Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | QGLFormat QGLFormat::fromSurfaceFormat(const QSurfaceFormat &format) | - |
10 | { | - |
11 | QGLFormat retFormat; | - |
12 | if (format.alphaBufferSize() >= 0) never evaluated: format.alphaBufferSize() >= 0 | 0 |
13 | retFormat.setAlphaBufferSize(format.alphaBufferSize()); never executed: retFormat.setAlphaBufferSize(format.alphaBufferSize()); | 0 |
14 | if (format.blueBufferSize() >= 0) never evaluated: format.blueBufferSize() >= 0 | 0 |
15 | retFormat.setBlueBufferSize(format.blueBufferSize()); never executed: retFormat.setBlueBufferSize(format.blueBufferSize()); | 0 |
16 | if (format.greenBufferSize() >= 0) never evaluated: format.greenBufferSize() >= 0 | 0 |
17 | retFormat.setGreenBufferSize(format.greenBufferSize()); never executed: retFormat.setGreenBufferSize(format.greenBufferSize()); | 0 |
18 | if (format.redBufferSize() >= 0) never evaluated: format.redBufferSize() >= 0 | 0 |
19 | retFormat.setRedBufferSize(format.redBufferSize()); never executed: retFormat.setRedBufferSize(format.redBufferSize()); | 0 |
20 | if (format.depthBufferSize() >= 0) never evaluated: format.depthBufferSize() >= 0 | 0 |
21 | retFormat.setDepthBufferSize(format.depthBufferSize()); never executed: retFormat.setDepthBufferSize(format.depthBufferSize()); | 0 |
22 | if (format.samples() > 1) { never evaluated: format.samples() > 1 | 0 |
23 | retFormat.setSampleBuffers(true); | - |
24 | retFormat.setSamples(format.samples()); | - |
25 | } | 0 |
26 | if (format.stencilBufferSize() > 0) { never evaluated: format.stencilBufferSize() > 0 | 0 |
27 | retFormat.setStencil(true); | - |
28 | retFormat.setStencilBufferSize(format.stencilBufferSize()); | - |
29 | } | 0 |
30 | retFormat.setDoubleBuffer(format.swapBehavior() != QSurfaceFormat::SingleBuffer); | - |
31 | retFormat.setStereo(format.stereo()); | - |
32 | retFormat.setVersion(format.majorVersion(), format.minorVersion()); | - |
33 | retFormat.setProfile(static_cast<QGLFormat::OpenGLContextProfile>(format.profile())); | - |
34 | return retFormat; never executed: return retFormat; | 0 |
35 | } | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format) | - |
41 | { | - |
42 | QSurfaceFormat retFormat; | - |
43 | if (format.alpha()) never evaluated: format.alpha() | 0 |
44 | retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize()); never executed: retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize()); | 0 |
45 | if (format.blueBufferSize() >= 0) never evaluated: format.blueBufferSize() >= 0 | 0 |
46 | retFormat.setBlueBufferSize(format.blueBufferSize()); never executed: retFormat.setBlueBufferSize(format.blueBufferSize()); | 0 |
47 | if (format.greenBufferSize() >= 0) never evaluated: format.greenBufferSize() >= 0 | 0 |
48 | retFormat.setGreenBufferSize(format.greenBufferSize()); never executed: retFormat.setGreenBufferSize(format.greenBufferSize()); | 0 |
49 | if (format.redBufferSize() >= 0) never evaluated: format.redBufferSize() >= 0 | 0 |
50 | retFormat.setRedBufferSize(format.redBufferSize()); never executed: retFormat.setRedBufferSize(format.redBufferSize()); | 0 |
51 | if (format.depth()) never evaluated: format.depth() | 0 |
52 | retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize()); never executed: retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize()); | 0 |
53 | retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::SingleBuffer); | - |
54 | if (format.sampleBuffers()) never evaluated: format.sampleBuffers() | 0 |
55 | retFormat.setSamples(format.samples() == -1 ? 4 : format.samples()); never executed: retFormat.setSamples(format.samples() == -1 ? 4 : format.samples()); | 0 |
56 | if (format.stencil()) never evaluated: format.stencil() | 0 |
57 | retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize()); never executed: retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize()); | 0 |
58 | retFormat.setStereo(format.stereo()); | - |
59 | retFormat.setMajorVersion(format.majorVersion()); | - |
60 | retFormat.setMinorVersion(format.minorVersion()); | - |
61 | retFormat.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(format.profile())); | - |
62 | return retFormat; never executed: return retFormat; | 0 |
63 | } | - |
64 | | - |
65 | void QGLContextPrivate::setupSharing() { | - |
66 | QGLContext * const q = q_func(); | - |
67 | QOpenGLContext *sharedContext = guiGlContext->shareContext(); | - |
68 | if (sharedContext) { never evaluated: sharedContext | 0 |
69 | QGLContext *actualSharedContext = QGLContext::fromOpenGLContext(sharedContext); | - |
70 | sharing = true; | - |
71 | QGLContextGroup::addShare(q, actualSharedContext); | - |
72 | } | 0 |
73 | } | 0 |
74 | | - |
75 | bool QGLFormat::hasOpenGL() | - |
76 | { | - |
77 | return QApplicationPrivate::platformIntegration() | 0 |
78 | ->hasCapability(QPlatformIntegration::OpenGL); never executed: return QApplicationPrivate::platformIntegration() ->hasCapability(QPlatformIntegration::OpenGL); | 0 |
79 | } | - |
80 | | - |
81 | void qDeleteQGLContext(void *handle) | - |
82 | { | - |
83 | QGLContext *context = static_cast<QGLContext *>(handle); | - |
84 | delete context; | - |
85 | } | 0 |
86 | | - |
87 | bool QGLContext::chooseContext(const QGLContext* shareContext) | - |
88 | { | - |
89 | QGLContextPrivate * const d = d_func(); | - |
90 | if(!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) { never evaluated: !d->paintDevice never evaluated: d->paintDevice->devType() != QInternal::Widget | 0 |
91 | d->valid = false; | - |
92 | }else { | 0 |
93 | QWidget *widget = static_cast<QWidget *>(d->paintDevice); | - |
94 | QGLFormat glformat = format(); | - |
95 | QSurfaceFormat winFormat = QGLFormat::toSurfaceFormat(glformat); | - |
96 | if (widget->testAttribute(Qt::WA_TranslucentBackground)) never evaluated: widget->testAttribute(Qt::WA_TranslucentBackground) | 0 |
97 | winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8)); never executed: winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8)); | 0 |
98 | | - |
99 | if (!widget->windowHandle()->handle()) { never evaluated: !widget->windowHandle()->handle() | 0 |
100 | widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface); | - |
101 | widget->windowHandle()->setFormat(winFormat); | - |
102 | widget->winId(); | - |
103 | } | 0 |
104 | | - |
105 | if (d->ownContext) never evaluated: d->ownContext | 0 |
106 | delete d->guiGlContext; never executed: delete d->guiGlContext; | 0 |
107 | d->ownContext = true; | - |
108 | QOpenGLContext *shareGlContext = shareContext ? shareContext->d_func()->guiGlContext : 0; never evaluated: shareContext | 0 |
109 | d->guiGlContext = new QOpenGLContext; | - |
110 | d->guiGlContext->setFormat(winFormat); | - |
111 | d->guiGlContext->setShareContext(shareGlContext); | - |
112 | d->valid = d->guiGlContext->create(); | - |
113 | | - |
114 | if (d->valid) never evaluated: d->valid | 0 |
115 | d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext); never executed: d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext); | 0 |
116 | | - |
117 | d->glFormat = QGLFormat::fromSurfaceFormat(d->guiGlContext->format()); | - |
118 | d->setupSharing(); | - |
119 | } | 0 |
120 | | - |
121 | | - |
122 | return d->valid; never executed: return d->valid; | 0 |
123 | } | - |
124 | | - |
125 | void QGLContext::reset() | - |
126 | { | - |
127 | QGLContextPrivate * const d = d_func(); | - |
128 | if (!d->valid) never evaluated: !d->valid | 0 |
129 | return; | 0 |
130 | d->cleanup(); | - |
131 | | - |
132 | d->crWin = false; | - |
133 | d->sharing = false; | - |
134 | d->valid = false; | - |
135 | d->transpColor = QColor(); | - |
136 | d->initDone = false; | - |
137 | QGLContextGroup::removeShare(this); | - |
138 | if (d->guiGlContext) { never evaluated: d->guiGlContext | 0 |
139 | if (QOpenGLContext::currentContext() == d->guiGlContext) never evaluated: QOpenGLContext::currentContext() == d->guiGlContext | 0 |
140 | doneCurrent(); never executed: doneCurrent(); | 0 |
141 | if (d->ownContext) { never evaluated: d->ownContext | 0 |
142 | if (d->guiGlContext->thread() == QThread::currentThread()) never evaluated: d->guiGlContext->thread() == QThread::currentThread() | 0 |
143 | delete d->guiGlContext; never executed: delete d->guiGlContext; | 0 |
144 | else | - |
145 | d->guiGlContext->deleteLater(); never executed: d->guiGlContext->deleteLater(); | 0 |
146 | } else | - |
147 | d->guiGlContext->setQGLContextHandle(0,0); never executed: d->guiGlContext->setQGLContextHandle(0,0); | 0 |
148 | d->guiGlContext = 0; | - |
149 | } | 0 |
150 | d->ownContext = false; | - |
151 | } | 0 |
152 | | - |
153 | void QGLContext::makeCurrent() | - |
154 | { | - |
155 | QGLContextPrivate * const d = d_func(); | - |
156 | if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) never evaluated: !d->paintDevice never evaluated: d->paintDevice->devType() != QInternal::Widget | 0 |
157 | return; | 0 |
158 | | - |
159 | QWidget *widget = static_cast<QWidget *>(d->paintDevice); | - |
160 | if (!widget->windowHandle()) never evaluated: !widget->windowHandle() | 0 |
161 | return; | 0 |
162 | | - |
163 | if (d->guiGlContext->makeCurrent(widget->windowHandle())) { never evaluated: d->guiGlContext->makeCurrent(widget->windowHandle()) | 0 |
164 | if (!d->workaroundsCached) { never evaluated: !d->workaroundsCached | 0 |
165 | d->workaroundsCached = true; | - |
166 | const char *renderer = reinterpret_cast<const char *>(glGetString(0x1F01)); | - |
167 | if (renderer && strstr(renderer, "Mali")) { never evaluated: renderer never evaluated: strstr(renderer, "Mali") | 0 |
168 | d->workaround_brokenFBOReadBack = true; | - |
169 | } | 0 |
170 | } | 0 |
171 | } | 0 |
172 | } | 0 |
173 | | - |
174 | void QGLContext::doneCurrent() | - |
175 | { | - |
176 | QGLContextPrivate * const d = d_func(); | - |
177 | d->guiGlContext->doneCurrent(); | - |
178 | } | 0 |
179 | | - |
180 | void QGLContext::swapBuffers() const | - |
181 | { | - |
182 | const QGLContextPrivate * const d = d_func(); | - |
183 | if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) never evaluated: !d->paintDevice never evaluated: d->paintDevice->devType() != QInternal::Widget | 0 |
184 | return; | 0 |
185 | | - |
186 | QWidget *widget = static_cast<QWidget *>(d->paintDevice); | - |
187 | if (!widget->windowHandle()) never evaluated: !widget->windowHandle() | 0 |
188 | return; | 0 |
189 | | - |
190 | d->guiGlContext->swapBuffers(widget->windowHandle()); | - |
191 | } | 0 |
192 | | - |
193 | QFunctionPointer QGLContext::getProcAddress(const QString &procName) const | - |
194 | { | - |
195 | const QGLContextPrivate * const d = d_func(); | - |
196 | return d->guiGlContext->getProcAddress(procName.toLatin1()); never executed: return d->guiGlContext->getProcAddress(procName.toLatin1()); | 0 |
197 | } | - |
198 | | - |
199 | void QGLWidget::setContext(QGLContext *context, | - |
200 | const QGLContext* shareContext, | - |
201 | bool deleteOldContext) | - |
202 | { | - |
203 | QGLWidgetPrivate * const d = d_func(); | - |
204 | if (context == 0) { never evaluated: context == 0 | 0 |
205 | QMessageLogger("qgl_qpa.cpp", 255, __PRETTY_FUNCTION__).warning("QGLWidget::setContext: Cannot set null context"); | - |
206 | return; | 0 |
207 | } | - |
208 | | - |
209 | if (context->device() == 0) never evaluated: context->device() == 0 | 0 |
210 | context->setDevice(this); never executed: context->setDevice(this); | 0 |
211 | | - |
212 | QGLContext* oldcx = d->glcx; | - |
213 | d->glcx = context; | - |
214 | | - |
215 | if (!d->glcx->isValid()) never evaluated: !d->glcx->isValid() | 0 |
216 | d->glcx->create(shareContext ? shareContext : oldcx); never executed: d->glcx->create(shareContext ? shareContext : oldcx); | 0 |
217 | | - |
218 | if (deleteOldContext) never evaluated: deleteOldContext | 0 |
219 | delete oldcx; never executed: delete oldcx; | 0 |
220 | } | 0 |
221 | | - |
222 | void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) | - |
223 | { | - |
224 | initContext(context, shareWidget); | - |
225 | } | 0 |
226 | | - |
227 | bool QGLFormat::hasOpenGLOverlays() | - |
228 | { | - |
229 | return false; never executed: return false; | 0 |
230 | } | - |
231 | | - |
232 | QColor QGLContext::overlayTransparentColor() const | - |
233 | { | - |
234 | return QColor(); never executed: return QColor(); | 0 |
235 | } | - |
236 | | - |
237 | uint QGLContext::colorIndex(const QColor&) const | - |
238 | { | - |
239 | return 0; never executed: return 0; | 0 |
240 | } | - |
241 | | - |
242 | | - |
243 | | - |
244 | | - |
245 | class QGLTemporaryContextPrivate | - |
246 | { | - |
247 | public: | - |
248 | QWindow *window; | - |
249 | QOpenGLContext *context; | - |
250 | | - |
251 | QGLContext *oldContext; | - |
252 | }; | - |
253 | | - |
254 | QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) | - |
255 | : d(new QGLTemporaryContextPrivate) | - |
256 | { | - |
257 | d->oldContext = const_cast<QGLContext *>(QGLContext::currentContext()); | - |
258 | | - |
259 | d->window = new QWindow; | - |
260 | d->window->setSurfaceType(QWindow::OpenGLSurface); | - |
261 | d->window->setGeometry(QRect(0, 0, 3, 3)); | - |
262 | d->window->create(); | - |
263 | | - |
264 | d->context = new QOpenGLContext; | - |
265 | | - |
266 | | - |
267 | QSurfaceFormat format; | - |
268 | format.setMajorVersion(4); | - |
269 | format.setMinorVersion(3); | - |
270 | | - |
271 | d->context->setFormat(format); | - |
272 | | - |
273 | d->context->create(); | - |
274 | d->context->makeCurrent(d->window); | - |
275 | } | 0 |
276 | | - |
277 | QGLTemporaryContext::~QGLTemporaryContext() | - |
278 | { | - |
279 | if (d->oldContext) never evaluated: d->oldContext | 0 |
280 | d->oldContext->makeCurrent(); never executed: d->oldContext->makeCurrent(); | 0 |
281 | | - |
282 | delete d->context; | - |
283 | delete d->window; | - |
284 | } | 0 |
285 | | - |
286 | | - |
287 | bool QGLWidgetPrivate::renderCxPm(QPixmap*) | - |
288 | { | - |
289 | return false; never executed: return false; | 0 |
290 | } | - |
291 | | - |
292 | | - |
293 | | - |
294 | | - |
295 | | - |
296 | void QGLWidgetPrivate::cleanupColormaps() | - |
297 | { | - |
298 | } | - |
299 | | - |
300 | bool QGLWidget::event(QEvent *e) | - |
301 | { | - |
302 | return QWidget::event(e); never executed: return QWidget::event(e); | 0 |
303 | } | - |
304 | | - |
305 | void QGLWidget::resizeEvent(QResizeEvent *e) | - |
306 | { | - |
307 | QGLWidgetPrivate * const d = d_func(); | - |
308 | | - |
309 | QWidget::resizeEvent(e); | - |
310 | if (!isValid()) never evaluated: !isValid() | 0 |
311 | return; | 0 |
312 | makeCurrent(); | - |
313 | if (!d->glcx->initialized()) never evaluated: !d->glcx->initialized() | 0 |
314 | glInit(); never executed: glInit(); | 0 |
315 | const qreal scaleFactor = (window() && window()->windowHandle()) ? never evaluated: window() never evaluated: window()->windowHandle() | 0 |
316 | window()->windowHandle()->devicePixelRatio() : 1.0; | - |
317 | | - |
318 | resizeGL(width() * scaleFactor, height() * scaleFactor); | - |
319 | } | 0 |
320 | | - |
321 | | - |
322 | const QGLContext* QGLWidget::overlayContext() const | - |
323 | { | - |
324 | return 0; never executed: return 0; | 0 |
325 | } | - |
326 | | - |
327 | void QGLWidget::makeOverlayCurrent() | - |
328 | { | - |
329 | } | - |
330 | | - |
331 | | - |
332 | void QGLWidget::updateOverlayGL() | - |
333 | { | - |
334 | } | - |
335 | | - |
336 | const QGLColormap & QGLWidget::colormap() const | - |
337 | { | - |
338 | const QGLWidgetPrivate * const d = d_func(); | - |
339 | return d->cmap; never executed: return d->cmap; | 0 |
340 | } | - |
341 | | - |
342 | void QGLWidget::setColormap(const QGLColormap & c) | - |
343 | { | - |
344 | (void)c;; | - |
345 | } | 0 |
346 | | - |
347 | QGLContext::QGLContext(QOpenGLContext *context) | - |
348 | : d_ptr(new QGLContextPrivate(this)) | - |
349 | { | - |
350 | QGLContextPrivate * const d = d_func(); | - |
351 | d->init(0, QGLFormat::fromSurfaceFormat(context->format())); | - |
352 | d->guiGlContext = context; | - |
353 | d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext); | - |
354 | d->ownContext = false; | - |
355 | d->valid = context->isValid(); | - |
356 | d->setupSharing(); | - |
357 | } | 0 |
358 | | - |
359 | QOpenGLContext *QGLContext::contextHandle() const | - |
360 | { | - |
361 | const QGLContextPrivate * const d = d_func(); | - |
362 | return d->guiGlContext; never executed: return d->guiGlContext; | 0 |
363 | } | - |
364 | | - |
365 | | - |
366 | | - |
367 | | - |
368 | | - |
369 | QGLContext *QGLContext::fromOpenGLContext(QOpenGLContext *context) | - |
370 | { | - |
371 | if (!context) never evaluated: !context | 0 |
372 | return 0; never executed: return 0; | 0 |
373 | if (context->qGLContextHandle()) { never evaluated: context->qGLContextHandle() | 0 |
374 | return reinterpret_cast<QGLContext *>(context->qGLContextHandle()); never executed: return reinterpret_cast<QGLContext *>(context->qGLContextHandle()); | 0 |
375 | } | - |
376 | QGLContext *glContext = new QGLContext(context); | - |
377 | | - |
378 | | - |
379 | return glContext; never executed: return glContext; | 0 |
380 | } | - |
381 | | - |
382 | | - |
383 | | - |
| | |