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