qopenglframebufferobject.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopenglframebufferobject.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5void QOpenGLFramebufferObjectFormat::detach()-
6{-
7 if (d->ref.load() != 1
d->ref.load() != 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
8 QOpenGLFramebufferObjectFormatPrivate *newd-
9 = new QOpenGLFramebufferObjectFormatPrivate(d);-
10 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
11 delete d;
never executed: delete d;
0
12 d = newd;-
13 }
never executed: end of block
0
14}
never executed: end of block
0
15QOpenGLFramebufferObjectFormat::QOpenGLFramebufferObjectFormat()-
16{-
17 d = new QOpenGLFramebufferObjectFormatPrivate;-
18}
never executed: end of block
0
19-
20-
21-
22-
23-
24QOpenGLFramebufferObjectFormat::QOpenGLFramebufferObjectFormat(const QOpenGLFramebufferObjectFormat &other)-
25{-
26 d = other.d;-
27 d->ref.ref();-
28}
never executed: end of block
0
29-
30-
31-
32-
33-
34QOpenGLFramebufferObjectFormat &QOpenGLFramebufferObjectFormat::operator=(const QOpenGLFramebufferObjectFormat &other)-
35{-
36 if (d != other.d
d != other.dDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
37 other.d->ref.ref();-
38 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
39 delete d;
never executed: delete d;
0
40 d = other.d;-
41 }
never executed: end of block
0
42 return
never executed: return *this;
*this;
never executed: return *this;
0
43}-
44-
45-
46-
47-
48QOpenGLFramebufferObjectFormat::~QOpenGLFramebufferObjectFormat()-
49{-
50 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
51 delete d;
never executed: delete d;
0
52}
never executed: end of block
0
53void QOpenGLFramebufferObjectFormat::setSamples(int samples)-
54{-
55 detach();-
56 d->samples = samples;-
57}
never executed: end of block
0
58int QOpenGLFramebufferObjectFormat::samples() const-
59{-
60 return
never executed: return d->samples;
d->samples;
never executed: return d->samples;
0
61}-
62void QOpenGLFramebufferObjectFormat::setMipmap(bool enabled)-
63{-
64 detach();-
65 d->mipmap = enabled;-
66}
never executed: end of block
0
67-
68-
69-
70-
71-
72-
73bool QOpenGLFramebufferObjectFormat::mipmap() const-
74{-
75 return
never executed: return d->mipmap;
d->mipmap;
never executed: return d->mipmap;
0
76}-
77-
78-
79-
80-
81-
82-
83void QOpenGLFramebufferObjectFormat::setAttachment(QOpenGLFramebufferObject::Attachment attachment)-
84{-
85 detach();-
86 d->attachment = attachment;-
87}
never executed: end of block
0
88-
89-
90-
91-
92-
93-
94-
95QOpenGLFramebufferObject::Attachment QOpenGLFramebufferObjectFormat::attachment() const-
96{-
97 return
never executed: return d->attachment;
d->attachment;
never executed: return d->attachment;
0
98}-
99-
100-
101-
102-
103-
104-
105-
106void QOpenGLFramebufferObjectFormat::setTextureTarget(GLenum target)-
107{-
108 detach();-
109 d->target = target;-
110}
never executed: end of block
0
111GLenum QOpenGLFramebufferObjectFormat::textureTarget() const-
112{-
113 return
never executed: return d->target;
d->target;
never executed: return d->target;
0
114}-
115void QOpenGLFramebufferObjectFormat::setInternalTextureFormat(GLenum internalTextureFormat)-
116{-
117 detach();-
118 d->internal_format = internalTextureFormat;-
119}
never executed: end of block
0
120GLenum QOpenGLFramebufferObjectFormat::internalTextureFormat() const-
121{-
122 return
never executed: return d->internal_format;
d->internal_format;
never executed: return d->internal_format;
0
123}-
124-
125-
126-
127-
128-
129bool QOpenGLFramebufferObjectFormat::operator==(const QOpenGLFramebufferObjectFormat& other) const-
130{-
131 if (d == other.d
d == other.dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
132 return
never executed: return true;
true;
never executed: return true;
0
133 else-
134 return
never executed: return d->equals(other.d);
d->equals(other.d);
never executed: return d->equals(other.d);
0
135}-
136-
137-
138-
139-
140-
141bool QOpenGLFramebufferObjectFormat::operator!=(const QOpenGLFramebufferObjectFormat& other) const-
142{-
143 return
never executed: return !(*this == other);
!(*this == other);
never executed: return !(*this == other);
0
144}-
145-
146bool QOpenGLFramebufferObjectPrivate::checkFramebufferStatus(QOpenGLContext *ctx) const-
147{-
148 if (!ctx
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
149 return
never executed: return false;
false;
never executed: return false;
0
150 GLenum status = ctx->functions()->glCheckFramebufferStatus(0x8D40);-
151 switch(status) {-
152 case
never executed: case 0:
0:
never executed: case 0:
0
153 case
never executed: case 0x8CD5:
0x8CD5:
never executed: case 0x8CD5:
0
154 return
never executed: return true;
true;
never executed: return true;
0
155 case
never executed: case 0x8CDD:
0x8CDD:
never executed: case 0x8CDD:
0
156 QMessageLogger(__FILE__, 383, __PRETTY_FUNCTION__).debug("QOpenGLFramebufferObject: Unsupported framebuffer format.");-
157 break;
never executed: break;
0
158 case
never executed: case 0x8CD6:
0x8CD6:
never executed: case 0x8CD6:
0
159 QMessageLogger(__FILE__, 386, __PRETTY_FUNCTION__).debug("QOpenGLFramebufferObject: Framebuffer incomplete attachment.");-
160 break;
never executed: break;
0
161 case
never executed: case 0x8CD7:
0x8CD7:
never executed: case 0x8CD7:
0
162 QMessageLogger(__FILE__, 389, __PRETTY_FUNCTION__).debug("QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.");-
163 break;
never executed: break;
0
164 case
never executed: case 0x8CDB:
0x8CDB:
never executed: case 0x8CDB:
0
165 QMessageLogger(__FILE__, 408, __PRETTY_FUNCTION__).debug("QOpenGLFramebufferObject: Framebuffer incomplete, missing draw buffer.");-
166 break;
never executed: break;
0
167-
168-
169 case
never executed: case 0x8CDC:
0x8CDC:
never executed: case 0x8CDC:
0
170 QMessageLogger(__FILE__, 413, __PRETTY_FUNCTION__).debug("QOpenGLFramebufferObject: Framebuffer incomplete, missing read buffer.");-
171 break;
never executed: break;
0
172-
173-
174 case
never executed: case 0x8D56:
0x8D56:
never executed: case 0x8D56:
0
175 QMessageLogger(__FILE__, 418, __PRETTY_FUNCTION__).debug("QOpenGLFramebufferObject: Framebuffer incomplete, attachments must have same number of samples per pixel.");-
176 break;
never executed: break;
0
177-
178 default
never executed: default:
:
never executed: default:
0
179 QMessageLogger(__FILE__, 422, __PRETTY_FUNCTION__).debug() <<"QOpenGLFramebufferObject: An undefined error has occurred: "<< status;-
180 break;
never executed: break;
0
181 }-
182 return
never executed: return false;
false;
never executed: return false;
0
183}-
184-
185namespace-
186{-
187 void freeFramebufferFunc(QOpenGLFunctions *funcs, GLuint id)-
188 {-
189 funcs->glDeleteFramebuffers(1, &id);-
190 }
never executed: end of block
0
191-
192 void freeRenderbufferFunc(QOpenGLFunctions *funcs, GLuint id)-
193 {-
194 funcs->glDeleteRenderbuffers(1, &id);-
195 }
never executed: end of block
0
196-
197 void freeTextureFunc(QOpenGLFunctions *funcs, GLuint id)-
198 {-
199 funcs->glDeleteTextures(1, &id);-
200 }
never executed: end of block
0
201}-
202-
203void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *, const QSize &size,-
204 QOpenGLFramebufferObject::Attachment attachment,-
205 GLenum texture_target, GLenum internal_format,-
206 GLint samples, bool mipmap)-
207{-
208 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
209-
210 funcs.initializeOpenGLFunctions();-
211-
212 if (!funcs.hasOpenGLFeature(QOpenGLFunctions::Framebuffers)
!funcs.hasOpen...:Framebuffers)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
213 return;
never executed: return;
0
214-
215-
216 if (!funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
!funcs.hasOpen...erMultisample)Description
TRUEnever evaluated
FALSEnever evaluated
0
217 || !funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)
!funcs.hasOpen...amebufferBlit)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
218 samples = 0;-
219 }
never executed: end of block
else if (!ctx->isOpenGLES()
!ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
|| ctx->format().majorVersion() >= 3
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
220 GLint maxSamples;-
221 funcs.glGetIntegerv(0x8D57, &maxSamples);-
222 samples = qBound(0, int(samples), int(maxSamples));-
223 }
never executed: end of block
0
224-
225 colorAttachments.append(ColorAttachment(size, internal_format));-
226-
227 dsSize = size;-
228-
229 samples = qMax(0, samples);-
230 requestedSamples = samples;-
231-
232 target = texture_target;-
233-
234 { while (QOpenGLContext::currentContext()->functions()->glGetError() != 0
QOpenGLContext...etError() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {}
never executed: end of block
};
0
235 GLuint fbo = 0;-
236-
237 funcs.glGenFramebuffers(1, &fbo);-
238 funcs.glBindFramebuffer(0x8D40, fbo);-
239-
240 QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid = true;-
241-
242 { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
err != 0Description
TRUEnever evaluated
FALSEnever evaluated
) { QMessageLogger(__FILE__, 485, __PRETTY_FUNCTION__).debug("[%s line %d] OpenGL Error: %d", __FILE__, 485, (int)err); }
never executed: end of block
};
0
243-
244 format.setTextureTarget(target);-
245 format.setInternalTextureFormat(internal_format);-
246 format.setMipmap(mipmap);-
247-
248 if (samples == 0
samples == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
249 initTexture(0);
never executed: initTexture(0);
0
250 else-
251 initColorBuffer(0, &samples);
never executed: initColorBuffer(0, &samples);
0
252-
253 format.setSamples(int(samples));-
254-
255 initDepthStencilAttachments(ctx, attachment);-
256-
257 if (valid
validDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
258 fbo_guard = new QOpenGLSharedResourceGuard(ctx, fbo, freeFramebufferFunc);
never executed: fbo_guard = new QOpenGLSharedResourceGuard(ctx, fbo, freeFramebufferFunc);
0
259 else-
260 funcs.glDeleteFramebuffers(1, &fbo);
never executed: funcs.glDeleteFramebuffers(1, &fbo);
0
261-
262 { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
err != 0Description
TRUEnever evaluated
FALSEnever evaluated
) { QMessageLogger(__FILE__, 505, __PRETTY_FUNCTION__).debug("[%s line %d] OpenGL Error: %d", __FILE__, 505, (int)err); }
never executed: end of block
};
0
263}
never executed: end of block
0
264-
265void QOpenGLFramebufferObjectPrivate::initTexture(int idx)-
266{-
267 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
268 GLuint texture = 0;-
269-
270 funcs.glGenTextures(1, &texture);-
271 funcs.glBindTexture(target, texture);-
272-
273 funcs.glTexParameteri(target, 0x2801, 0x2600);-
274 funcs.glTexParameteri(target, 0x2800, 0x2600);-
275 funcs.glTexParameteri(target, 0x2802, 0x812F);-
276 funcs.glTexParameteri(target, 0x2803, 0x812F);-
277-
278 ColorAttachment &color(colorAttachments[idx]);-
279-
280 GLuint pixelType = 0x1401;-
281 if (color.internalFormat == 0x8059
color.internalFormat == 0x8059Description
TRUEnever evaluated
FALSEnever evaluated
|| color.internalFormat == 0x8052
color.internalFormat == 0x8052Description
TRUEnever evaluated
FALSEnever evaluated
)
0
282 pixelType = 0x8368;
never executed: pixelType = 0x8368;
0
283-
284 funcs.glTexImage2D(target, 0, color.internalFormat, color.size.width(), color.size.height(), 0,-
285 0x1908, pixelType, __null);-
286 if (format.mipmap()
format.mipmap()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
287 int width = color.size.width();-
288 int height = color.size.height();-
289 int level = 0;-
290 while (width > 1
width > 1Description
TRUEnever evaluated
FALSEnever evaluated
|| height > 1
height > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
291 width = qMax(1, width >> 1);-
292 height = qMax(1, height >> 1);-
293 ++level;-
294 funcs.glTexImage2D(target, level, color.internalFormat, width, height, 0,-
295 0x1908, pixelType, __null);-
296 }
never executed: end of block
0
297 }
never executed: end of block
0
298 funcs.glFramebufferTexture2D(0x8D40, 0x8CE0 + idx,-
299 target, texture, 0);-
300-
301 { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
err != 0Description
TRUEnever evaluated
FALSEnever evaluated
) { QMessageLogger(__FILE__, 544, __PRETTY_FUNCTION__).debug("[%s line %d] OpenGL Error: %d", __FILE__, 544, (int)err); }
never executed: end of block
};
0
302 funcs.glBindTexture(target, 0);-
303 valid = checkFramebufferStatus(ctx);-
304 if (valid
validDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
305 color.guard = new QOpenGLSharedResourceGuard(ctx, texture, freeTextureFunc);-
306 }
never executed: end of block
else {
0
307 funcs.glDeleteTextures(1, &texture);-
308 }
never executed: end of block
0
309}-
310-
311void QOpenGLFramebufferObjectPrivate::initColorBuffer(int idx, GLint *samples)-
312{-
313 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
314 GLuint color_buffer = 0;-
315-
316 ColorAttachment &color(colorAttachments[idx]);-
317-
318 GLenum storageFormat = color.internalFormat;-
319-
320 if (ctx->isOpenGLES()
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
&& color.internalFormat == 0x1908
color.internalFormat == 0x1908Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
321 if (funcs.hasOpenGLExtension(QOpenGLExtensions::Sized8Formats)
funcs.hasOpenG...Sized8Formats)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
322 storageFormat = 0x8058;
never executed: storageFormat = 0x8058;
0
323 else-
324 storageFormat = 0x8056;
never executed: storageFormat = 0x8056;
0
325 }-
326-
327 funcs.glGenRenderbuffers(1, &color_buffer);-
328 funcs.glBindRenderbuffer(0x8D41, color_buffer);-
329 funcs.glRenderbufferStorageMultisample(0x8D41, *samples, storageFormat, color.size.width(), color.size.height());-
330 funcs.glFramebufferRenderbuffer(0x8D40, 0x8CE0 + idx,-
331 0x8D41, color_buffer);-
332-
333 { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
err != 0Description
TRUEnever evaluated
FALSEnever evaluated
) { QMessageLogger(__FILE__, 576, __PRETTY_FUNCTION__).debug("[%s line %d] OpenGL Error: %d", __FILE__, 576, (int)err); }
never executed: end of block
};
0
334 valid = checkFramebufferStatus(ctx);-
335 if (valid
validDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
336-
337-
338-
339 funcs.glGetRenderbufferParameteriv(0x8D41, 0x8CAB, samples);-
340 color.guard = new QOpenGLSharedResourceGuard(ctx, color_buffer, freeRenderbufferFunc);-
341 }
never executed: end of block
else {
0
342 funcs.glDeleteRenderbuffers(1, &color_buffer);-
343 }
never executed: end of block
0
344}-
345-
346void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext *ctx,-
347 QOpenGLFramebufferObject::Attachment attachment)-
348{-
349-
350-
351-
352 const int samples = requestedSamples;-
353-
354-
355 if (depth_buffer_guard
depth_buffer_guardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
356 funcs.glFramebufferRenderbuffer(0x8D40, 0x8D00, 0x8D41, 0);-
357 depth_buffer_guard->free();-
358 }
never executed: end of block
0
359 if (stencil_buffer_guard
stencil_buffer_guardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
360 funcs.glFramebufferRenderbuffer(0x8D40, 0x8D20, 0x8D41, 0);-
361 if (stencil_buffer_guard != depth_buffer_guard
stencil_buffer...h_buffer_guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
362 stencil_buffer_guard->free();
never executed: stencil_buffer_guard->free();
0
363 }
never executed: end of block
0
364-
365 depth_buffer_guard = 0;-
366 stencil_buffer_guard = 0;-
367-
368 GLuint depth_buffer = 0;-
369 GLuint stencil_buffer = 0;-
370-
371-
372-
373-
374-
375 if (attachment == QOpenGLFramebufferObject::CombinedDepthStencil
attachment == ...edDepthStencilDescription
TRUEnever evaluated
FALSEnever evaluated
0
376 && funcs.hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil)
funcs.hasOpenG...dDepthStencil)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
377 {-
378-
379 funcs.glGenRenderbuffers(1, &depth_buffer);-
380 funcs.glBindRenderbuffer(0x8D41, depth_buffer);-
381 ((!(funcs.glIsRenderbuffer(depth_buffer))) ? qt_assert("funcs.glIsRenderbuffer(depth_buffer)",__FILE__,624) : qt_noop());-
382 if (samples != 0
samples != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
funcs.hasOpenG...erMultisample)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
383 funcs.glRenderbufferStorageMultisample(0x8D41, samples,
never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x88F0, dsSize.width(), dsSize.height());
0
384 0x88F0, dsSize.width(), dsSize.height());
never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x88F0, dsSize.width(), dsSize.height());
0
385 else-
386 funcs.glRenderbufferStorage(0x8D41,
never executed: funcs.glRenderbufferStorage(0x8D41, 0x88F0, dsSize.width(), dsSize.height());
0
387 0x88F0, dsSize.width(), dsSize.height());
never executed: funcs.glRenderbufferStorage(0x8D41, 0x88F0, dsSize.width(), dsSize.height());
0
388-
389 stencil_buffer = depth_buffer;-
390 funcs.glFramebufferRenderbuffer(0x8D40, 0x8D00,-
391 0x8D41, depth_buffer);-
392 funcs.glFramebufferRenderbuffer(0x8D40, 0x8D20,-
393 0x8D41, stencil_buffer);-
394-
395 valid = checkFramebufferStatus(ctx);-
396 if (!valid
!validDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
397 funcs.glDeleteRenderbuffers(1, &depth_buffer);-
398 stencil_buffer = depth_buffer = 0;-
399 }
never executed: end of block
0
400 }
never executed: end of block
0
401-
402 if (depth_buffer == 0
depth_buffer == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& (attachment == QOpenGLFramebufferObject::CombinedDepthStencil
attachment == ...edDepthStencilDescription
TRUEnever evaluated
FALSEnever evaluated
0
403 || (
(attachment ==...Object::Depth)Description
TRUEnever evaluated
FALSEnever evaluated
attachment == QOpenGLFramebufferObject::Depth)
(attachment ==...Object::Depth)Description
TRUEnever evaluated
FALSEnever evaluated
))
0
404 {-
405 funcs.glGenRenderbuffers(1, &depth_buffer);-
406 funcs.glBindRenderbuffer(0x8D41, depth_buffer);-
407 ((!(funcs.glIsRenderbuffer(depth_buffer))) ? qt_assert("funcs.glIsRenderbuffer(depth_buffer)",__FILE__,650) : qt_noop());-
408 if (samples != 0
samples != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
funcs.hasOpenG...erMultisample)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
409 if (ctx->isOpenGLES()
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
410 if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)
funcs.hasOpenG...ions::Depth24)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
411 funcs.glRenderbufferStorageMultisample(0x8D41, samples,
never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A6, dsSize.width(), dsSize.height());
0
412 0x81A6, dsSize.width(), dsSize.height());
never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A6, dsSize.width(), dsSize.height());
0
413 else-
414 funcs.glRenderbufferStorageMultisample(0x8D41, samples,
never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A5, dsSize.width(), dsSize.height());
0
415 0x81A5, dsSize.width(), dsSize.height());
never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A5, dsSize.width(), dsSize.height());
0
416 } else {-
417 funcs.glRenderbufferStorageMultisample(0x8D41, samples,-
418 0x1902, dsSize.width(), dsSize.height());-
419 }
never executed: end of block
0
420 } else {-
421 if (ctx->isOpenGLES()
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
422 if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)
funcs.hasOpenG...ions::Depth24)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
423 funcs.glRenderbufferStorage(0x8D41, 0x81A6,-
424 dsSize.width(), dsSize.height());-
425 }
never executed: end of block
else {
0
426 funcs.glRenderbufferStorage(0x8D41, 0x81A5,-
427 dsSize.width(), dsSize.height());-
428 }
never executed: end of block
0
429 } else {-
430 funcs.glRenderbufferStorage(0x8D41, 0x1902, dsSize.width(), dsSize.height());-
431 }
never executed: end of block
0
432 }-
433 funcs.glFramebufferRenderbuffer(0x8D40, 0x8D00,-
434 0x8D41, depth_buffer);-
435 valid = checkFramebufferStatus(ctx);-
436 if (!valid
!validDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
437 funcs.glDeleteRenderbuffers(1, &depth_buffer);-
438 depth_buffer = 0;-
439 }
never executed: end of block
0
440 }
never executed: end of block
0
441-
442 if (stencil_buffer == 0
stencil_buffer == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(attachment ==...dDepthStencil)Description
TRUEnever evaluated
FALSEnever evaluated
attachment == QOpenGLFramebufferObject::CombinedDepthStencil)
(attachment ==...dDepthStencil)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
443 funcs.glGenRenderbuffers(1, &stencil_buffer);-
444 funcs.glBindRenderbuffer(0x8D41, stencil_buffer);-
445 ((!(funcs.glIsRenderbuffer(stencil_buffer))) ? qt_assert("funcs.glIsRenderbuffer(stencil_buffer)",__FILE__,688) : qt_noop());-
446-
447-
448-
449-
450 GLenum storage = ctx->isOpenGLES()
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
? 0x8D48 : 0x1901;
0
451-
452-
453 if (samples != 0
samples != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
funcs.hasOpenG...erMultisample)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
454 funcs.glRenderbufferStorageMultisample(0x8D41, samples, storage, dsSize.width(), dsSize.height());
never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, storage, dsSize.width(), dsSize.height());
0
455 else-
456 funcs.glRenderbufferStorage(0x8D41, storage, dsSize.width(), dsSize.height());
never executed: funcs.glRenderbufferStorage(0x8D41, storage, dsSize.width(), dsSize.height());
0
457-
458 funcs.glFramebufferRenderbuffer(0x8D40, 0x8D20,-
459 0x8D41, stencil_buffer);-
460 valid = checkFramebufferStatus(ctx);-
461 if (!valid
!validDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
462 funcs.glDeleteRenderbuffers(1, &stencil_buffer);-
463 stencil_buffer = 0;-
464 }
never executed: end of block
0
465 }
never executed: end of block
0
466-
467-
468 valid = checkFramebufferStatus(ctx);-
469-
470 if (depth_buffer
depth_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
&& stencil_buffer
stencil_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
471 fbo_attachment = QOpenGLFramebufferObject::CombinedDepthStencil;-
472 }
never executed: end of block
else if (depth_buffer
depth_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
473 fbo_attachment = QOpenGLFramebufferObject::Depth;-
474 }
never executed: end of block
else {
0
475 fbo_attachment = QOpenGLFramebufferObject::NoAttachment;-
476 }
never executed: end of block
0
477-
478 if (valid
validDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
479 if (depth_buffer
depth_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
480 depth_buffer_guard = new QOpenGLSharedResourceGuard(ctx, depth_buffer, freeRenderbufferFunc);
never executed: depth_buffer_guard = new QOpenGLSharedResourceGuard(ctx, depth_buffer, freeRenderbufferFunc);
0
481 if (stencil_buffer
stencil_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
482 if (stencil_buffer == depth_buffer
stencil_buffer == depth_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
483 stencil_buffer_guard = depth_buffer_guard;
never executed: stencil_buffer_guard = depth_buffer_guard;
0
484 else-
485 stencil_buffer_guard = new QOpenGLSharedResourceGuard(ctx, stencil_buffer, freeRenderbufferFunc);
never executed: stencil_buffer_guard = new QOpenGLSharedResourceGuard(ctx, stencil_buffer, freeRenderbufferFunc);
0
486 }-
487 }
never executed: end of block
else {
0
488 if (depth_buffer
depth_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
489 funcs.glDeleteRenderbuffers(1, &depth_buffer);
never executed: funcs.glDeleteRenderbuffers(1, &depth_buffer);
0
490 if (stencil_buffer
stencil_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
&& depth_buffer != stencil_buffer
depth_buffer != stencil_bufferDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
491 funcs.glDeleteRenderbuffers(1, &stencil_buffer);
never executed: funcs.glDeleteRenderbuffers(1, &stencil_buffer);
0
492 }
never executed: end of block
0
493 { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
err != 0Description
TRUEnever evaluated
FALSEnever evaluated
) { QMessageLogger(__FILE__, 736, __PRETTY_FUNCTION__).debug("[%s line %d] OpenGL Error: %d", __FILE__, 736, (int)err); }
never executed: end of block
};
0
494-
495 format.setAttachment(fbo_attachment);-
496}
never executed: end of block
0
497static inline GLenum effectiveInternalFormat(GLenum internalFormat)-
498{-
499 if (!internalFormat
!internalFormatDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
500-
501-
502-
503 internalFormat = QOpenGLContext::currentContext()->isOpenGLES()
QOpenGLContext...->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
? 0x1908 : 0x8058;
never executed: internalFormat = QOpenGLContext::currentContext()->isOpenGLES() ? 0x1908 : 0x8058;
0
504-
505 return
never executed: return internalFormat;
internalFormat;
never executed: return internalFormat;
0
506}-
507QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum target)-
508 : d_ptr(new QOpenGLFramebufferObjectPrivate)-
509{-
510 QOpenGLFramebufferObjectPrivate * const d = d_func();-
511 d->init(this, size, NoAttachment, target, effectiveInternalFormat(0));-
512}
never executed: end of block
0
513QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, GLenum target)-
514 : d_ptr(new QOpenGLFramebufferObjectPrivate)-
515{-
516 QOpenGLFramebufferObjectPrivate * const d = d_func();-
517 d->init(this, QSize(width, height), NoAttachment, target, effectiveInternalFormat(0));-
518}
never executed: end of block
0
519-
520-
521-
522-
523-
524-
525-
526QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, const QOpenGLFramebufferObjectFormat &format)-
527 : d_ptr(new QOpenGLFramebufferObjectPrivate)-
528{-
529 QOpenGLFramebufferObjectPrivate * const d = d_func();-
530 d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(),-
531 format.samples(), format.mipmap());-
532}
never executed: end of block
0
533-
534-
535-
536-
537-
538-
539-
540QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat &format)-
541 : d_ptr(new QOpenGLFramebufferObjectPrivate)-
542{-
543 QOpenGLFramebufferObjectPrivate * const d = d_func();-
544 d->init(this, QSize(width, height), format.attachment(), format.textureTarget(),-
545 format.internalTextureFormat(), format.samples(), format.mipmap());-
546}
never executed: end of block
0
547QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, Attachment attachment,-
548 GLenum target, GLenum internalFormat)-
549 : d_ptr(new QOpenGLFramebufferObjectPrivate)-
550{-
551 QOpenGLFramebufferObjectPrivate * const d = d_func();-
552 d->init(this, QSize(width, height), attachment, target, effectiveInternalFormat(internalFormat));-
553}
never executed: end of block
0
554QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, Attachment attachment,-
555 GLenum target, GLenum internalFormat)-
556 : d_ptr(new QOpenGLFramebufferObjectPrivate)-
557{-
558 QOpenGLFramebufferObjectPrivate * const d = d_func();-
559 d->init(this, size, attachment, target, effectiveInternalFormat(internalFormat));-
560}
never executed: end of block
0
561-
562-
563-
564-
565-
566-
567QOpenGLFramebufferObject::~QOpenGLFramebufferObject()-
568{-
569 QOpenGLFramebufferObjectPrivate * const d = d_func();-
570 if (isBound()
isBound()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
571 release();
never executed: release();
0
572-
573 for (const auto &color : qAsConst(d->colorAttachments)) {-
574 if (color.guard
color.guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
575 color.guard->free();
never executed: color.guard->free();
0
576 }
never executed: end of block
0
577 d->colorAttachments.clear();-
578-
579 if (d->depth_buffer_guard
d->depth_buffer_guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
580 d->depth_buffer_guard->free();
never executed: d->depth_buffer_guard->free();
0
581 if (d->stencil_buffer_guard
d->stencil_buffer_guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->stencil_buffer_guard != d->depth_buffer_guard
d->stencil_buf...h_buffer_guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
582 d->stencil_buffer_guard->free();
never executed: d->stencil_buffer_guard->free();
0
583 if (d->fbo_guard
d->fbo_guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
584 d->fbo_guard->free();
never executed: d->fbo_guard->free();
0
585-
586 QOpenGLContextPrivate *contextPrv = QOpenGLContextPrivate::get(QOpenGLContext::currentContext());-
587 if (contextPrv
contextPrvDescription
TRUEnever evaluated
FALSEnever evaluated
&& contextPrv->qgl_current_fbo == this
contextPrv->qg...nt_fbo == thisDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
588 contextPrv->qgl_current_fbo_invalid = true;-
589 contextPrv->qgl_current_fbo = nullptr;-
590 }
never executed: end of block
0
591}
never executed: end of block
0
592void QOpenGLFramebufferObject::addColorAttachment(const QSize &size, GLenum internalFormat)-
593{-
594 QOpenGLFramebufferObjectPrivate * const d = d_func();-
595-
596 if (!QOpenGLContext::currentContext()->functions()->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)
!QOpenGLContex...RenderTargets)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
597 QMessageLogger(__FILE__, 1000, __PRETTY_FUNCTION__).warning("Multiple render targets not supported, ignoring extra color attachment request");-
598 return;
never executed: return;
0
599 }-
600-
601 QOpenGLFramebufferObjectPrivate::ColorAttachment color(size, effectiveInternalFormat(internalFormat));-
602 d->colorAttachments.append(color);-
603 const int idx = d->colorAttachments.count() - 1;-
604-
605 if (d->requestedSamples == 0
d->requestedSamples == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
606 d->initTexture(idx);-
607 }
never executed: end of block
else {
0
608 GLint samples = d->requestedSamples;-
609 d->initColorBuffer(idx, &samples);-
610 }
never executed: end of block
0
611}-
612void QOpenGLFramebufferObject::addColorAttachment(int width, int height, GLenum internalFormat)-
613{-
614 addColorAttachment(QSize(width, height), internalFormat);-
615}
never executed: end of block
0
616bool QOpenGLFramebufferObject::isValid() const-
617{-
618 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
619 return
never executed: return d->valid && d->fbo_guard && d->fbo_guard->id();
d->valid && d->fbo_guard && d->fbo_guard->id();
never executed: return d->valid && d->fbo_guard && d->fbo_guard->id();
0
620}-
621bool QOpenGLFramebufferObject::bind()-
622{-
623 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
624 return
never executed: return false;
false;
never executed: return false;
0
625 QOpenGLFramebufferObjectPrivate * const d = d_func();-
626 QOpenGLContext *current = QOpenGLContext::currentContext();-
627 if (!current
!currentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
628 return
never executed: return false;
false;
never executed: return false;
0
629-
630 if (current->shareGroup() != d->fbo_guard->group()
current->share...guard->group()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
631 QMessageLogger(__FILE__, 1077, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::bind() called from incompatible context");
never executed: QMessageLogger(__FILE__, 1077, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::bind() called from incompatible context");
0
632-
633-
634 d->funcs.glBindFramebuffer(0x8D40, d->fbo());-
635-
636 QOpenGLContextPrivate::get(current)->qgl_current_fbo_invalid = true;-
637 QOpenGLContextPrivate::get(current)->qgl_current_fbo = this;-
638-
639 if (d->format.samples() == 0
d->format.samples() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
640-
641 for (int i = 0; i < d->colorAttachments.count()
i < d->colorAt...hments.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
642 if (!d->colorAttachments.at(i).guard
!d->colorAttac...ts.at(i).guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
643 d->initTexture(i);
never executed: d->initTexture(i);
0
644 }
never executed: end of block
0
645 }
never executed: end of block
0
646-
647 return
never executed: return d->valid;
d->valid;
never executed: return d->valid;
0
648}-
649bool QOpenGLFramebufferObject::release()-
650{-
651 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
652 return
never executed: return false;
false;
never executed: return false;
0
653-
654 QOpenGLContext *current = QOpenGLContext::currentContext();-
655 if (!current
!currentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
656 return
never executed: return false;
false;
never executed: return false;
0
657-
658 QOpenGLFramebufferObjectPrivate * const d = d_func();-
659-
660 if (current->shareGroup() != d->fbo_guard->group()
current->share...guard->group()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
661 QMessageLogger(__FILE__, 1117, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::release() called from incompatible context");
never executed: QMessageLogger(__FILE__, 1117, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::release() called from incompatible context");
0
662-
663-
664 if (current
currentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
665 d->funcs.glBindFramebuffer(0x8D40, current->defaultFramebufferObject());-
666-
667 QOpenGLContextPrivate *contextPrv = QOpenGLContextPrivate::get(current);-
668 contextPrv->qgl_current_fbo_invalid = true;-
669 contextPrv->qgl_current_fbo = nullptr;-
670 }
never executed: end of block
0
671-
672 return
never executed: return true;
true;
never executed: return true;
0
673}-
674GLuint QOpenGLFramebufferObject::texture() const-
675{-
676 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
677 return
never executed: return d->colorAttachments[0].guard ? d->colorAttachments[0].guard->id() : 0;
d->colorAttachments[0].guard ? d->colorAttachments[0].guard->id() : 0;
never executed: return d->colorAttachments[0].guard ? d->colorAttachments[0].guard->id() : 0;
0
678}-
679QVector<GLuint> QOpenGLFramebufferObject::textures() const-
680{-
681 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
682 QVector<GLuint> ids;-
683 if (d->format.samples() != 0
d->format.samples() != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
684 return
never executed: return ids;
ids;
never executed: return ids;
0
685 ids.reserve(d->colorAttachments.count());-
686 for (const auto &color : d->colorAttachments)-
687 ids.append(color.guard ? color.guard->id() : 0);
never executed: ids.append(color.guard ? color.guard->id() : 0);
0
688 return
never executed: return ids;
ids;
never executed: return ids;
0
689}-
690GLuint QOpenGLFramebufferObject::takeTexture()-
691{-
692 return
never executed: return takeTexture(0);
takeTexture(0);
never executed: return takeTexture(0);
0
693}-
694GLuint QOpenGLFramebufferObject::takeTexture(int colorAttachmentIndex)-
695{-
696 QOpenGLFramebufferObjectPrivate * const d = d_func();-
697 GLuint id = 0;-
698 if (isValid()
isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->format.samples() == 0
d->format.samples() == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& d->colorAttachments.count() > colorAttachmentIndex
d->colorAttach...ttachmentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
699 QOpenGLContext *current = QOpenGLContext::currentContext();-
700 if (current
currentDescription
TRUEnever evaluated
FALSEnever evaluated
&& current->shareGroup() == d->fbo_guard->group()
current->share...guard->group()Description
TRUEnever evaluated
FALSEnever evaluated
&& isBound()
isBound()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
701 release();
never executed: release();
0
702 auto &guard = d->colorAttachments[colorAttachmentIndex].guard;-
703 id = guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
? guard->id() : 0;
0
704-
705-
706 guard = 0;-
707 }
never executed: end of block
0
708 return
never executed: return id;
id;
never executed: return id;
0
709}-
710-
711-
712-
713-
714-
715QSize QOpenGLFramebufferObject::size() const-
716{-
717 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
718 return
never executed: return d->dsSize;
d->dsSize;
never executed: return d->dsSize;
0
719}-
720-
721-
722-
723-
724-
725-
726-
727QVector<QSize> QOpenGLFramebufferObject::sizes() const-
728{-
729 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
730 QVector<QSize> sz;-
731 sz.reserve(d->colorAttachments.size());-
732 for (const auto &color : d->colorAttachments)-
733 sz.append(color.size);
never executed: sz.append(color.size);
0
734 return
never executed: return sz;
sz;
never executed: return sz;
0
735}-
736QOpenGLFramebufferObjectFormat QOpenGLFramebufferObject::format() const-
737{-
738 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
739 return
never executed: return d->format;
d->format;
never executed: return d->format;
0
740}-
741-
742static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool include_alpha, QOpenGLContext *context)-
743{-
744 QOpenGLFunctions *funcs = context->functions();-
745 const int w = size.width();-
746 const int h = size.height();-
747 bool isOpenGL12orBetter = !context->isOpenGLES()
!context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
&& (context->format().majorVersion() >= 2
context->forma...Version() >= 2Description
TRUEnever evaluated
FALSEnever evaluated
|| context->format().minorVersion() >= 2
context->forma...Version() >= 2Description
TRUEnever evaluated
FALSEnever evaluated
);
0
748 if (isOpenGL12orBetter
isOpenGL12orBetterDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
749 QImage img(size, include_alpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);-
750 funcs->glReadPixels(0, 0, w, h, 0x80E1, 0x8367, img.bits());-
751 return
never executed: return img;
img;
never executed: return img;
0
752 }-
753-
754-
755-
756 const bool has_bgra_ext = context->isOpenGLES()
context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
757 ? context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_read_format_bgra") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_read_format_bgra" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return
never executed: return ba;
ba;
never executed: return ba;
}()))
0
758 : context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_bgra") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_bgra" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return
never executed: return ba;
ba;
never executed: return ba;
}()));
0
759-
760-
761 const char *renderer = reinterpret_cast<const char *>(funcs->glGetString(0x1F01));-
762 const char *ver = reinterpret_cast<const char *>(funcs->glGetString(0x1F02));-
763-
764-
765 const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0
qstrcmp(render...e G6200") == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
766 && ::
::strstr(ver, "1.3") != 0Description
TRUEnever evaluated
FALSEnever evaluated
strstr(ver, "1.3") != 0
::strstr(ver, "1.3") != 0Description
TRUEnever evaluated
FALSEnever evaluated
) ||
0
767 (qstrcmp(renderer, "Mali-T760") == 0
qstrcmp(render...li-T760") == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
768 && ::
::strstr(ver, "3.1") != 0Description
TRUEnever evaluated
FALSEnever evaluated
strstr(ver, "3.1") != 0
::strstr(ver, "3.1") != 0Description
TRUEnever evaluated
FALSEnever evaluated
) ||
0
769 (qstrcmp(renderer, "Mali-T720") == 0
qstrcmp(render...li-T720") == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
770 && ::
::strstr(ver, "3.1") != 0Description
TRUEnever evaluated
FALSEnever evaluated
strstr(ver, "3.1") != 0
::strstr(ver, "3.1") != 0Description
TRUEnever evaluated
FALSEnever evaluated
) ||
0
771 qstrcmp(renderer, "PowerVR SGX 554") == 0
qstrcmp(render...SGX 554") == 0Description
TRUEnever evaluated
FALSEnever evaluated
;
0
772-
773-
774-
775 const bool supports_bgra = has_bgra_ext
has_bgra_extDescription
TRUEnever evaluated
FALSEnever evaluated
&& !blackListed
!blackListedDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
776-
777 if (supports_bgra
supports_bgraDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
778 QImage img(size, include_alpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);-
779 funcs->glReadPixels(0, 0, w, h, 0x80E1, 0x1401, img.bits());-
780 return
never executed: return img;
img;
never executed: return img;
0
781 }-
782-
783 QImage rgbaImage(size, include_alpha ? QImage::Format_RGBA8888_Premultiplied : QImage::Format_RGBX8888);-
784 funcs->glReadPixels(0, 0, w, h, 0x1908, 0x1401, rgbaImage.bits());-
785 return
never executed: return rgbaImage;
rgbaImage;
never executed: return rgbaImage;
0
786}-
787-
788static inline QImage qt_gl_read_framebuffer_rgb10a2(const QSize &size, bool include_alpha, QOpenGLContext *context)-
789{-
790-
791 QImage img(size, include_alpha ? QImage::Format_A2BGR30_Premultiplied : QImage::Format_BGR30);-
792 context->functions()->glReadPixels(0, 0, size.width(), size.height(), 0x1908, 0x8368, img.bits());-
793 return
never executed: return img;
img;
never executed: return img;
0
794}-
795-
796static QImage qt_gl_read_framebuffer(const QSize &size, GLenum internal_format, bool include_alpha, bool flip)-
797{-
798 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
799 QOpenGLFunctions *funcs = ctx->functions();-
800 while (funcs->glGetError()
funcs->glGetError()Description
TRUEnever evaluated
FALSEnever evaluated
);
never executed: ;
0
801-
802 switch (internal_format) {-
803 case
never executed: case 0x1907:
0x1907:
never executed: case 0x1907:
0
804 case
never executed: case 0x8051:
0x8051:
never executed: case 0x8051:
0
805 return
never executed: return qt_gl_read_framebuffer_rgba8(size, false, ctx).mirrored(false, flip);
qt_gl_read_framebuffer_rgba8(size, false, ctx).mirrored(false, flip);
never executed: return qt_gl_read_framebuffer_rgba8(size, false, ctx).mirrored(false, flip);
0
806 case
never executed: case 0x8052:
0x8052:
never executed: case 0x8052:
0
807 return
never executed: return qt_gl_read_framebuffer_rgb10a2(size, false, ctx).mirrored(false, flip);
qt_gl_read_framebuffer_rgb10a2(size, false, ctx).mirrored(false, flip);
never executed: return qt_gl_read_framebuffer_rgb10a2(size, false, ctx).mirrored(false, flip);
0
808 case
never executed: case 0x8059:
0x8059:
never executed: case 0x8059:
0
809 return
never executed: return qt_gl_read_framebuffer_rgb10a2(size, include_alpha, ctx).mirrored(false, flip);
qt_gl_read_framebuffer_rgb10a2(size, include_alpha, ctx).mirrored(false, flip);
never executed: return qt_gl_read_framebuffer_rgb10a2(size, include_alpha, ctx).mirrored(false, flip);
0
810 case
never executed: case 0x1908:
0x1908:
never executed: case 0x1908:
0
811 case
never executed: case 0x8058:
0x8058:
never executed: case 0x8058:
0
812 default
never executed: default:
:
never executed: default:
0
813 return
never executed: return qt_gl_read_framebuffer_rgba8(size, include_alpha, ctx).mirrored(false, flip);
qt_gl_read_framebuffer_rgba8(size, include_alpha, ctx).mirrored(false, flip);
never executed: return qt_gl_read_framebuffer_rgba8(size, include_alpha, ctx).mirrored(false, flip);
0
814 }-
815-
816 do
dead code: do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,1353) : qt_noop()); __builtin_unreachable(); } while (0);
{ ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,1353) : qt_noop()); __builtin_unreachable(); } while (0);
dead code: do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,1353) : qt_noop()); __builtin_unreachable(); } while (0);
-
817 return
dead code: return QImage();
QImage();
dead code: return QImage();
-
818}-
819-
820__attribute__((visibility("default"))) QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha)-
821{-
822 return
never executed: return qt_gl_read_framebuffer(size, alpha_format ? 0x1908 : 0x1907, include_alpha, true);
qt_gl_read_framebuffer(size, alpha_format ? 0x1908 : 0x1907, include_alpha, true);
never executed: return qt_gl_read_framebuffer(size, alpha_format ? 0x1908 : 0x1907, include_alpha, true);
0
823}-
824QImage QOpenGLFramebufferObject::toImage(bool flipped) const-
825{-
826 return
never executed: return toImage(flipped, 0);
toImage(flipped, 0);
never executed: return toImage(flipped, 0);
0
827}-
828QImage QOpenGLFramebufferObject::toImage() const-
829{-
830 return
never executed: return toImage(true, 0);
toImage(true, 0);
never executed: return toImage(true, 0);
0
831}-
832QImage QOpenGLFramebufferObject::toImage(bool flipped, int colorAttachmentIndex) const-
833{-
834 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
835 if (!d->valid
!d->validDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
836 return
never executed: return QImage();
QImage();
never executed: return QImage();
0
837-
838 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
839 if (!ctx
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
840 QMessageLogger(__FILE__, 1439, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::toImage() called without a current context");-
841 return
never executed: return QImage();
QImage();
never executed: return QImage();
0
842 }-
843-
844 if (d->colorAttachments.count() <= colorAttachmentIndex
d->colorAttach...ttachmentIndexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
845 QMessageLogger(__FILE__, 1444, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::toImage() called for missing color attachment");-
846 return
never executed: return QImage();
QImage();
never executed: return QImage();
0
847 }-
848-
849 GLuint prevFbo = 0;-
850 ctx->functions()->glGetIntegerv(0x8CA6, (GLint *) &prevFbo);-
851-
852 if (prevFbo != d->fbo()
prevFbo != d->fbo()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
853 const_cast<
never executed: const_cast<QOpenGLFramebufferObject *>(this)->bind();
QOpenGLFramebufferObject *>(this)->bind();
never executed: const_cast<QOpenGLFramebufferObject *>(this)->bind();
0
854-
855 QImage image;-
856 QOpenGLExtraFunctions *extraFuncs = ctx->extraFunctions();-
857-
858 if (format().samples() != 0
format().samples() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
859 QRect rect(QPoint(0, 0), size());-
860 if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)
extraFuncs->ha...RenderTargets)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
861 QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, QOpenGLFramebufferObjectFormat());-
862 blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect,-
863 0x00004000, 0x2600,-
864 colorAttachmentIndex, 0);-
865 image = temp.toImage(flipped);-
866 }
never executed: end of block
else {
0
867 QOpenGLFramebufferObject temp(size(), QOpenGLFramebufferObjectFormat());-
868 blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect);-
869 image = temp.toImage(flipped);-
870 }
never executed: end of block
0
871 } else {-
872 if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)
extraFuncs->ha...RenderTargets)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
873 extraFuncs->glReadBuffer(0x8CE0 + colorAttachmentIndex);-
874 image = qt_gl_read_framebuffer(d->colorAttachments[colorAttachmentIndex].size,-
875 d->colorAttachments[colorAttachmentIndex].internalFormat,-
876 true, flipped);-
877 extraFuncs->glReadBuffer(0x8CE0);-
878 }
never executed: end of block
else {
0
879 image = qt_gl_read_framebuffer(d->colorAttachments[0].size,-
880 d->colorAttachments[0].internalFormat,-
881 true, flipped);-
882 }
never executed: end of block
0
883 }-
884-
885 if (prevFbo != d->fbo()
prevFbo != d->fbo()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
886 ctx->functions()->glBindFramebuffer(0x8D40, prevFbo);
never executed: ctx->functions()->glBindFramebuffer(0x8D40, prevFbo);
0
887-
888 return
never executed: return image;
image;
never executed: return image;
0
889}-
890bool QOpenGLFramebufferObject::bindDefault()-
891{-
892 QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());-
893-
894 if (ctx
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
895 ctx->functions()->glBindFramebuffer(0x8D40, ctx->defaultFramebufferObject());-
896 QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid = true;-
897 QOpenGLContextPrivate::get(ctx)->qgl_current_fbo = nullptr;-
898 }
never executed: end of block
0
899-
900 else-
901 QMessageLogger(__FILE__, 1510, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::bindDefault() called without current context.");
never executed: QMessageLogger(__FILE__, 1510, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::bindDefault() called without current context.");
0
902-
903-
904 return
never executed: return ctx != 0;
ctx != 0;
never executed: return ctx != 0;
0
905}-
906-
907-
908-
909-
910-
911-
912-
913bool QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()-
914{-
915 return
never executed: return QOpenGLContext::currentContext()->functions()->hasOpenGLFeature(QOpenGLFunctions::Framebuffers);
QOpenGLContext::currentContext()->functions()->hasOpenGLFeature(QOpenGLFunctions::Framebuffers);
never executed: return QOpenGLContext::currentContext()->functions()->hasOpenGLFeature(QOpenGLFunctions::Framebuffers);
0
916}-
917GLuint QOpenGLFramebufferObject::handle() const-
918{-
919 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
920 return
never executed: return d->fbo();
d->fbo();
never executed: return d->fbo();
0
921}-
922-
923-
924-
925-
926-
927-
928QOpenGLFramebufferObject::Attachment QOpenGLFramebufferObject::attachment() const-
929{-
930 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
931 if (d->valid
d->validDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
932 return
never executed: return d->fbo_attachment;
d->fbo_attachment;
never executed: return d->fbo_attachment;
0
933 return
never executed: return NoAttachment;
NoAttachment;
never executed: return NoAttachment;
0
934}-
935void QOpenGLFramebufferObject::setAttachment(QOpenGLFramebufferObject::Attachment attachment)-
936{-
937 QOpenGLFramebufferObjectPrivate * const d = d_func();-
938 if (attachment == d->fbo_attachment
attachment == ...fbo_attachmentDescription
TRUEnever evaluated
FALSEnever evaluated
|| !isValid()
!isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
939 return;
never executed: return;
0
940 QOpenGLContext *current = QOpenGLContext::currentContext();-
941 if (!current
!currentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
942 return;
never executed: return;
0
943-
944 if (current->shareGroup() != d->fbo_guard->group()
current->share...guard->group()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
945 QMessageLogger(__FILE__, 1573, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::setAttachment() called from incompatible context");
never executed: QMessageLogger(__FILE__, 1573, __PRETTY_FUNCTION__).warning("QOpenGLFramebufferObject::setAttachment() called from incompatible context");
0
946-
947 d->funcs.glBindFramebuffer(0x8D40, d->fbo());-
948 QOpenGLContextPrivate::get(current)->qgl_current_fbo_invalid = true;-
949 d->initDepthStencilAttachments(current, attachment);-
950}
never executed: end of block
0
951-
952-
953-
954-
955-
956bool QOpenGLFramebufferObject::isBound() const-
957{-
958 const QOpenGLFramebufferObjectPrivate * const d = d_func();-
959 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
960 if (!ctx
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
961 return
never executed: return false;
false;
never executed: return false;
0
962 GLint fbo = 0;-
963 ctx->functions()->glGetIntegerv(0x8CA6, &fbo);-
964 return
never executed: return GLuint(fbo) == d->fbo();
GLuint(fbo) == d->fbo();
never executed: return GLuint(fbo) == d->fbo();
0
965}-
966bool QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()-
967{-
968 return
never executed: return QOpenGLExtensions(QOpenGLContext::currentContext()).hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
QOpenGLExtensions(QOpenGLContext::currentContext()).hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
never executed: return QOpenGLExtensions(QOpenGLContext::currentContext()).hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
0
969}-
970-
971-
972-
973-
974-
975-
976-
977void QOpenGLFramebufferObject::blitFramebuffer(QOpenGLFramebufferObject *target,-
978 QOpenGLFramebufferObject *source,-
979 GLbitfield buffers, GLenum filter)-
980{-
981 if (!target
!targetDescription
TRUEnever evaluated
FALSEnever evaluated
&& !source
!sourceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
982 return;
never executed: return;
0
983-
984 QSize targetSize;-
985 QSize sourceSize;-
986-
987 if (target
targetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
988 targetSize = target->size();
never executed: targetSize = target->size();
0
989 if (source
sourceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
990 sourceSize = source->size();
never executed: sourceSize = source->size();
0
991-
992 if (targetSize.isEmpty()
targetSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
993 targetSize = sourceSize;
never executed: targetSize = sourceSize;
0
994 else if (sourceSize.isEmpty()
sourceSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
995 sourceSize = targetSize;
never executed: sourceSize = targetSize;
0
996-
997 blitFramebuffer(target, QRect(QPoint(0, 0), targetSize),-
998 source, QRect(QPoint(0, 0), sourceSize),-
999 buffers, filter);-
1000}
never executed: end of block
0
1001-
1002-
1003-
1004-
1005-
1006void QOpenGLFramebufferObject::blitFramebuffer(QOpenGLFramebufferObject *target, const QRect &targetRect,-
1007 QOpenGLFramebufferObject *source, const QRect &sourceRect,-
1008 GLbitfield buffers,-
1009 GLenum filter)-
1010{-
1011 blitFramebuffer(target, targetRect, source, sourceRect, buffers, filter, 0, 0);-
1012}
never executed: end of block
0
1013void QOpenGLFramebufferObject::blitFramebuffer(QOpenGLFramebufferObject *target, const QRect &targetRect,-
1014 QOpenGLFramebufferObject *source, const QRect &sourceRect,-
1015 GLbitfield buffers,-
1016 GLenum filter,-
1017 int readColorAttachmentIndex,-
1018 int drawColorAttachmentIndex,-
1019 QOpenGLFramebufferObject::FramebufferRestorePolicy restorePolicy)-
1020{-
1021 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
1022 if (!ctx
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1023 return;
never executed: return;
0
1024-
1025 QOpenGLExtensions extensions(ctx);-
1026 if (!extensions.hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)
!extensions.ha...amebufferBlit)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1027 return;
never executed: return;
0
1028-
1029 GLuint prevFbo = 0;-
1030 if (restorePolicy == RestoreFrameBufferBinding
restorePolicy ...eBufferBindingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1031 ctx->functions()->glGetIntegerv(0x8CA6, (GLint *) &prevFbo);
never executed: ctx->functions()->glGetIntegerv(0x8CA6, (GLint *) &prevFbo);
0
1032-
1033 const int sx0 = sourceRect.left();-
1034 const int sx1 = sourceRect.left() + sourceRect.width();-
1035 const int sy0 = sourceRect.top();-
1036 const int sy1 = sourceRect.top() + sourceRect.height();-
1037-
1038 const int tx0 = targetRect.left();-
1039 const int tx1 = targetRect.left() + targetRect.width();-
1040 const int ty0 = targetRect.top();-
1041 const int ty1 = targetRect.top() + targetRect.height();-
1042-
1043 const GLuint defaultFboId = ctx->defaultFramebufferObject();-
1044-
1045 extensions.glBindFramebuffer(0x8CA8, source ? source->handle() : defaultFboId);-
1046 extensions.glBindFramebuffer(0x8CA9, target ? target->handle() : defaultFboId);-
1047-
1048 const bool supportsMRT = extensions.hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets);-
1049 if (supportsMRT
supportsMRTDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1050 extensions.glReadBuffer(0x8CE0 + readColorAttachmentIndex);-
1051 if (target
targetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1052 GLenum drawBuf = 0x8CE0 + drawColorAttachmentIndex;-
1053 extensions.glDrawBuffers(1, &drawBuf);-
1054 }
never executed: end of block
0
1055 }
never executed: end of block
0
1056-
1057 extensions.glBlitFramebuffer(sx0, sy0, sx1, sy1,-
1058 tx0, ty0, tx1, ty1,-
1059 buffers, filter);-
1060-
1061 if (supportsMRT
supportsMRTDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1062 extensions.glReadBuffer(0x8CE0);
never executed: extensions.glReadBuffer(0x8CE0);
0
1063-
1064 switch (restorePolicy) {-
1065 case
never executed: case RestoreFrameBufferBinding:
RestoreFrameBufferBinding:
never executed: case RestoreFrameBufferBinding:
0
1066 ctx->functions()->glBindFramebuffer(0x8D40, prevFbo);-
1067 break;
never executed: break;
0
1068-
1069 case
never executed: case RestoreFramebufferBindingToDefault:
RestoreFramebufferBindingToDefault:
never executed: case RestoreFramebufferBindingToDefault:
0
1070 ctx->functions()->glBindFramebuffer(0x8D40, ctx->defaultFramebufferObject());-
1071 break;
never executed: break;
0
1072-
1073 case
never executed: case DontRestoreFramebufferBinding:
DontRestoreFramebufferBinding:
never executed: case DontRestoreFramebufferBinding:
0
1074 break;
never executed: break;
0
1075 }-
1076}
never executed: end of block
0
1077void QOpenGLFramebufferObject::blitFramebuffer(QOpenGLFramebufferObject *target, const QRect &targetRect,-
1078 QOpenGLFramebufferObject *source, const QRect &sourceRect,-
1079 GLbitfield buffers,-
1080 GLenum filter,-
1081 int readColorAttachmentIndex,-
1082 int drawColorAttachmentIndex)-
1083{-
1084 blitFramebuffer(target, targetRect, source, sourceRect,-
1085 buffers, filter,-
1086 readColorAttachmentIndex,-
1087 drawColorAttachmentIndex,-
1088 RestoreFrameBufferBinding);-
1089}
never executed: end of block
0
1090-
1091-
Switch to Source codePreprocessed file

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