Krita Source Code Documentation
Loading...
Searching...
No Matches
KisScreenInformationAdapter::Private Struct Reference

Public Member Functions

void initialize (QOpenGLContext *context)
 

Public Attributes

QOpenGLContext * context
 
QString errorString
 

Detailed Description

Definition at line 56 of file KisScreenInformationAdapter.cpp.

Member Function Documentation

◆ initialize()

void KisScreenInformationAdapter::Private::initialize ( QOpenGLContext * context)

Definition at line 80 of file KisScreenInformationAdapter.cpp.

81{
82 context = newContext;
83 errorString.clear();
84
85 try {
86
87#if defined Q_OS_WIN
88
89 if (!context->isOpenGLES()) {
90 throw EGLException("the context is not OpenGL ES");
91 }
92
93 PFNEGLQUERYSTRINGPROC queryString = nullptr;
94 getProcAddressSafe(context, "eglQueryString", queryString);
95
96 const char* client_extensions = queryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
97 const QList<QByteArray> extensions = QByteArray(client_extensions).split(' ');
98
99 if (!extensions.contains("EGL_ANGLE_platform_angle_d3d") ||
100 !extensions.contains("EGL_ANGLE_device_creation_d3d11")) {
101
102 throw EGLException("the context is not Angle + D3D11");
103 }
104
105 PFNEGLQUERYDISPLAYATTRIBEXTPROC queryDisplayAttribEXT = nullptr;
106 PFNEGLQUERYDEVICEATTRIBEXTPROC queryDeviceAttribEXT = nullptr;
107
108 getProcAddressSafe(context, "eglQueryDisplayAttribEXT", queryDisplayAttribEXT);
109 getProcAddressSafe(context, "eglQueryDeviceAttribEXT", queryDeviceAttribEXT);
110
111 QPlatformNativeInterface *nativeInterface = qGuiApp->platformNativeInterface();
112 EGLDisplay display = reinterpret_cast<EGLDisplay>(nativeInterface->nativeResourceForContext("egldisplay", context));
113
114 if (!display) {
115 throw EGLException(
116 QString("couldn't request EGLDisplay handle, display = 0x%1").arg(uintptr_t(display), 0, 16));
117 }
118
119 EGLAttrib value = 0;
120 EGLBoolean result = false;
121
122 result = queryDisplayAttribEXT(display, EGL_DEVICE_EXT, &value);
123
124 if (!result || value == EGL_NONE) {
125 throw EGLException(
126 QString("couldn't request EGLDeviceEXT handle, result = 0x%1, value = 0x%2")
127 .arg(result, 0, 16).arg(value, 0, 16));
128 }
129
130 EGLDeviceEXT device = reinterpret_cast<EGLDeviceEXT>(value);
131
132 result = queryDeviceAttribEXT(device, EGL_D3D11_DEVICE_ANGLE, &value);
133
134 if (!result || value == EGL_NONE) {
135 throw EGLException(
136 QString("couldn't request ID3D11Device pointer, result = 0x%1, value = 0x%2")
137 .arg(result, 0, 16).arg(value, 0, 16));
138 }
139 ID3D11Device *deviceD3D = reinterpret_cast<ID3D11Device*>(value);
140
141 {
142 HRESULT result = 0;
143
144 Microsoft::WRL::ComPtr<IDXGIDevice> dxgiDevice;
145 result = deviceD3D->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
146
147 if (FAILED(result)) {
148 throw EGLException(
149 QString("couldn't request IDXGIDevice pointer, result = 0x%1").arg(result, 0, 16));
150 }
151
152 Microsoft::WRL::ComPtr<IDXGIAdapter1> dxgiAdapter;
153 result = dxgiDevice->GetParent(__uuidof(IDXGIAdapter1), (void**)&dxgiAdapter);
154
155 if (FAILED(result)) {
156 throw EGLException(
157 QString("couldn't request IDXGIAdapter1 pointer, result = 0x%1").arg(result, 0, 16));
158 }
159
160 this->dxgiAdapter = dxgiAdapter;
161 }
162
163#else
164 throw EGLException("current platform doesn't support fetching display information");
165#endif
166
167 } catch (EGLException &e) {
168 this->context = 0;
169 this->errorString = e.what();
170#ifdef Q_OS_WIN
171 this->dxgiAdapter.Reset();
172#endif
173 }
174}
float value(const T *src, size_t ch)

References context, errorString, and value().

Member Data Documentation

◆ context

QOpenGLContext* KisScreenInformationAdapter::Private::context

Definition at line 60 of file KisScreenInformationAdapter.cpp.

◆ errorString

QString KisScreenInformationAdapter::Private::errorString

Definition at line 61 of file KisScreenInformationAdapter.cpp.


The documentation for this struct was generated from the following file: