qopenglcontext.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qopenglcontext.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12class QOpenGLVersionProfilePrivate-
13{-
14public:-
15 QOpenGLVersionProfilePrivate()-
16 : majorVersion(0),-
17 minorVersion(0),-
18 profile(QSurfaceFormat::NoProfile)-
19 {}
never executed: end of block
0
20-
21 int majorVersion;-
22 int minorVersion;-
23 QSurfaceFormat::OpenGLContextProfile profile;-
24};-
25QOpenGLVersionProfile::QOpenGLVersionProfile()-
26 : d(new QOpenGLVersionProfilePrivate)-
27{-
28}
never executed: end of block
0
29-
30-
31-
32-
33-
34QOpenGLVersionProfile::QOpenGLVersionProfile(const QSurfaceFormat &format)-
35 : d(new QOpenGLVersionProfilePrivate)-
36{-
37 d->majorVersion = format.majorVersion();-
38 d->minorVersion = format.minorVersion();-
39 d->profile = format.profile();-
40}
never executed: end of block
0
41-
42-
43-
44-
45QOpenGLVersionProfile::QOpenGLVersionProfile(const QOpenGLVersionProfile &other)-
46 : d(new QOpenGLVersionProfilePrivate)-
47{-
48 *d = *(other.d);-
49}
never executed: end of block
0
50-
51-
52-
53-
54QOpenGLVersionProfile::~QOpenGLVersionProfile()-
55{-
56 delete d;-
57}
never executed: end of block
0
58-
59-
60-
61-
62QOpenGLVersionProfile &QOpenGLVersionProfile::operator=(const QOpenGLVersionProfile &rhs)-
63{-
64 if (this == &rhs
this == &rhsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
65 return
never executed: return *this;
*this;
never executed: return *this;
0
66 *d = *(rhs.d);-
67 return
never executed: return *this;
*this;
never executed: return *this;
0
68}-
69-
70-
71-
72-
73-
74-
75-
76QPair<int, int> QOpenGLVersionProfile::version() const-
77{-
78 return
never executed: return qMakePair( d->majorVersion, d->minorVersion);
qMakePair( d->majorVersion, d->minorVersion);
never executed: return qMakePair( d->majorVersion, d->minorVersion);
0
79}-
80-
81-
82-
83-
84-
85-
86void QOpenGLVersionProfile::setVersion(int majorVersion, int minorVersion)-
87{-
88 d->majorVersion = majorVersion;-
89 d->minorVersion = minorVersion;-
90}
never executed: end of block
0
91-
92-
93-
94-
95-
96-
97QSurfaceFormat::OpenGLContextProfile QOpenGLVersionProfile::profile() const-
98{-
99 return
never executed: return d->profile;
d->profile;
never executed: return d->profile;
0
100}-
101-
102-
103-
104-
105-
106-
107-
108void QOpenGLVersionProfile::setProfile(QSurfaceFormat::OpenGLContextProfile profile)-
109{-
110 d->profile = profile;-
111}
never executed: end of block
0
112-
113-
114-
115-
116-
117-
118-
119bool QOpenGLVersionProfile::hasProfiles() const-
120{-
121 return
never executed: return ( d->majorVersion > 3 || (d->majorVersion == 3 && d->minorVersion > 1));
( d->majorVersion > 3
never executed: return ( d->majorVersion > 3 || (d->majorVersion == 3 && d->minorVersion > 1));
0
122 || (d->majorVersion == 3 && d->minorVersion > 1));
never executed: return ( d->majorVersion > 3 || (d->majorVersion == 3 && d->minorVersion > 1));
0
123}-
124-
125-
126-
127-
128-
129bool QOpenGLVersionProfile::isLegacyVersion() const-
130{-
131 return
never executed: return (d->majorVersion < 3 || (d->majorVersion == 3 && d->minorVersion == 0));
(d->majorVersion < 3 || (d->majorVersion == 3 && d->minorVersion == 0));
never executed: return (d->majorVersion < 3 || (d->majorVersion == 3 && d->minorVersion == 0));
0
132}-
133-
134-
135-
136-
137-
138-
139-
140bool QOpenGLVersionProfile::isValid() const-
141{-
142 return
never executed: return d->majorVersion > 0 && d->minorVersion >= 0;
d->majorVersion > 0 && d->minorVersion >= 0;
never executed: return d->majorVersion > 0 && d->minorVersion >= 0;
0
143}-
144-
145class QGuiGLThreadContext-
146{-
147public:-
148 QGuiGLThreadContext()-
149 : context(0)-
150 {-
151 }
never executed: end of block
0
152 ~QGuiGLThreadContext() {-
153 if (context
contextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
154 context->doneCurrent();
never executed: context->doneCurrent();
0
155 }
never executed: end of block
0
156 QOpenGLContext *context;-
157};-
158-
159namespace { namespace Q_QGS_qwindow_context_storage { typedef QThreadStorage<QGuiGLThreadContext *> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
never executed: guard.store(QtGlobalStatic::Destroyed);
}
never executed: end of block
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return
never executed: return &holder.value;
&holder.value;
never executed: return &holder.value;
} } } static QGlobalStatic<QThreadStorage<QGuiGLThreadContext *>, Q_QGS_qwindow_context_storage::innerFunction, Q_QGS_qwindow_context_storage::guard> qwindow_context_storage;;
0
160static QOpenGLContext *global_share_context = 0;-
161-
162-
163QHash<QOpenGLContext *, bool> QOpenGLContextPrivate::makeCurrentTracker;-
164QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;-
165void qt_gl_set_global_share_context(QOpenGLContext *context)-
166{-
167 global_share_context = context;-
168}
never executed: end of block
0
169-
170-
171-
172-
173QOpenGLContext *qt_gl_global_share_context()-
174{-
175 return
never executed: return global_share_context;
global_share_context;
never executed: return global_share_context;
0
176}-
177QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context)-
178{-
179 QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();-
180 if (!threadContext
!threadContextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
181 if (!QThread::currentThread()
!QThread::currentThread()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
182 QMessageLogger(__FILE__, 348, __PRETTY_FUNCTION__).warning("No QTLS available. currentContext won't work");-
183 return
never executed: return 0;
0;
never executed: return 0;
0
184 }-
185 threadContext = new QGuiGLThreadContext;-
186 qwindow_context_storage()->setLocalData(threadContext);-
187 }
never executed: end of block
0
188 QOpenGLContext *previous = threadContext->context;-
189 threadContext->context = context;-
190 return
never executed: return previous;
previous;
never executed: return previous;
0
191}-
192-
193int QOpenGLContextPrivate::maxTextureSize()-
194{-
195 if (max_texture_size != -1
max_texture_size != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
196 return
never executed: return max_texture_size;
max_texture_size;
never executed: return max_texture_size;
0
197-
198 QOpenGLContext * const q = q_func();-
199 QOpenGLFunctions *funcs = q->functions();-
200 funcs->glGetIntegerv(0x0D33, &max_texture_size);-
201-
202-
203 if (!q->isOpenGLES()
!q->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
204 GLenum proxy = 0x8064;-
205-
206 GLint size;-
207 GLint next = 64;-
208 funcs->glTexImage2D(proxy, 0, 0x1908, next, next, 0, 0x1908, 0x1401, 0);-
209-
210 QOpenGLFunctions_1_0 *gl1funcs = 0;-
211 QOpenGLFunctions_3_2_Core *gl3funcs = 0;-
212-
213 if (q->format().profile() == QSurfaceFormat::CoreProfile
q->format().pr...t::CoreProfileDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
214 gl3funcs = q->versionFunctions<QOpenGLFunctions_3_2_Core>();
never executed: gl3funcs = q->versionFunctions<QOpenGLFunctions_3_2_Core>();
0
215 else-
216 gl1funcs = q->versionFunctions<QOpenGLFunctions_1_0>();
never executed: gl1funcs = q->versionFunctions<QOpenGLFunctions_1_0>();
0
217-
218 ((!(gl1funcs || gl3funcs)) ? qt_assert("gl1funcs || gl3funcs",__FILE__,384) : qt_noop());-
219-
220 if (gl1funcs
gl1funcsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
221 gl1funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &size);
never executed: gl1funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &size);
0
222 else-
223 gl3funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &size);
never executed: gl3funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &size);
0
224-
225 if (size == 0
size == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
226 return
never executed: return max_texture_size;
max_texture_size;
never executed: return max_texture_size;
0
227 }-
228 do {-
229 size = next;-
230 next = size * 2;-
231-
232 if (next > max_texture_size
next > max_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
233 break;
never executed: break;
0
234 funcs->glTexImage2D(proxy, 0, 0x1908, next, next, 0, 0x1908, 0x1401, 0);-
235 if (gl1funcs
gl1funcsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
236 gl1funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &next);
never executed: gl1funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &next);
0
237 else-
238 gl3funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &next);
never executed: gl3funcs->glGetTexLevelParameteriv(proxy, 0, 0x1000, &next);
0
239-
240 } while (next > size
next > sizeDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
241-
242 max_texture_size = size;-
243 }
never executed: end of block
0
244-
245-
246 return
never executed: return max_texture_size;
max_texture_size;
never executed: return max_texture_size;
0
247}-
248-
249-
250-
251-
252-
253QOpenGLContext* QOpenGLContext::currentContext()-
254{-
255 QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();-
256 if (threadContext
threadContextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
257 return
never executed: return threadContext->context;
threadContext->context;
never executed: return threadContext->context;
0
258 }-
259 return
never executed: return 0;
0;
never executed: return 0;
0
260}-
261-
262-
263-
264-
265bool QOpenGLContext::areSharing(QOpenGLContext *first, QOpenGLContext *second)-
266{-
267 return
never executed: return first->shareGroup() == second->shareGroup();
first->shareGroup() == second->shareGroup();
never executed: return first->shareGroup() == second->shareGroup();
0
268}-
269-
270-
271-
272-
273-
274-
275QPlatformOpenGLContext *QOpenGLContext::handle() const-
276{-
277 const QOpenGLContextPrivate * const d = d_func();-
278 return
never executed: return d->platformGLContext;
d->platformGLContext;
never executed: return d->platformGLContext;
0
279}-
280-
281-
282-
283-
284-
285-
286-
287QPlatformOpenGLContext *QOpenGLContext::shareHandle() const-
288{-
289 const QOpenGLContextPrivate * const d = d_func();-
290 if (d->shareContext
d->shareContextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
291 return
never executed: return d->shareContext->handle();
d->shareContext->handle();
never executed: return d->shareContext->handle();
0
292 return
never executed: return 0;
0;
never executed: return 0;
0
293}-
294QOpenGLContext::QOpenGLContext(QObject *parent)-
295 : QObject(*new QOpenGLContextPrivate(), parent)-
296{-
297 setScreen(QGuiApplication::primaryScreen());-
298}
never executed: end of block
0
299void QOpenGLContext::setFormat(const QSurfaceFormat &format)-
300{-
301 QOpenGLContextPrivate * const d = d_func();-
302 d->requestedFormat = format;-
303}
never executed: end of block
0
304-
305-
306-
307-
308-
309void QOpenGLContext::setShareContext(QOpenGLContext *shareContext)-
310{-
311 QOpenGLContextPrivate * const d = d_func();-
312 d->shareContext = shareContext;-
313}
never executed: end of block
0
314-
315-
316-
317-
318-
319void QOpenGLContext::setScreen(QScreen *screen)-
320{-
321 QOpenGLContextPrivate * const d = d_func();-
322 if (d->screen
d->screenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
323 disconnect(d->screen, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "508"), this, qFlagLocation("1""_q_screenDestroyed(QObject*)" "\0" __FILE__ ":" "508"));
never executed: disconnect(d->screen, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "508"), this, qFlagLocation("1""_q_screenDestroyed(QObject*)" "\0" __FILE__ ":" "508"));
0
324 d->screen = screen;-
325 if (!d->screen
!d->screenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
326 d->screen = QGuiApplication::primaryScreen();
never executed: d->screen = QGuiApplication::primaryScreen();
0
327 if (d->screen
d->screenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
328 connect(d->screen, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "513"), this, qFlagLocation("1""_q_screenDestroyed(QObject*)" "\0" __FILE__ ":" "513"));
never executed: connect(d->screen, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "513"), this, qFlagLocation("1""_q_screenDestroyed(QObject*)" "\0" __FILE__ ":" "513"));
0
329}
never executed: end of block
0
330-
331void QOpenGLContextPrivate::_q_screenDestroyed(QObject *object)-
332{-
333 QOpenGLContext * const q = q_func();-
334 if (object == static_cast<QObject *>(screen)
object == stat...ect *>(screen)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
335 screen = 0;-
336 q->setScreen(0);-
337 }
never executed: end of block
0
338}
never executed: end of block
0
339void QOpenGLContext::setNativeHandle(const QVariant &handle)-
340{-
341 QOpenGLContextPrivate * const d = d_func();-
342 d->nativeHandle = handle;-
343}
never executed: end of block
0
344QVariant QOpenGLContext::nativeHandle() const-
345{-
346 const QOpenGLContextPrivate * const d = d_func();-
347 return
never executed: return d->nativeHandle;
d->nativeHandle;
never executed: return d->nativeHandle;
0
348}-
349bool QOpenGLContext::create()-
350{-
351 QOpenGLContextPrivate * const d = d_func();-
352 if (d->platformGLContext
d->platformGLContextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
353 destroy();
never executed: destroy();
0
354-
355 d->platformGLContext = QGuiApplicationPrivate::platformIntegration()->createPlatformOpenGLContext(this);-
356 if (!d->platformGLContext
!d->platformGLContextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
357 return
never executed: return false;
false;
never executed: return false;
0
358 d->platformGLContext->initialize();-
359 d->platformGLContext->setContext(this);-
360 if (!d->platformGLContext->isSharing()
!d->platformGL...t->isSharing()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
361 d->shareContext = 0;
never executed: d->shareContext = 0;
0
362 d->shareGroup = d->shareContext
d->shareContextDescription
TRUEnever evaluated
FALSEnever evaluated
? d->shareContext->shareGroup() : new QOpenGLContextGroup;
0
363 d->shareGroup->d_func()->addContext(this);-
364 return
never executed: return isValid();
isValid();
never executed: return isValid();
0
365}-
366void QOpenGLContext::destroy()-
367{-
368 deleteQGLContext();-
369 QOpenGLContextPrivate * const d = d_func();-
370 if (d->platformGLContext
d->platformGLContextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
371 aboutToBeDestroyed();
never executed: aboutToBeDestroyed();
0
372 if (QOpenGLContext::currentContext() == this
QOpenGLContext...text() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
373 doneCurrent();
never executed: doneCurrent();
0
374 if (d->shareGroup
d->shareGroupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
375 d->shareGroup->d_func()->removeContext(this);
never executed: d->shareGroup->d_func()->removeContext(this);
0
376 d->shareGroup = 0;-
377 delete d->platformGLContext;-
378 d->platformGLContext = 0;-
379 delete d->functions;-
380 d->functions = 0;-
381-
382 for (QAbstractOpenGLFunctions *func : qAsConst(d->externalVersionFunctions)) {-
383 QAbstractOpenGLFunctionsPrivate *func_d = QAbstractOpenGLFunctionsPrivate::get(func);-
384 func_d->owningContext = 0;-
385 func_d->initialized = false;-
386 }
never executed: end of block
0
387 d->externalVersionFunctions.clear();-
388 qDeleteAll(d->versionFunctions);-
389 d->versionFunctions.clear();-
390-
391 delete d->textureFunctions;-
392 d->textureFunctions = 0;-
393-
394 d->nativeHandle = QVariant();-
395}
never executed: end of block
0
396QOpenGLContext::~QOpenGLContext()-
397{-
398 destroy();-
399-
400-
401 QOpenGLContextPrivate::cleanMakeCurrentTracker(this);-
402-
403}
never executed: end of block
0
404bool QOpenGLContext::isValid() const-
405{-
406 const QOpenGLContextPrivate * const d = d_func();-
407 return
never executed: return d->platformGLContext && d->platformGLContext->isValid();
d->platformGLContext && d->platformGLContext->isValid();
never executed: return d->platformGLContext && d->platformGLContext->isValid();
0
408}-
409QOpenGLFunctions *QOpenGLContext::functions() const-
410{-
411 const QOpenGLContextPrivate * const d = d_func();-
412 if (!d->functions
!d->functionsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
413 const_cast<
never executed: const_cast<QOpenGLFunctions *&>(d->functions) = new QOpenGLExtensions(QOpenGLContext::currentContext());
QOpenGLFunctions *&>(d->functions) = new QOpenGLExtensions(QOpenGLContext::currentContext());
never executed: const_cast<QOpenGLFunctions *&>(d->functions) = new QOpenGLExtensions(QOpenGLContext::currentContext());
0
414 return
never executed: return d->functions;
d->functions;
never executed: return d->functions;
0
415}-
416QOpenGLExtraFunctions *QOpenGLContext::extraFunctions() const-
417{-
418 return
never executed: return static_cast<QOpenGLExtraFunctions *>(functions());
static_cast<QOpenGLExtraFunctions *>(functions());
never executed: return static_cast<QOpenGLExtraFunctions *>(functions());
0
419}-
420QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionProfile &versionProfile) const-
421{-
422-
423 if (isOpenGLES()
isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
424 QMessageLogger(__FILE__, 825, __PRETTY_FUNCTION__).warning("versionFunctions: Not supported on OpenGL ES");-
425 return
never executed: return 0;
0;
never executed: return 0;
0
426 }-
427-
428-
429 const QOpenGLContextPrivate * const d = d_func();-
430 const QSurfaceFormat f = format();-
431-
432-
433 QOpenGLVersionProfile vp = versionProfile;-
434 if (!vp.isValid()
!vp.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
435 vp = QOpenGLVersionProfile(f);
never executed: vp = QOpenGLVersionProfile(f);
0
436-
437-
438 const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());-
439 if (v < vp.version()
v < vp.version()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
440 return
never executed: return 0;
0;
never executed: return 0;
0
441-
442-
443-
444 if (((vp.hasProfiles()
vp.hasProfiles()Description
TRUEnever evaluated
FALSEnever evaluated
&& vp.profile() != QSurfaceFormat::CoreProfile
vp.profile() !...t::CoreProfileDescription
TRUEnever evaluated
FALSEnever evaluated
) || vp.isLegacyVersion()
vp.isLegacyVersion()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
445 && f.profile() == QSurfaceFormat::CoreProfile
f.profile() ==...t::CoreProfileDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
446 return
never executed: return 0;
0;
never executed: return 0;
0
447-
448-
449 QAbstractOpenGLFunctions* funcs = 0;-
450 if (!d->versionFunctions.contains(vp)
!d->versionFun...s.contains(vp)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
451 funcs = QOpenGLVersionFunctionsFactory::create(vp);-
452 if (funcs
funcsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
453 funcs->setOwningContext(this);-
454 d->versionFunctions.insert(vp, funcs);-
455 }
never executed: end of block
0
456 }
never executed: end of block
else {
0
457 funcs = d->versionFunctions.value(vp);-
458 }
never executed: end of block
0
459-
460 if (funcs
funcsDescription
TRUEnever evaluated
FALSEnever evaluated
&& QOpenGLContext::currentContext() == this
QOpenGLContext...text() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
461 funcs->initializeOpenGLFunctions();
never executed: funcs->initializeOpenGLFunctions();
0
462-
463 return
never executed: return funcs;
funcs;
never executed: return funcs;
0
464}-
465QSet<QByteArray> QOpenGLContext::extensions() const-
466{-
467 const QOpenGLContextPrivate * const d = d_func();-
468 if (d->extensionNames.isEmpty()
d->extensionNames.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
469 QOpenGLExtensionMatcher matcher;-
470 d->extensionNames = matcher.extensions();-
471 }
never executed: end of block
0
472-
473 return
never executed: return d->extensionNames;
d->extensionNames;
never executed: return d->extensionNames;
0
474}-
475bool QOpenGLContext::hasExtension(const QByteArray &extension) const-
476{-
477 return
never executed: return extensions().contains(extension);
extensions().contains(extension);
never executed: return extensions().contains(extension);
0
478}-
479GLuint QOpenGLContext::defaultFramebufferObject() const-
480{-
481 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
482 return
never executed: return 0;
0;
never executed: return 0;
0
483-
484 const QOpenGLContextPrivate * const d = d_func();-
485 if (!d->surface
!d->surfaceDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->surface->surfaceHandle()
!d->surface->surfaceHandle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
486 return
never executed: return 0;
0;
never executed: return 0;
0
487-
488 if (d->defaultFboRedirect
d->defaultFboRedirectDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
489 return
never executed: return d->defaultFboRedirect;
d->defaultFboRedirect;
never executed: return d->defaultFboRedirect;
0
490-
491 return
never executed: return d->platformGLContext->defaultFramebufferObject(d->surface->surfaceHandle());
d->platformGLContext->defaultFramebufferObject(d->surface->surfaceHandle());
never executed: return d->platformGLContext->defaultFramebufferObject(d->surface->surfaceHandle());
0
492}-
493bool QOpenGLContext::makeCurrent(QSurface *surface)-
494{-
495 QOpenGLContextPrivate * const d = d_func();-
496 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
497 return
never executed: return false;
false;
never executed: return false;
0
498-
499 if (__builtin_expect(!!(thread() != QThread::currentThread()), false)
__builtin_expe...ead()), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
500 QMessageLogger(__FILE__, 958, __PRETTY_FUNCTION__).fatal("Cannot make QOpenGLContext current in a different thread");
never executed: QMessageLogger(__FILE__, 958, __PRETTY_FUNCTION__).fatal("Cannot make QOpenGLContext current in a different thread");
0
501-
502 if (!surface
!surfaceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
503 doneCurrent();-
504 return
never executed: return true;
true;
never executed: return true;
0
505 }-
506-
507 if (!surface->surfaceHandle()
!surface->surfaceHandle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
508 return
never executed: return false;
false;
never executed: return false;
0
509 if (!surface->supportsOpenGL()
!surface->supportsOpenGL()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
510 QMessageLogger(__FILE__, 968, __PRETTY_FUNCTION__).warning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface;-
511 return
never executed: return false;
false;
never executed: return false;
0
512 }-
513-
514 QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this);-
515-
516 if (d->platformGLContext->makeCurrent(surface->surfaceHandle())
d->platformGLC...rfaceHandle())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
517 d->surface = surface;-
518-
519 d->shareGroup->d_func()->deletePendingResources(this);-
520-
521-
522 QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);-
523-
524-
525 return
never executed: return true;
true;
never executed: return true;
0
526 }-
527-
528 QOpenGLContextPrivate::setCurrentContext(previous);-
529-
530 return
never executed: return false;
false;
never executed: return false;
0
531}-
532void QOpenGLContext::doneCurrent()-
533{-
534 QOpenGLContextPrivate * const d = d_func();-
535 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
536 return;
never executed: return;
0
537-
538 if (QOpenGLContext::currentContext() == this
QOpenGLContext...text() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
539 d->shareGroup->d_func()->deletePendingResources(this);
never executed: d->shareGroup->d_func()->deletePendingResources(this);
0
540-
541 d->platformGLContext->doneCurrent();-
542 QOpenGLContextPrivate::setCurrentContext(0);-
543-
544 d->surface = 0;-
545}
never executed: end of block
0
546-
547-
548-
549-
550-
551-
552QSurface *QOpenGLContext::surface() const-
553{-
554 const QOpenGLContextPrivate * const d = d_func();-
555 return
never executed: return d->surface;
d->surface;
never executed: return d->surface;
0
556}-
557void QOpenGLContext::swapBuffers(QSurface *surface)-
558{-
559 QOpenGLContextPrivate * const d = d_func();-
560 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
561 return;
never executed: return;
0
562-
563 if (!surface
!surfaceDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
564 QMessageLogger(__FILE__, 1038, __PRETTY_FUNCTION__).warning("QOpenGLContext::swapBuffers() called with null argument");-
565 return;
never executed: return;
0
566 }-
567-
568 if (!surface->supportsOpenGL()
!surface->supportsOpenGL()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
569 QMessageLogger(__FILE__, 1043, __PRETTY_FUNCTION__).warning("QOpenGLContext::swapBuffers() called with non-opengl surface");-
570 return;
never executed: return;
0
571 }-
572-
573 if (surface->surfaceClass() == QSurface::Window
surface->surfa...urface::WindowDescription
TRUEnever evaluated
FALSEnever evaluated
0
574 && !qt_window_private(static_cast<QWindow *>(surface))->receivedExpose
!qt_window_pri...receivedExposeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
575 {-
576 QMessageLogger(__FILE__, 1050, __PRETTY_FUNCTION__).warning("QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined");-
577 }
never executed: end of block
0
578-
579 QPlatformSurface *surfaceHandle = surface->surfaceHandle();-
580 if (!surfaceHandle
!surfaceHandleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
581 return;
never executed: return;
0
582-
583-
584 if (!QOpenGLContextPrivate::toggleMakeCurrentTracker(this, false)
!QOpenGLContex...r(this, false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
585 QMessageLogger(__FILE__, 1059, __PRETTY_FUNCTION__).warning("QOpenGLContext::swapBuffers() called without corresponding makeCurrent()");
never executed: QMessageLogger(__FILE__, 1059, __PRETTY_FUNCTION__).warning("QOpenGLContext::swapBuffers() called without corresponding makeCurrent()");
0
586-
587 if (surface->format().swapBehavior() == QSurfaceFormat::SingleBuffer
surface->forma...::SingleBufferDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
588 functions()->glFlush();
never executed: functions()->glFlush();
0
589 d->platformGLContext->swapBuffers(surfaceHandle);-
590}
never executed: end of block
0
591-
592-
593-
594-
595-
596-
597QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) const-
598{-
599 return
never executed: return getProcAddress(procName.constData());
getProcAddress(procName.constData());
never executed: return getProcAddress(procName.constData());
0
600}-
601-
602-
603-
604-
605-
606QFunctionPointer QOpenGLContext::getProcAddress(const char *procName) const-
607{-
608 const QOpenGLContextPrivate * const d = d_func();-
609 if (!d->platformGLContext
!d->platformGLContextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
610 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
611 return
never executed: return d->platformGLContext->getProcAddress(procName);
d->platformGLContext->getProcAddress(procName);
never executed: return d->platformGLContext->getProcAddress(procName);
0
612}-
613QSurfaceFormat QOpenGLContext::format() const-
614{-
615 const QOpenGLContextPrivate * const d = d_func();-
616 if (!d->platformGLContext
!d->platformGLContextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
617 return
never executed: return d->requestedFormat;
d->requestedFormat;
never executed: return d->requestedFormat;
0
618 return
never executed: return d->platformGLContext->format();
d->platformGLContext->format();
never executed: return d->platformGLContext->format();
0
619}-
620-
621-
622-
623-
624QOpenGLContextGroup *QOpenGLContext::shareGroup() const-
625{-
626 const QOpenGLContextPrivate * const d = d_func();-
627 return
never executed: return d->shareGroup;
d->shareGroup;
never executed: return d->shareGroup;
0
628}-
629-
630-
631-
632-
633-
634-
635-
636QOpenGLContext *QOpenGLContext::shareContext() const-
637{-
638 const QOpenGLContextPrivate * const d = d_func();-
639 return
never executed: return d->shareContext;
d->shareContext;
never executed: return d->shareContext;
0
640}-
641-
642-
643-
644-
645QScreen *QOpenGLContext::screen() const-
646{-
647 const QOpenGLContextPrivate * const d = d_func();-
648 return
never executed: return d->screen;
d->screen;
never executed: return d->screen;
0
649}-
650-
651-
652-
653-
654-
655-
656-
657void *QOpenGLContext::qGLContextHandle() const-
658{-
659 const QOpenGLContextPrivate * const d = d_func();-
660 return
never executed: return d->qGLContextHandle;
d->qGLContextHandle;
never executed: return d->qGLContextHandle;
0
661}-
662-
663-
664-
665-
666-
667-
668-
669void QOpenGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *))-
670{-
671 QOpenGLContextPrivate * const d = d_func();-
672 d->qGLContextHandle = handle;-
673 d->qGLContextDeleteFunction = qGLContextDeleteFunction;-
674}
never executed: end of block
0
675-
676-
677-
678-
679void QOpenGLContext::deleteQGLContext()-
680{-
681 QOpenGLContextPrivate * const d = d_func();-
682 if (d->qGLContextDeleteFunction
d->qGLContextDeleteFunctionDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->qGLContextHandle
d->qGLContextHandleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
683 d->qGLContextDeleteFunction(d->qGLContextHandle);-
684 d->qGLContextDeleteFunction = 0;-
685 d->qGLContextHandle = 0;-
686 }
never executed: end of block
0
687}
never executed: end of block
0
688void *QOpenGLContext::openGLModuleHandle()-
689{-
690-
691-
692-
693-
694-
695 return
never executed: return 0;
0;
never executed: return 0;
0
696-
697}-
698QOpenGLContext::OpenGLModuleType QOpenGLContext::openGLModuleType()-
699{-
700-
701-
702-
703-
704-
705-
706 return
never executed: return LibGL;
LibGL;
never executed: return LibGL;
0
707-
708}-
709bool QOpenGLContext::isOpenGLES() const-
710{-
711 return
never executed: return format().renderableType() == QSurfaceFormat::OpenGLES;
format().renderableType() == QSurfaceFormat::OpenGLES;
never executed: return format().renderableType() == QSurfaceFormat::OpenGLES;
0
712}-
713bool QOpenGLContext::supportsThreadedOpenGL()-
714{-
715 ((!((static_cast<QGuiApplication *>(QCoreApplication::instance())))) ? qt_assert("qGuiApp",__FILE__,1273) : qt_noop());-
716 return
never executed: return QGuiApplicationPrivate::instance()->platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL);
QGuiApplicationPrivate::instance()->platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL);
never executed: return QGuiApplicationPrivate::instance()->platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL);
0
717}-
718QOpenGLContext *QOpenGLContext::globalShareContext()-
719{-
720 ((!((static_cast<QGuiApplication *>(QCoreApplication::instance())))) ? qt_assert("qGuiApp",__FILE__,1298) : qt_noop());-
721 return
never executed: return qt_gl_global_share_context();
qt_gl_global_share_context();
never executed: return qt_gl_global_share_context();
0
722}-
723-
724-
725-
726-
727QOpenGLVersionFunctionsStorage *QOpenGLContext::functionsBackendStorage() const-
728{-
729 const QOpenGLContextPrivate * const d = d_func();-
730 return
never executed: return &d->versionFunctionsStorage;
&d->versionFunctionsStorage;
never executed: return &d->versionFunctionsStorage;
0
731}-
732-
733-
734-
735-
736void QOpenGLContext::insertExternalFunctions(QAbstractOpenGLFunctions *f)-
737{-
738 QOpenGLContextPrivate * const d = d_func();-
739 d->externalVersionFunctions.insert(f);-
740}
never executed: end of block
0
741-
742-
743-
744-
745void QOpenGLContext::removeExternalFunctions(QAbstractOpenGLFunctions *f)-
746{-
747 QOpenGLContextPrivate * const d = d_func();-
748 d->externalVersionFunctions.remove(f);-
749}
never executed: end of block
0
750-
751-
752-
753-
754QOpenGLTextureHelper* QOpenGLContext::textureFunctions() const-
755{-
756 const QOpenGLContextPrivate * const d = d_func();-
757 return
never executed: return d->textureFunctions;
d->textureFunctions;
never executed: return d->textureFunctions;
0
758}-
759-
760-
761-
762-
763void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs)-
764{-
765 QOpenGLContextPrivate * const d = d_func();-
766 d->textureFunctions = textureFuncs;-
767}
never executed: end of block
0
768QOpenGLContextGroup::QOpenGLContextGroup()-
769 : QObject(*new QOpenGLContextGroupPrivate())-
770{-
771}
never executed: end of block
0
772-
773-
774-
775-
776QOpenGLContextGroup::~QOpenGLContextGroup()-
777{-
778 QOpenGLContextGroupPrivate * const d = d_func();-
779 d->cleanup();-
780}
never executed: end of block
0
781-
782-
783-
784-
785QList<QOpenGLContext *> QOpenGLContextGroup::shares() const-
786{-
787 const QOpenGLContextGroupPrivate * const d = d_func();-
788 return
never executed: return d->m_shares;
d->m_shares;
never executed: return d->m_shares;
0
789}-
790-
791-
792-
793-
794-
795-
796QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup()-
797{-
798 QOpenGLContext *current = QOpenGLContext::currentContext();-
799 return
never executed: return current ? current->shareGroup() : 0;
current ? current->shareGroup() : 0;
never executed: return current ? current->shareGroup() : 0;
0
800}-
801-
802void QOpenGLContextGroupPrivate::addContext(QOpenGLContext *ctx)-
803{-
804 QMutexLocker locker(&m_mutex);-
805 m_refs.ref();-
806 m_shares << ctx;-
807}
never executed: end of block
0
808-
809void QOpenGLContextGroupPrivate::removeContext(QOpenGLContext *ctx)-
810{-
811 QOpenGLContextGroup * const q = q_func();-
812-
813 bool deleteObject = false;-
814-
815 {-
816 QMutexLocker locker(&m_mutex);-
817 m_shares.removeOne(ctx);-
818-
819 if (ctx == m_context
ctx == m_contextDescription
TRUEnever evaluated
FALSEnever evaluated
&& !m_shares.isEmpty()
!m_shares.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
820 m_context = m_shares.constFirst();
never executed: m_context = m_shares.constFirst();
0
821-
822 if (!m_refs.deref()
!m_refs.deref()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
823 cleanup();-
824 deleteObject = true;-
825 }
never executed: end of block
0
826 }-
827-
828 if (deleteObject
deleteObjectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
829 if (q->thread() == QThread::currentThread()
q->thread() ==...urrentThread()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
830 delete q;
never executed: delete q;
0
831 else-
832 q->deleteLater();
never executed: q->deleteLater();
0
833 }-
834}
never executed: end of block
0
835-
836void QOpenGLContextGroupPrivate::cleanup()-
837{-
838 QOpenGLContextGroup * const q = q_func();-
839 {-
840 QHash<QOpenGLMultiGroupSharedResource *, QOpenGLSharedResource *>::const_iterator it, end;-
841 end = m_resources.constEnd();-
842 for (it = m_resources.constBegin(); it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
843 it.key()->cleanup(q, it.value());
never executed: it.key()->cleanup(q, it.value());
0
844 m_resources.clear();-
845 }-
846-
847 QList<QOpenGLSharedResource *>::iterator it = m_sharedResources.begin();-
848 QList<QOpenGLSharedResource *>::iterator end = m_sharedResources.end();-
849-
850 while (it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
851 (*it)->invalidateResource();-
852 (*it)->m_group = 0;-
853 ++it;-
854 }
never executed: end of block
0
855-
856 m_sharedResources.clear();-
857-
858 qDeleteAll(m_pendingDeletion.begin(), m_pendingDeletion.end());-
859 m_pendingDeletion.clear();-
860}
never executed: end of block
0
861-
862void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx)-
863{-
864 QMutexLocker locker(&m_mutex);-
865-
866 const QList<QOpenGLSharedResource *> pending = m_pendingDeletion;-
867 m_pendingDeletion.clear();-
868-
869 QList<QOpenGLSharedResource *>::const_iterator it = pending.begin();-
870 QList<QOpenGLSharedResource *>::const_iterator end = pending.end();-
871 while (it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
872 (*it)->freeResource(ctx);-
873 delete *it;-
874 ++it;-
875 }
never executed: end of block
0
876}
never executed: end of block
0
877QOpenGLSharedResource::QOpenGLSharedResource(QOpenGLContextGroup *group)-
878 : m_group(group)-
879{-
880 QMutexLocker locker(&m_group->d_func()->m_mutex);-
881 m_group->d_func()->m_sharedResources << this;-
882}
never executed: end of block
0
883-
884QOpenGLSharedResource::~QOpenGLSharedResource()-
885{-
886}-
887-
888-
889void QOpenGLSharedResource::free()-
890{-
891 if (!m_group
!m_groupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
892 delete this;-
893 return;
never executed: return;
0
894 }-
895-
896 QMutexLocker locker(&m_group->d_func()->m_mutex);-
897 m_group->d_func()->m_sharedResources.removeOne(this);-
898 m_group->d_func()->m_pendingDeletion << this;-
899-
900-
901 QOpenGLContext *current = QOpenGLContext::currentContext();-
902 if (current
currentDescription
TRUEnever evaluated
FALSEnever evaluated
&& current->shareGroup() == m_group
current->share...p() == m_groupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
903 m_group->d_func()->deletePendingResources(current);-
904 }
never executed: end of block
0
905}
never executed: end of block
0
906void QOpenGLSharedResourceGuard::freeResource(QOpenGLContext *context)-
907{-
908 if (m_id
m_idDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
909 QOpenGLFunctions functions(context);-
910 m_func(&functions, m_id);-
911 m_id = 0;-
912 }
never executed: end of block
0
913}
never executed: end of block
0
914QOpenGLMultiGroupSharedResource::QOpenGLMultiGroupSharedResource()-
915 : active(0),-
916 m_mutex(QMutex::Recursive)-
917{-
918-
919-
920-
921}
never executed: end of block
0
922-
923QOpenGLMultiGroupSharedResource::~QOpenGLMultiGroupSharedResource()-
924{-
925-
926-
927-
928 for (int i = 0; i < m_groups.size()
i < m_groups.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
929 if (!m_groups.at(i)->shares().isEmpty()
!m_groups.at(i...es().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
930 QOpenGLContext *context = m_groups.at(i)->shares().constFirst();-
931 QOpenGLSharedResource *resource = value(context);-
932 if (resource
resourceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
933 resource->free();
never executed: resource->free();
0
934 }
never executed: end of block
0
935 m_groups.at(i)->d_func()->m_resources.remove(this);-
936 active.deref();-
937 }
never executed: end of block
0
938-
939 if (active.load() != 0
active.load() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
940 QMessageLogger(__FILE__, 1586, __PRETTY_FUNCTION__).warning("QtGui: Resources are still available at program shutdown.\n"-
941 " This is possibly caused by a leaked QOpenGLWidget, \n"-
942 " QOpenGLFramebufferObject or QOpenGLPixelBuffer.");-
943 }
never executed: end of block
0
944-
945}
never executed: end of block
0
946-
947void QOpenGLMultiGroupSharedResource::insert(QOpenGLContext *context, QOpenGLSharedResource *value)-
948{-
949-
950-
951-
952 QOpenGLContextGroup *group = context->shareGroup();-
953 ((!(!group->d_func()->m_resources.contains(this))) ? qt_assert("!group->d_func()->m_resources.contains(this)",__FILE__,1599) : qt_noop());-
954 group->d_func()->m_resources.insert(this, value);-
955 m_groups.append(group);-
956 active.ref();-
957}
never executed: end of block
0
958-
959QOpenGLSharedResource *QOpenGLMultiGroupSharedResource::value(QOpenGLContext *context)-
960{-
961 QOpenGLContextGroup *group = context->shareGroup();-
962 return
never executed: return group->d_func()->m_resources.value(this, 0);
group->d_func()->m_resources.value(this, 0);
never executed: return group->d_func()->m_resources.value(this, 0);
0
963}-
964-
965QList<QOpenGLSharedResource *> QOpenGLMultiGroupSharedResource::resources() const-
966{-
967 QList<QOpenGLSharedResource *> result;-
968 for (QList<QOpenGLContextGroup *>::const_iterator it = m_groups.constBegin(); it != m_groups.constEnd()
it != m_groups.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
969 QOpenGLSharedResource *resource = (*it)->d_func()->m_resources.value(const_cast<QOpenGLMultiGroupSharedResource *>(this), 0);-
970 if (resource
resourceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
971 result << resource;
never executed: result << resource;
0
972 }
never executed: end of block
0
973 return
never executed: return result;
result;
never executed: return result;
0
974}-
975-
976void QOpenGLMultiGroupSharedResource::cleanup(QOpenGLContextGroup *group, QOpenGLSharedResource *value)-
977{-
978-
979-
980-
981 value->invalidateResource();-
982 value->free();-
983 active.deref();-
984-
985 ((!(m_groups.contains(group))) ? qt_assert("m_groups.contains(group)",__FILE__,1631) : qt_noop());-
986 m_groups.removeOne(group);-
987}
never executed: end of block
0
988-
989-
990-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9