| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | extern QImage qt_gl_read_frame_buffer(const QSize&, bool, bool); | - |
| 7 | void QGLFramebufferObjectFormat::detach() | - |
| 8 | { | - |
| 9 | if (d->ref.load() != 1) { never evaluated: d->ref.load() != 1 | 0 |
| 10 | QGLFramebufferObjectFormatPrivate *newd | - |
| 11 | = new QGLFramebufferObjectFormatPrivate(d); | - |
| 12 | if (!d->ref.deref()) never evaluated: !d->ref.deref() | 0 |
| 13 | delete d; never executed: delete d; | 0 |
| 14 | d = newd; | - |
| 15 | } | 0 |
| 16 | } | 0 |
| 17 | QGLFramebufferObjectFormat::QGLFramebufferObjectFormat() | - |
| 18 | { | - |
| 19 | d = new QGLFramebufferObjectFormatPrivate; | - |
| 20 | } | 0 |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other) | - |
| 27 | { | - |
| 28 | d = other.d; | - |
| 29 | d->ref.ref(); | - |
| 30 | } | 0 |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | QGLFramebufferObjectFormat &QGLFramebufferObjectFormat::operator=(const QGLFramebufferObjectFormat &other) | - |
| 37 | { | - |
| 38 | if (d != other.d) { never evaluated: d != other.d | 0 |
| 39 | other.d->ref.ref(); | - |
| 40 | if (!d->ref.deref()) never evaluated: !d->ref.deref() | 0 |
| 41 | delete d; never executed: delete d; | 0 |
| 42 | d = other.d; | - |
| 43 | } | 0 |
| 44 | return *this; never executed: return *this; | 0 |
| 45 | } | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat() | - |
| 51 | { | - |
| 52 | if (!d->ref.deref()) never evaluated: !d->ref.deref() | 0 |
| 53 | delete d; never executed: delete d; | 0 |
| 54 | } | 0 |
| 55 | void QGLFramebufferObjectFormat::setSamples(int samples) | - |
| 56 | { | - |
| 57 | detach(); | - |
| 58 | d->samples = samples; | - |
| 59 | } | 0 |
| 60 | int QGLFramebufferObjectFormat::samples() const | - |
| 61 | { | - |
| 62 | return d->samples; never executed: return d->samples; | 0 |
| 63 | } | - |
| 64 | void QGLFramebufferObjectFormat::setMipmap(bool enabled) | - |
| 65 | { | - |
| 66 | detach(); | - |
| 67 | d->mipmap = enabled; | - |
| 68 | } | 0 |
| 69 | bool QGLFramebufferObjectFormat::mipmap() const | - |
| 70 | { | - |
| 71 | return d->mipmap; never executed: return d->mipmap; | 0 |
| 72 | } | - |
| 73 | | - |
| 74 | | - |
| 75 | | - |
| 76 | | - |
| 77 | | - |
| 78 | | - |
| 79 | void QGLFramebufferObjectFormat::setAttachment(QGLFramebufferObject::Attachment attachment) | - |
| 80 | { | - |
| 81 | detach(); | - |
| 82 | d->attachment = attachment; | - |
| 83 | } | 0 |
| 84 | | - |
| 85 | | - |
| 86 | | - |
| 87 | | - |
| 88 | | - |
| 89 | | - |
| 90 | | - |
| 91 | QGLFramebufferObject::Attachment QGLFramebufferObjectFormat::attachment() const | - |
| 92 | { | - |
| 93 | return d->attachment; never executed: return d->attachment; | 0 |
| 94 | } | - |
| 95 | | - |
| 96 | | - |
| 97 | | - |
| 98 | | - |
| 99 | | - |
| 100 | | - |
| 101 | | - |
| 102 | void QGLFramebufferObjectFormat::setTextureTarget(GLenum target) | - |
| 103 | { | - |
| 104 | detach(); | - |
| 105 | d->target = target; | - |
| 106 | } | 0 |
| 107 | GLenum QGLFramebufferObjectFormat::textureTarget() const | - |
| 108 | { | - |
| 109 | return d->target; never executed: return d->target; | 0 |
| 110 | } | - |
| 111 | void QGLFramebufferObjectFormat::setInternalTextureFormat(GLenum internalTextureFormat) | - |
| 112 | { | - |
| 113 | detach(); | - |
| 114 | d->internal_format = internalTextureFormat; | - |
| 115 | } | 0 |
| 116 | GLenum QGLFramebufferObjectFormat::internalTextureFormat() const | - |
| 117 | { | - |
| 118 | return d->internal_format; never executed: return d->internal_format; | 0 |
| 119 | } | - |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | bool QGLFramebufferObjectFormat::operator==(const QGLFramebufferObjectFormat& other) const | - |
| 126 | { | - |
| 127 | if (d == other.d) never evaluated: d == other.d | 0 |
| 128 | return true; never executed: return true; | 0 |
| 129 | else | - |
| 130 | return d->equals(other.d); never executed: return d->equals(other.d); | 0 |
| 131 | } | - |
| 132 | | - |
| 133 | | - |
| 134 | | - |
| 135 | | - |
| 136 | | - |
| 137 | bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& other) const | - |
| 138 | { | - |
| 139 | return !(*this == other); never executed: return !(*this == other); | 0 |
| 140 | } | - |
| 141 | | - |
| 142 | void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f, | - |
| 143 | QGLFramebufferObject::Attachment attachment) | - |
| 144 | { | - |
| 145 | fbo = f; | - |
| 146 | m_thisFBO = fbo->d_func()->fbo(); | - |
| 147 | | - |
| 148 | | - |
| 149 | | - |
| 150 | fboFormat = QGLContext::currentContext()->format(); | - |
| 151 | if (attachment == QGLFramebufferObject::CombinedDepthStencil) { never evaluated: attachment == QGLFramebufferObject::CombinedDepthStencil | 0 |
| 152 | fboFormat.setDepth(true); | - |
| 153 | fboFormat.setStencil(true); | - |
| 154 | } else if (attachment == QGLFramebufferObject::Depth) { never evaluated: attachment == QGLFramebufferObject::Depth | 0 |
| 155 | fboFormat.setDepth(true); | - |
| 156 | fboFormat.setStencil(false); | - |
| 157 | } else { | 0 |
| 158 | fboFormat.setDepth(false); | - |
| 159 | fboFormat.setStencil(false); | - |
| 160 | } | 0 |
| 161 | | - |
| 162 | GLenum format = f->format().internalTextureFormat(); | - |
| 163 | reqAlpha = (format != 0x1907 never evaluated: format != 0x1907 | 0 |
| 164 | | - |
| 165 | && format != 0x8050 && format != 0x8051 never evaluated: format != 0x8050 never evaluated: format != 0x8051 | 0 |
| 166 | | - |
| 167 | ); | - |
| 168 | } | 0 |
| 169 | | - |
| 170 | QGLContext *QGLFBOGLPaintDevice::context() const | - |
| 171 | { | - |
| 172 | return const_cast<QGLContext *>(QGLContext::currentContext()); never executed: return const_cast<QGLContext *>(QGLContext::currentContext()); | 0 |
| 173 | } | - |
| 174 | | - |
| 175 | bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const | - |
| 176 | { | - |
| 177 | const QGLContext *ctx = QGLContext::currentContext();; | - |
| 178 | if (!ctx) | 0 |
| 179 | return false; never executed: return false; | 0 |
| 180 | GLenum status = QGLContextPrivate::extensionFuncs(ctx).qt_glCheckFramebufferStatus(0x8D40); | - |
| 181 | switch(status) { | - |
| 182 | case 0x0: | - |
| 183 | case 0x8CD5: | - |
| 184 | return true; never executed: return true; | 0 |
| 185 | case 0x8CDD: | - |
| 186 | QMessageLogger("qglframebufferobject.cpp", 398, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Unsupported framebuffer format."); | - |
| 187 | break; | 0 |
| 188 | case 0x8CD6: | - |
| 189 | QMessageLogger("qglframebufferobject.cpp", 401, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete attachment."); | - |
| 190 | break; | 0 |
| 191 | case 0x8CD7: | - |
| 192 | QMessageLogger("qglframebufferobject.cpp", 404, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, missing attachment."); | - |
| 193 | break; | 0 |
| 194 | case 0x8CDB: | - |
| 195 | QMessageLogger("qglframebufferobject.cpp", 423, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, missing draw buffer."); | - |
| 196 | break; | 0 |
| 197 | | - |
| 198 | | - |
| 199 | case 0x8CDC: | - |
| 200 | QMessageLogger("qglframebufferobject.cpp", 428, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, missing read buffer."); | - |
| 201 | break; | 0 |
| 202 | | - |
| 203 | | - |
| 204 | case 0x8D56: | - |
| 205 | QMessageLogger("qglframebufferobject.cpp", 433, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, attachments must have same number of samples per pixel."); | - |
| 206 | break; | 0 |
| 207 | | - |
| 208 | default: | - |
| 209 | QMessageLogger("qglframebufferobject.cpp", 437, __PRETTY_FUNCTION__).debug() <<"QGLFramebufferObject: An undefined error has occurred: "<< status; | - |
| 210 | break; | 0 |
| 211 | } | - |
| 212 | return false; never executed: return false; | 0 |
| 213 | } | - |
| 214 | | - |
| 215 | namespace | - |
| 216 | { | - |
| 217 | void freeFramebufferFunc(QGLContext *ctx, GLuint id) | - |
| 218 | { | - |
| 219 | (void)ctx;; | - |
| 220 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteFramebuffers(1, &id); | - |
| 221 | } | 0 |
| 222 | | - |
| 223 | void freeRenderbufferFunc(QGLContext *ctx, GLuint id) | - |
| 224 | { | - |
| 225 | (void)ctx;; | - |
| 226 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &id); | - |
| 227 | } | 0 |
| 228 | | - |
| 229 | void freeTextureFunc(QGLContext *ctx, GLuint id) | - |
| 230 | { | - |
| 231 | (void)ctx;; | - |
| 232 | glDeleteTextures(1, &id); | - |
| 233 | } | 0 |
| 234 | } | - |
| 235 | | - |
| 236 | void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, | - |
| 237 | QGLFramebufferObject::Attachment attachment, | - |
| 238 | GLenum texture_target, GLenum internal_format, | - |
| 239 | GLint samples, bool mipmap) | - |
| 240 | { | - |
| 241 | QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); | - |
| 242 | | - |
| 243 | bool ext_detected = (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject); | - |
| 244 | if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx))) never evaluated: !ext_detected never evaluated: ext_detected never evaluated: !qt_resolve_framebufferobject_extensions(ctx) | 0 |
| 245 | return; | 0 |
| 246 | | - |
| 247 | size = sz; | - |
| 248 | target = texture_target; | - |
| 249 | | - |
| 250 | | - |
| 251 | {}; | - |
| 252 | GLuint fbo = 0; | - |
| 253 | QGLContextPrivate::extensionFuncs(ctx).qt_glGenFramebuffers(1, &fbo); | - |
| 254 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, fbo); | - |
| 255 | | - |
| 256 | GLuint texture = 0; | - |
| 257 | GLuint color_buffer = 0; | - |
| 258 | GLuint depth_buffer = 0; | - |
| 259 | GLuint stencil_buffer = 0; | - |
| 260 | | - |
| 261 | {}; | - |
| 262 | | - |
| 263 | if (samples == 0) { never evaluated: samples == 0 | 0 |
| 264 | glGenTextures(1, &texture); | - |
| 265 | glBindTexture(target, texture); | - |
| 266 | glTexImage2D(target, 0, internal_format, size.width(), size.height(), 0, | - |
| 267 | 0x1908, 0x1401, __null); | - |
| 268 | if (mipmap) { | 0 |
| 269 | int width = size.width(); | - |
| 270 | int height = size.height(); | - |
| 271 | int level = 0; | - |
| 272 | while (width > 1 || height > 1) { never evaluated: width > 1 never evaluated: height > 1 | 0 |
| 273 | width = qMax(1, width >> 1); | - |
| 274 | height = qMax(1, height >> 1); | - |
| 275 | ++level; | - |
| 276 | glTexImage2D(target, level, internal_format, width, height, 0, | - |
| 277 | 0x1908, 0x1401, __null); | - |
| 278 | } | 0 |
| 279 | } | 0 |
| 280 | glTexParameteri(target, 0x2801, 0x2600); | - |
| 281 | glTexParameteri(target, 0x2800, 0x2600); | - |
| 282 | glTexParameteri(target, 0x2802, 0x812F); | - |
| 283 | glTexParameteri(target, 0x2803, 0x812F); | - |
| 284 | QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTexture2D(0x8D40, 0x8CE0, | - |
| 285 | target, texture, 0); | - |
| 286 | | - |
| 287 | {}; | - |
| 288 | valid = checkFramebufferStatus(); | - |
| 289 | glBindTexture(target, 0); | - |
| 290 | | - |
| 291 | color_buffer = 0; | - |
| 292 | } else { | 0 |
| 293 | mipmap = false; | - |
| 294 | GLint maxSamples; | - |
| 295 | glGetIntegerv(0x8D57, &maxSamples); | - |
| 296 | | - |
| 297 | samples = qBound(0, int(samples), int(maxSamples)); | - |
| 298 | | - |
| 299 | QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers(1, &color_buffer); | - |
| 300 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer(0x8D41, color_buffer); | - |
| 301 | if (QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT && samples > 0) { never evaluated: QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT never evaluated: samples > 0 | 0 |
| 302 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT(0x8D41, samples, | - |
| 303 | internal_format, size.width(), size.height()); | - |
| 304 | } else { | 0 |
| 305 | samples = 0; | - |
| 306 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage(0x8D41, internal_format, | - |
| 307 | size.width(), size.height()); | - |
| 308 | } | 0 |
| 309 | | - |
| 310 | QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer(0x8D40, 0x8CE0, | - |
| 311 | 0x8D41, color_buffer); | - |
| 312 | | - |
| 313 | {}; | - |
| 314 | valid = checkFramebufferStatus(); | - |
| 315 | | - |
| 316 | if (valid) | 0 |
| 317 | QGLContextPrivate::extensionFuncs(ctx).qt_glGetRenderbufferParameteriv(0x8D41, 0x8CAB, &samples); never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glGetRenderbufferParameteriv(0x8D41, 0x8CAB, &samples); | 0 |
| 318 | } | 0 |
| 319 | | - |
| 320 | | - |
| 321 | | - |
| 322 | | - |
| 323 | | - |
| 324 | if (attachment == QGLFramebufferObject::CombinedDepthStencil never evaluated: attachment == QGLFramebufferObject::CombinedDepthStencil | 0 |
| 325 | && (QGLExtensions::glExtensions() & QGLExtensions::PackedDepthStencil)) { never evaluated: (QGLExtensions::glExtensions() & QGLExtensions::PackedDepthStencil) | 0 |
| 326 | | - |
| 327 | QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers(1, &depth_buffer); | - |
| 328 | qt_noop(); | - |
| 329 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer(0x8D41, depth_buffer); | - |
| 330 | qt_noop(); | - |
| 331 | if (samples != 0 && QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT) never evaluated: samples != 0 never evaluated: QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT | 0 |
| 332 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT(0x8D41, samples, | 0 |
| 333 | 0x88F0, size.width(), size.height()); never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT(0x8D41, samples, 0x88F0, size.width(), size.height()); | 0 |
| 334 | else | - |
| 335 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage(0x8D41, | 0 |
| 336 | 0x88F0, size.width(), size.height()); never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage(0x8D41, 0x88F0, size.width(), size.height()); | 0 |
| 337 | | - |
| 338 | stencil_buffer = depth_buffer; | - |
| 339 | QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer(0x8D40, 0x8D00, | - |
| 340 | 0x8D41, depth_buffer); | - |
| 341 | QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer(0x8D40, 0x8D20, | - |
| 342 | 0x8D41, stencil_buffer); | - |
| 343 | | - |
| 344 | valid = checkFramebufferStatus(); | - |
| 345 | if (!valid) { | 0 |
| 346 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &depth_buffer); | - |
| 347 | stencil_buffer = depth_buffer = 0; | - |
| 348 | } | 0 |
| 349 | } | 0 |
| 350 | | - |
| 351 | if (depth_buffer == 0 && (attachment == QGLFramebufferObject::CombinedDepthStencil never evaluated: depth_buffer == 0 never evaluated: attachment == QGLFramebufferObject::CombinedDepthStencil | 0 |
| 352 | || (attachment == QGLFramebufferObject::Depth))) never evaluated: (attachment == QGLFramebufferObject::Depth) | 0 |
| 353 | { | - |
| 354 | QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers(1, &depth_buffer); | - |
| 355 | qt_noop(); | - |
| 356 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer(0x8D41, depth_buffer); | - |
| 357 | qt_noop(); | - |
| 358 | if (samples != 0 && QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT) { never evaluated: samples != 0 never evaluated: QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT | 0 |
| 359 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT(0x8D41, samples, | - |
| 360 | 0x1902, size.width(), size.height()); | - |
| 361 | | - |
| 362 | } else { | 0 |
| 363 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage(0x8D41, 0x1902, size.width(), size.height()); | - |
| 364 | | - |
| 365 | } | 0 |
| 366 | QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer(0x8D40, 0x8D00, | - |
| 367 | 0x8D41, depth_buffer); | - |
| 368 | valid = checkFramebufferStatus(); | - |
| 369 | if (!valid) { | 0 |
| 370 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &depth_buffer); | - |
| 371 | depth_buffer = 0; | - |
| 372 | } | 0 |
| 373 | } | 0 |
| 374 | | - |
| 375 | if (stencil_buffer == 0 && (attachment == QGLFramebufferObject::CombinedDepthStencil)) { never evaluated: stencil_buffer == 0 never evaluated: (attachment == QGLFramebufferObject::CombinedDepthStencil) | 0 |
| 376 | QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers(1, &stencil_buffer); | - |
| 377 | qt_noop(); | - |
| 378 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer(0x8D41, stencil_buffer); | - |
| 379 | qt_noop(); | - |
| 380 | if (samples != 0 && QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT) { never evaluated: samples != 0 never evaluated: QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT | 0 |
| 381 | | - |
| 382 | | - |
| 383 | | - |
| 384 | | - |
| 385 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT(0x8D41, samples, | - |
| 386 | 0x1901, size.width(), size.height()); | - |
| 387 | | - |
| 388 | } else { | 0 |
| 389 | | - |
| 390 | | - |
| 391 | | - |
| 392 | | - |
| 393 | QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage(0x8D41, 0x1901, | - |
| 394 | size.width(), size.height()); | - |
| 395 | | - |
| 396 | } | 0 |
| 397 | QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer(0x8D40, 0x8D20, | - |
| 398 | 0x8D41, stencil_buffer); | - |
| 399 | valid = checkFramebufferStatus(); | - |
| 400 | if (!valid) { | 0 |
| 401 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &stencil_buffer); | - |
| 402 | stencil_buffer = 0; | - |
| 403 | } | 0 |
| 404 | } | 0 |
| 405 | | - |
| 406 | | - |
| 407 | valid = checkFramebufferStatus(); | - |
| 408 | | - |
| 409 | if (depth_buffer && stencil_buffer) { never evaluated: depth_buffer never evaluated: stencil_buffer | 0 |
| 410 | fbo_attachment = QGLFramebufferObject::CombinedDepthStencil; | - |
| 411 | } else if (depth_buffer) { never evaluated: depth_buffer | 0 |
| 412 | fbo_attachment = QGLFramebufferObject::Depth; | - |
| 413 | } else { | 0 |
| 414 | fbo_attachment = QGLFramebufferObject::NoAttachment; | - |
| 415 | } | 0 |
| 416 | | - |
| 417 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, ctx->d_ptr->current_fbo); | - |
| 418 | if (valid) { | 0 |
| 419 | fbo_guard = createSharedResourceGuard(ctx, fbo, freeFramebufferFunc); | - |
| 420 | if (color_buffer) never evaluated: color_buffer | 0 |
| 421 | color_buffer_guard = createSharedResourceGuard(ctx, color_buffer, freeRenderbufferFunc); never executed: color_buffer_guard = createSharedResourceGuard(ctx, color_buffer, freeRenderbufferFunc); | 0 |
| 422 | else | - |
| 423 | texture_guard = createSharedResourceGuard(ctx, texture, freeTextureFunc); never executed: texture_guard = createSharedResourceGuard(ctx, texture, freeTextureFunc); | 0 |
| 424 | if (depth_buffer) never evaluated: depth_buffer | 0 |
| 425 | depth_buffer_guard = createSharedResourceGuard(ctx, depth_buffer, freeRenderbufferFunc); never executed: depth_buffer_guard = createSharedResourceGuard(ctx, depth_buffer, freeRenderbufferFunc); | 0 |
| 426 | if (stencil_buffer) { never evaluated: stencil_buffer | 0 |
| 427 | if (stencil_buffer == depth_buffer) never evaluated: stencil_buffer == depth_buffer | 0 |
| 428 | stencil_buffer_guard = depth_buffer_guard; never executed: stencil_buffer_guard = depth_buffer_guard; | 0 |
| 429 | else | - |
| 430 | stencil_buffer_guard = createSharedResourceGuard(ctx, stencil_buffer, freeRenderbufferFunc); never executed: stencil_buffer_guard = createSharedResourceGuard(ctx, stencil_buffer, freeRenderbufferFunc); | 0 |
| 431 | } | - |
| 432 | } else { | 0 |
| 433 | if (color_buffer) never evaluated: color_buffer | 0 |
| 434 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &color_buffer); never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &color_buffer); | 0 |
| 435 | else | - |
| 436 | glDeleteTextures(1, &texture); never executed: glDeleteTextures(1, &texture); | 0 |
| 437 | if (depth_buffer) never evaluated: depth_buffer | 0 |
| 438 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &depth_buffer); never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &depth_buffer); | 0 |
| 439 | if (stencil_buffer && depth_buffer != stencil_buffer) never evaluated: stencil_buffer never evaluated: depth_buffer != stencil_buffer | 0 |
| 440 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &stencil_buffer); never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers(1, &stencil_buffer); | 0 |
| 441 | QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteFramebuffers(1, &fbo); | - |
| 442 | } | 0 |
| 443 | {}; | - |
| 444 | | - |
| 445 | format.setTextureTarget(target); | - |
| 446 | format.setSamples(int(samples)); | - |
| 447 | format.setAttachment(fbo_attachment); | - |
| 448 | format.setInternalTextureFormat(internal_format); | - |
| 449 | format.setMipmap(mipmap); | - |
| 450 | | - |
| 451 | glDevice.setFBO(q, attachment); | - |
| 452 | } | 0 |
| 453 | QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target) | - |
| 454 | : d_ptr(new QGLFramebufferObjectPrivate) | - |
| 455 | { | - |
| 456 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 457 | d->init(this, size, NoAttachment, target, 0x8058); | - |
| 458 | } | 0 |
| 459 | QGLFramebufferObject::QGLFramebufferObject(int width, int height, GLenum target) | - |
| 460 | : d_ptr(new QGLFramebufferObjectPrivate) | - |
| 461 | { | - |
| 462 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 463 | d->init(this, QSize(width, height), NoAttachment, target, 0x8058); | - |
| 464 | } | 0 |
| 465 | | - |
| 466 | | - |
| 467 | | - |
| 468 | | - |
| 469 | | - |
| 470 | | - |
| 471 | | - |
| 472 | QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebufferObjectFormat &format) | - |
| 473 | : d_ptr(new QGLFramebufferObjectPrivate) | - |
| 474 | { | - |
| 475 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 476 | d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), | - |
| 477 | format.samples(), format.mipmap()); | - |
| 478 | } | 0 |
| 479 | | - |
| 480 | | - |
| 481 | | - |
| 482 | | - |
| 483 | | - |
| 484 | | - |
| 485 | | - |
| 486 | QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFramebufferObjectFormat &format) | - |
| 487 | : d_ptr(new QGLFramebufferObjectPrivate) | - |
| 488 | { | - |
| 489 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 490 | d->init(this, QSize(width, height), format.attachment(), format.textureTarget(), | - |
| 491 | format.internalTextureFormat(), format.samples(), format.mipmap()); | - |
| 492 | } | 0 |
| 493 | QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment attachment, | - |
| 494 | GLenum target, GLenum internal_format) | - |
| 495 | : d_ptr(new QGLFramebufferObjectPrivate) | - |
| 496 | { | - |
| 497 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 498 | d->init(this, QSize(width, height), attachment, target, internal_format); | - |
| 499 | } | 0 |
| 500 | QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachment, | - |
| 501 | GLenum target, GLenum internal_format) | - |
| 502 | : d_ptr(new QGLFramebufferObjectPrivate) | - |
| 503 | { | - |
| 504 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 505 | d->init(this, size, attachment, target, internal_format); | - |
| 506 | } | 0 |
| 507 | | - |
| 508 | | - |
| 509 | | - |
| 510 | | - |
| 511 | | - |
| 512 | | - |
| 513 | QGLFramebufferObject::~QGLFramebufferObject() | - |
| 514 | { | - |
| 515 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 516 | | - |
| 517 | delete d->engine; | - |
| 518 | | - |
| 519 | if (d->texture_guard) never evaluated: d->texture_guard | 0 |
| 520 | d->texture_guard->free(); never executed: d->texture_guard->free(); | 0 |
| 521 | if (d->color_buffer_guard) never evaluated: d->color_buffer_guard | 0 |
| 522 | d->color_buffer_guard->free(); never executed: d->color_buffer_guard->free(); | 0 |
| 523 | if (d->depth_buffer_guard) never evaluated: d->depth_buffer_guard | 0 |
| 524 | d->depth_buffer_guard->free(); never executed: d->depth_buffer_guard->free(); | 0 |
| 525 | if (d->stencil_buffer_guard && d->stencil_buffer_guard != d->depth_buffer_guard) never evaluated: d->stencil_buffer_guard never evaluated: d->stencil_buffer_guard != d->depth_buffer_guard | 0 |
| 526 | d->stencil_buffer_guard->free(); never executed: d->stencil_buffer_guard->free(); | 0 |
| 527 | if (d->fbo_guard) never evaluated: d->fbo_guard | 0 |
| 528 | d->fbo_guard->free(); never executed: d->fbo_guard->free(); | 0 |
| 529 | } | 0 |
| 530 | bool QGLFramebufferObject::isValid() const | - |
| 531 | { | - |
| 532 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 533 | return d->valid && d->fbo_guard && d->fbo_guard->id(); never executed: return d->valid && d->fbo_guard && d->fbo_guard->id(); | 0 |
| 534 | } | - |
| 535 | bool QGLFramebufferObject::bind() | - |
| 536 | { | - |
| 537 | if (!isValid()) never evaluated: !isValid() | 0 |
| 538 | return false; never executed: return false; | 0 |
| 539 | QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 540 | const QGLContext *ctx = QGLContext::currentContext();; | - |
| 541 | if (!ctx) | 0 |
| 542 | return false; never executed: return false; | 0 |
| 543 | const QGLContext *current = QGLContext::currentContext(); | - |
| 544 | | - |
| 545 | | - |
| 546 | | - |
| 547 | | - |
| 548 | | - |
| 549 | | - |
| 550 | | - |
| 551 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, d->fbo()); | - |
| 552 | d->valid = d->checkFramebufferStatus(); | - |
| 553 | if (d->valid && current) never evaluated: d->valid | 0 |
| 554 | current->d_ptr->current_fbo = d->fbo(); never executed: current->d_ptr->current_fbo = d->fbo(); | 0 |
| 555 | return d->valid; never executed: return d->valid; | 0 |
| 556 | } | - |
| 557 | bool QGLFramebufferObject::release() | - |
| 558 | { | - |
| 559 | if (!isValid()) never evaluated: !isValid() | 0 |
| 560 | return false; never executed: return false; | 0 |
| 561 | const QGLContext *ctx = QGLContext::currentContext();; | - |
| 562 | if (!ctx) | 0 |
| 563 | return false; never executed: return false; | 0 |
| 564 | | - |
| 565 | const QGLContext *current = QGLContext::currentContext(); | - |
| 566 | if (current) { | 0 |
| 567 | current->d_ptr->current_fbo = current->d_ptr->default_fbo; | - |
| 568 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, current->d_ptr->default_fbo); | - |
| 569 | } | 0 |
| 570 | | - |
| 571 | return true; never executed: return true; | 0 |
| 572 | } | - |
| 573 | GLuint QGLFramebufferObject::texture() const | - |
| 574 | { | - |
| 575 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 576 | return d->texture_guard ? d->texture_guard->id() : 0; never executed: return d->texture_guard ? d->texture_guard->id() : 0; | 0 |
| 577 | } | - |
| 578 | | - |
| 579 | | - |
| 580 | | - |
| 581 | | - |
| 582 | | - |
| 583 | | - |
| 584 | | - |
| 585 | QSize QGLFramebufferObject::size() const | - |
| 586 | { | - |
| 587 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 588 | return d->size; never executed: return d->size; | 0 |
| 589 | } | - |
| 590 | | - |
| 591 | | - |
| 592 | | - |
| 593 | | - |
| 594 | QGLFramebufferObjectFormat QGLFramebufferObject::format() const | - |
| 595 | { | - |
| 596 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 597 | return d->format; never executed: return d->format; | 0 |
| 598 | } | - |
| 599 | | - |
| 600 | | - |
| 601 | | - |
| 602 | | - |
| 603 | | - |
| 604 | | - |
| 605 | QImage QGLFramebufferObject::toImage() const | - |
| 606 | { | - |
| 607 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 608 | if (!d->valid) never evaluated: !d->valid | 0 |
| 609 | return QImage(); never executed: return QImage(); | 0 |
| 610 | | - |
| 611 | | - |
| 612 | if (format().samples() != 0) { never evaluated: format().samples() != 0 | 0 |
| 613 | QGLFramebufferObject temp(size(), QGLFramebufferObjectFormat()); | - |
| 614 | | - |
| 615 | QRect rect(QPoint(0, 0), size()); | - |
| 616 | blitFramebuffer(&temp, rect, const_cast<QGLFramebufferObject *>(this), rect); | - |
| 617 | | - |
| 618 | return temp.toImage(); never executed: return temp.toImage(); | 0 |
| 619 | } | - |
| 620 | | - |
| 621 | bool wasBound = isBound(); | - |
| 622 | if (!wasBound) never evaluated: !wasBound | 0 |
| 623 | const_cast<QGLFramebufferObject *>(this)->bind(); never executed: const_cast<QGLFramebufferObject *>(this)->bind(); | 0 |
| 624 | QImage image = qt_gl_read_frame_buffer(d->size, format().internalTextureFormat() != 0x1907, true); | - |
| 625 | if (!wasBound) never evaluated: !wasBound | 0 |
| 626 | const_cast<QGLFramebufferObject *>(this)->release(); never executed: const_cast<QGLFramebufferObject *>(this)->release(); | 0 |
| 627 | | - |
| 628 | return image; never executed: return image; | 0 |
| 629 | } | - |
| 630 | | - |
| 631 | static QGLEngineThreadStorage<QGL2PaintEngineEx> *qt_buffer_2_engine() { static QGlobalStatic<QGLEngineThreadStorage<QGL2PaintEngineEx> > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QGLEngineThreadStorage<QGL2PaintEngineEx> *x = new QGLEngineThreadStorage<QGL2PaintEngineEx>; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QGLEngineThreadStorage<QGL2PaintEngineEx> > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; never executed: return thisGlobalStatic.pointer.load(); never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) never evaluated: !thisGlobalStatic.pointer.load() never evaluated: !thisGlobalStatic.destroyed | 0 |
| 632 | | - |
| 633 | | - |
| 634 | QPaintEngine *QGLFramebufferObject::paintEngine() const | - |
| 635 | { | - |
| 636 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 637 | if (d->engine) never evaluated: d->engine | 0 |
| 638 | return d->engine; never executed: return d->engine; | 0 |
| 639 | | - |
| 640 | QPaintEngine *engine = qt_buffer_2_engine()->engine(); | - |
| 641 | if (engine->isActive() && engine->paintDevice() != this) { never evaluated: engine->isActive() never evaluated: engine->paintDevice() != this | 0 |
| 642 | d->engine = new QGL2PaintEngineEx; | - |
| 643 | return d->engine; never executed: return d->engine; | 0 |
| 644 | } | - |
| 645 | return engine; never executed: return engine; | 0 |
| 646 | } | - |
| 647 | bool QGLFramebufferObject::bindDefault() | - |
| 648 | { | - |
| 649 | QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); | - |
| 650 | | - |
| 651 | if (ctx) { | 0 |
| 652 | bool ext_detected = (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject); | - |
| 653 | if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx))) never evaluated: !ext_detected never evaluated: ext_detected never evaluated: !qt_resolve_framebufferobject_extensions(ctx) | 0 |
| 654 | return false; never executed: return false; | 0 |
| 655 | | - |
| 656 | ctx->d_ptr->current_fbo = ctx->d_ptr->default_fbo; | - |
| 657 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, ctx->d_ptr->default_fbo); | - |
| 658 | | - |
| 659 | | - |
| 660 | | - |
| 661 | | - |
| 662 | } | 0 |
| 663 | | - |
| 664 | return ctx != 0; never executed: return ctx != 0; | 0 |
| 665 | } | - |
| 666 | | - |
| 667 | | - |
| 668 | | - |
| 669 | | - |
| 670 | | - |
| 671 | | - |
| 672 | | - |
| 673 | bool QGLFramebufferObject::hasOpenGLFramebufferObjects() | - |
| 674 | { | - |
| 675 | return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject); never executed: return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject); | 0 |
| 676 | } | - |
| 677 | void QGLFramebufferObject::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) | - |
| 678 | { | - |
| 679 | const_cast<QGLContext *>(QGLContext::currentContext())->drawTexture(target, textureId, textureTarget); | - |
| 680 | } | 0 |
| 681 | void QGLFramebufferObject::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) | - |
| 682 | { | - |
| 683 | const_cast<QGLContext *>(QGLContext::currentContext())->drawTexture(point, textureId, textureTarget); | - |
| 684 | } | 0 |
| 685 | | - |
| 686 | | - |
| 687 | int QGLFramebufferObject::metric(PaintDeviceMetric metric) const | - |
| 688 | { | - |
| 689 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 690 | | - |
| 691 | float dpmx = qt_defaultDpiX()*100./2.54; | - |
| 692 | float dpmy = qt_defaultDpiY()*100./2.54; | - |
| 693 | int w = d->size.width(); | - |
| 694 | int h = d->size.height(); | - |
| 695 | switch (metric) { | - |
| 696 | case PdmWidth: | - |
| 697 | return w; never executed: return w; | 0 |
| 698 | | - |
| 699 | case PdmHeight: | - |
| 700 | return h; never executed: return h; | 0 |
| 701 | | - |
| 702 | case PdmWidthMM: | - |
| 703 | return qRound(w * 1000 / dpmx); never executed: return qRound(w * 1000 / dpmx); | 0 |
| 704 | | - |
| 705 | case PdmHeightMM: | - |
| 706 | return qRound(h * 1000 / dpmy); never executed: return qRound(h * 1000 / dpmy); | 0 |
| 707 | | - |
| 708 | case PdmNumColors: | - |
| 709 | return 0; never executed: return 0; | 0 |
| 710 | | - |
| 711 | case PdmDepth: | - |
| 712 | return 32; never executed: return 32; | 0 |
| 713 | | - |
| 714 | case PdmDpiX: | - |
| 715 | return qRound(dpmx * 0.0254); never executed: return qRound(dpmx * 0.0254); | 0 |
| 716 | | - |
| 717 | case PdmDpiY: | - |
| 718 | return qRound(dpmy * 0.0254); never executed: return qRound(dpmy * 0.0254); | 0 |
| 719 | | - |
| 720 | case PdmPhysicalDpiX: | - |
| 721 | return qRound(dpmx * 0.0254); never executed: return qRound(dpmx * 0.0254); | 0 |
| 722 | | - |
| 723 | case PdmPhysicalDpiY: | - |
| 724 | return qRound(dpmy * 0.0254); never executed: return qRound(dpmy * 0.0254); | 0 |
| 725 | | - |
| 726 | default: | - |
| 727 | QMessageLogger("qglframebufferobject.cpp", 1234, __PRETTY_FUNCTION__).warning("QGLFramebufferObject::metric(), Unhandled metric type: %d.\n", metric); | - |
| 728 | break; | 0 |
| 729 | } | - |
| 730 | return 0; never executed: return 0; | 0 |
| 731 | } | - |
| 732 | GLuint QGLFramebufferObject::handle() const | - |
| 733 | { | - |
| 734 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 735 | return d->fbo(); never executed: return d->fbo(); | 0 |
| 736 | } | - |
| 737 | QGLFramebufferObject::Attachment QGLFramebufferObject::attachment() const | - |
| 738 | { | - |
| 739 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 740 | if (d->valid) never evaluated: d->valid | 0 |
| 741 | return d->fbo_attachment; never executed: return d->fbo_attachment; | 0 |
| 742 | return NoAttachment; never executed: return NoAttachment; | 0 |
| 743 | } | - |
| 744 | bool QGLFramebufferObject::isBound() const | - |
| 745 | { | - |
| 746 | const QGLFramebufferObjectPrivate * const d = d_func(); | - |
| 747 | const QGLContext *current = QGLContext::currentContext(); | - |
| 748 | return current ? current->d_ptr->current_fbo == d->fbo() : false; never executed: return current ? current->d_ptr->current_fbo == d->fbo() : false; | 0 |
| 749 | } | - |
| 750 | bool QGLFramebufferObject::hasOpenGLFramebufferBlit() | - |
| 751 | { | - |
| 752 | return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit); never executed: return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit); | 0 |
| 753 | } | - |
| 754 | void QGLFramebufferObject::blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect, | - |
| 755 | QGLFramebufferObject *source, const QRect &sourceRect, | - |
| 756 | GLbitfield buffers, | - |
| 757 | GLenum filter) | - |
| 758 | { | - |
| 759 | if (!(QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit)) never evaluated: !(QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit) | 0 |
| 760 | return; | 0 |
| 761 | | - |
| 762 | const QGLContext *ctx = QGLContext::currentContext(); | - |
| 763 | if (!ctx || !ctx->contextHandle()) never evaluated: !ctx->contextHandle() | 0 |
| 764 | return; | 0 |
| 765 | | - |
| 766 | QSurface *surface = ctx->contextHandle()->surface(); | - |
| 767 | | - |
| 768 | const int height = static_cast<QWindow *>(surface)->height(); | - |
| 769 | | - |
| 770 | const int sh = source ? source->height() : height; | 0 |
| 771 | const int th = target ? target->height() : height; | 0 |
| 772 | | - |
| 773 | const int sx0 = sourceRect.left(); | - |
| 774 | const int sx1 = sourceRect.left() + sourceRect.width(); | - |
| 775 | const int sy0 = sh - (sourceRect.top() + sourceRect.height()); | - |
| 776 | const int sy1 = sh - sourceRect.top(); | - |
| 777 | | - |
| 778 | const int tx0 = targetRect.left(); | - |
| 779 | const int tx1 = targetRect.left() + targetRect.width(); | - |
| 780 | const int ty0 = th - (targetRect.top() + targetRect.height()); | - |
| 781 | const int ty1 = th - targetRect.top(); | - |
| 782 | | - |
| 783 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8CA8, source ? source->handle() : 0); | - |
| 784 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8CA9, target ? target->handle() : 0); | - |
| 785 | | - |
| 786 | QGLContextPrivate::extensionFuncs(ctx).qt_glBlitFramebufferEXT(sx0, sy0, sx1, sy1, | - |
| 787 | tx0, ty0, tx1, ty1, | - |
| 788 | buffers, filter); | - |
| 789 | | - |
| 790 | QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, ctx->d_ptr->current_fbo); | - |
| 791 | } | 0 |
| 792 | | - |
| 793 | | - |
| 794 | | - |
| | |