| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/opengl/qglframebufferobject.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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
| 0 | ||||||||||||||||||
| 10 | QGLFramebufferObjectFormatPrivate *newd | - | ||||||||||||||||||
| 11 | = new QGLFramebufferObjectFormatPrivate(d); | - | ||||||||||||||||||
| 12 | if (!d->ref.deref()
| 0 | ||||||||||||||||||
| 13 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 14 | d = newd; | - | ||||||||||||||||||
| 15 | } never executed: end of block | 0 | ||||||||||||||||||
| 16 | } never executed: end of block | 0 | ||||||||||||||||||
| 17 | QGLFramebufferObjectFormat::QGLFramebufferObjectFormat() | - | ||||||||||||||||||
| 18 | { | - | ||||||||||||||||||
| 19 | d = new QGLFramebufferObjectFormatPrivate; | - | ||||||||||||||||||
| 20 | } never executed: end of block | 0 | ||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other) | - | ||||||||||||||||||
| 27 | { | - | ||||||||||||||||||
| 28 | d = other.d; | - | ||||||||||||||||||
| 29 | d->ref.ref(); | - | ||||||||||||||||||
| 30 | } never executed: end of block | 0 | ||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | QGLFramebufferObjectFormat &QGLFramebufferObjectFormat::operator=(const QGLFramebufferObjectFormat &other) | - | ||||||||||||||||||
| 37 | { | - | ||||||||||||||||||
| 38 | if (d != other.d
| 0 | ||||||||||||||||||
| 39 | other.d->ref.ref(); | - | ||||||||||||||||||
| 40 | if (!d->ref.deref()
| 0 | ||||||||||||||||||
| 41 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 42 | d = other.d; | - | ||||||||||||||||||
| 43 | } never executed: end of block | 0 | ||||||||||||||||||
| 44 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||
| 45 | } | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat() | - | ||||||||||||||||||
| 51 | { | - | ||||||||||||||||||
| 52 | if (!d->ref.deref()
| 0 | ||||||||||||||||||
| 53 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||
| 55 | void QGLFramebufferObjectFormat::setSamples(int samples) | - | ||||||||||||||||||
| 56 | { | - | ||||||||||||||||||
| 57 | detach(); | - | ||||||||||||||||||
| 58 | d->samples = samples; | - | ||||||||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||||||||
| 60 | int QGLFramebufferObjectFormat::samples() const | - | ||||||||||||||||||
| 61 | { | - | ||||||||||||||||||
| 62 | return never executed: d->samples;return d->samples;never executed: return d->samples; | 0 | ||||||||||||||||||
| 63 | } | - | ||||||||||||||||||
| 64 | void QGLFramebufferObjectFormat::setMipmap(bool enabled) | - | ||||||||||||||||||
| 65 | { | - | ||||||||||||||||||
| 66 | detach(); | - | ||||||||||||||||||
| 67 | d->mipmap = enabled; | - | ||||||||||||||||||
| 68 | } never executed: end of block | 0 | ||||||||||||||||||
| 69 | bool QGLFramebufferObjectFormat::mipmap() const | - | ||||||||||||||||||
| 70 | { | - | ||||||||||||||||||
| 71 | return never executed: d->mipmap;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 | } never executed: end of block | 0 | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | QGLFramebufferObject::Attachment QGLFramebufferObjectFormat::attachment() const | - | ||||||||||||||||||
| 92 | { | - | ||||||||||||||||||
| 93 | return never executed: d->attachment;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 | } never executed: end of block | 0 | ||||||||||||||||||
| 107 | GLenum QGLFramebufferObjectFormat::textureTarget() const | - | ||||||||||||||||||
| 108 | { | - | ||||||||||||||||||
| 109 | return never executed: d->target;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 | } never executed: end of block | 0 | ||||||||||||||||||
| 116 | GLenum QGLFramebufferObjectFormat::internalTextureFormat() const | - | ||||||||||||||||||
| 117 | { | - | ||||||||||||||||||
| 118 | return never executed: d->internal_format;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
| 0 | ||||||||||||||||||
| 128 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 129 | else | - | ||||||||||||||||||
| 130 | return never executed: d->equals(other.d);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 never executed: !(*this == other);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
| 0 | ||||||||||||||||||
| 152 | fboFormat.setDepth(true); | - | ||||||||||||||||||
| 153 | fboFormat.setStencil(true); | - | ||||||||||||||||||
| 154 | } never executed: else if (attachment == QGLFramebufferObject::Depthend of block
| 0 | ||||||||||||||||||
| 155 | fboFormat.setDepth(true); | - | ||||||||||||||||||
| 156 | fboFormat.setStencil(false); | - | ||||||||||||||||||
| 157 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 158 | fboFormat.setDepth(false); | - | ||||||||||||||||||
| 159 | fboFormat.setStencil(false); | - | ||||||||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | GLenum format = f->format().internalTextureFormat(); | - | ||||||||||||||||||
| 163 | reqAlpha = (format != 0x1907
| 0 | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | && format != 0x8050
| 0 | ||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | && format != 0x8051
| 0 | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | ); | - | ||||||||||||||||||
| 171 | } never executed: end of block | 0 | ||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | QGLContext *QGLFBOGLPaintDevice::context() const | - | ||||||||||||||||||
| 174 | { | - | ||||||||||||||||||
| 175 | return never executed: const_cast<QGLContext *>(QGLContext::currentContext());return const_cast<QGLContext *>(QGLContext::currentContext());never executed: return const_cast<QGLContext *>(QGLContext::currentContext()); | 0 | ||||||||||||||||||
| 176 | } | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | const QGLContext *ctx = QGLContext::currentContext();; | - | ||||||||||||||||||
| 181 | if (!ctx
| 0 | ||||||||||||||||||
| 182 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 183 | GLenum status = ctx->contextHandle()->functions()->glCheckFramebufferStatus(0x8D40); | - | ||||||||||||||||||
| 184 | switch(status) { | - | ||||||||||||||||||
| 185 | case never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||
| 186 | case never executed: 0x8CD5:case 0x8CD5:never executed: case 0x8CD5: | 0 | ||||||||||||||||||
| 187 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 188 | case never executed: 0x8CDD:case 0x8CDD:never executed: case 0x8CDD: | 0 | ||||||||||||||||||
| 189 | QMessageLogger(__FILE__, 403, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Unsupported framebuffer format."); | - | ||||||||||||||||||
| 190 | break; never executed: break; | 0 | ||||||||||||||||||
| 191 | case never executed: 0x8CD6:case 0x8CD6:never executed: case 0x8CD6: | 0 | ||||||||||||||||||
| 192 | QMessageLogger(__FILE__, 406, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete attachment."); | - | ||||||||||||||||||
| 193 | break; never executed: break; | 0 | ||||||||||||||||||
| 194 | case never executed: 0x8CD7:case 0x8CD7:never executed: case 0x8CD7: | 0 | ||||||||||||||||||
| 195 | QMessageLogger(__FILE__, 409, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, missing attachment."); | - | ||||||||||||||||||
| 196 | break; never executed: break; | 0 | ||||||||||||||||||
| 197 | case never executed: 0x8CDB:case 0x8CDB:never executed: case 0x8CDB: | 0 | ||||||||||||||||||
| 198 | QMessageLogger(__FILE__, 428, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, missing draw buffer."); | - | ||||||||||||||||||
| 199 | break; never executed: break; | 0 | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | case never executed: 0x8CDC:case 0x8CDC:never executed: case 0x8CDC: | 0 | ||||||||||||||||||
| 203 | QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, missing read buffer."); | - | ||||||||||||||||||
| 204 | break; never executed: break; | 0 | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | case never executed: 0x8D56:case 0x8D56:never executed: case 0x8D56: | 0 | ||||||||||||||||||
| 208 | QMessageLogger(__FILE__, 438, __PRETTY_FUNCTION__).debug("QGLFramebufferObject: Framebuffer incomplete, attachments must have same number of samples per pixel."); | - | ||||||||||||||||||
| 209 | break; never executed: break; | 0 | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 212 | QMessageLogger(__FILE__, 442, __PRETTY_FUNCTION__).debug() <<"QGLFramebufferObject: An undefined error has occurred: "<< status; | - | ||||||||||||||||||
| 213 | break; never executed: break; | 0 | ||||||||||||||||||
| 214 | } | - | ||||||||||||||||||
| 215 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 216 | } | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | namespace | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | void freeFramebufferFunc(QGLContext *ctx, GLuint id) | - | ||||||||||||||||||
| 221 | { | - | ||||||||||||||||||
| 222 | ((!(ctx)) ? qt_assert("ctx",__FILE__,452) : qt_noop()); | - | ||||||||||||||||||
| 223 | ctx->contextHandle()->functions()->glDeleteFramebuffers(1, &id); | - | ||||||||||||||||||
| 224 | } never executed: end of block | 0 | ||||||||||||||||||
| 225 | - | |||||||||||||||||||
| 226 | void freeRenderbufferFunc(QGLContext *ctx, GLuint id) | - | ||||||||||||||||||
| 227 | { | - | ||||||||||||||||||
| 228 | ((!(ctx)) ? qt_assert("ctx",__FILE__,458) : qt_noop()); | - | ||||||||||||||||||
| 229 | ctx->contextHandle()->functions()->glDeleteRenderbuffers(1, &id); | - | ||||||||||||||||||
| 230 | } never executed: end of block | 0 | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | void freeTextureFunc(QGLContext *ctx, GLuint id) | - | ||||||||||||||||||
| 233 | { | - | ||||||||||||||||||
| 234 | (void)ctx;; | - | ||||||||||||||||||
| 235 | ctx->contextHandle()->functions()->glDeleteTextures(1, &id); | - | ||||||||||||||||||
| 236 | } never executed: end of block | 0 | ||||||||||||||||||
| 237 | } | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, | - | ||||||||||||||||||
| 240 | QGLFramebufferObject::Attachment attachment, | - | ||||||||||||||||||
| 241 | GLenum texture_target, GLenum internal_format, | - | ||||||||||||||||||
| 242 | GLint samples, bool mipmap) | - | ||||||||||||||||||
| 243 | { | - | ||||||||||||||||||
| 244 | QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | funcs.initializeOpenGLFunctions(); | - | ||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | if (!funcs.hasOpenGLFeature(QOpenGLFunctions::Framebuffers)
| 0 | ||||||||||||||||||
| 249 | return; never executed: return; | 0 | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | ctx->d_ptr->refreshCurrentFbo(); | - | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | size = sz; | - | ||||||||||||||||||
| 254 | target = texture_target; | - | ||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | { while (QOpenGLContext::currentContext()->functions()->glGetError() != 0
never executed: };end of block | 0 | ||||||||||||||||||
| 258 | GLuint fbo = 0; | - | ||||||||||||||||||
| 259 | funcs.glGenFramebuffers(1, &fbo); | - | ||||||||||||||||||
| 260 | funcs.glBindFramebuffer(0x8D40, fbo); | - | ||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | GLuint texture = 0; | - | ||||||||||||||||||
| 263 | GLuint color_buffer = 0; | - | ||||||||||||||||||
| 264 | GLuint depth_buffer = 0; | - | ||||||||||||||||||
| 265 | GLuint stencil_buffer = 0; | - | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
never executed: };end of block | 0 | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | if (samples == 0
| 0 | ||||||||||||||||||
| 270 | funcs.glGenTextures(1, &texture); | - | ||||||||||||||||||
| 271 | funcs.glBindTexture(target, texture); | - | ||||||||||||||||||
| 272 | funcs.glTexImage2D(target, 0, internal_format, size.width(), size.height(), 0, | - | ||||||||||||||||||
| 273 | 0x1908, 0x1401, __null); | - | ||||||||||||||||||
| 274 | if (mipmap
| 0 | ||||||||||||||||||
| 275 | int width = size.width(); | - | ||||||||||||||||||
| 276 | int height = size.height(); | - | ||||||||||||||||||
| 277 | int level = 0; | - | ||||||||||||||||||
| 278 | while (width > 1
| 0 | ||||||||||||||||||
| 279 | width = qMax(1, width >> 1); | - | ||||||||||||||||||
| 280 | height = qMax(1, height >> 1); | - | ||||||||||||||||||
| 281 | ++level; | - | ||||||||||||||||||
| 282 | funcs.glTexImage2D(target, level, internal_format, width, height, 0, | - | ||||||||||||||||||
| 283 | 0x1908, 0x1401, __null); | - | ||||||||||||||||||
| 284 | } never executed: end of block | 0 | ||||||||||||||||||
| 285 | } never executed: end of block | 0 | ||||||||||||||||||
| 286 | funcs.glTexParameteri(target, 0x2801, 0x2600); | - | ||||||||||||||||||
| 287 | funcs.glTexParameteri(target, 0x2800, 0x2600); | - | ||||||||||||||||||
| 288 | funcs.glTexParameteri(target, 0x2802, 0x812F); | - | ||||||||||||||||||
| 289 | funcs.glTexParameteri(target, 0x2803, 0x812F); | - | ||||||||||||||||||
| 290 | funcs.glFramebufferTexture2D(0x8D40, 0x8CE0, | - | ||||||||||||||||||
| 291 | target, texture, 0); | - | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
never executed: };end of block | 0 | ||||||||||||||||||
| 294 | valid = checkFramebufferStatus(); | - | ||||||||||||||||||
| 295 | funcs.glBindTexture(target, 0); | - | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | color_buffer = 0; | - | ||||||||||||||||||
| 298 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 299 | mipmap = false; | - | ||||||||||||||||||
| 300 | GLint maxSamples; | - | ||||||||||||||||||
| 301 | funcs.glGetIntegerv(0x8D57, &maxSamples); | - | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | samples = qBound(0, int(samples), int(maxSamples)); | - | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | funcs.glGenRenderbuffers(1, &color_buffer); | - | ||||||||||||||||||
| 306 | funcs.glBindRenderbuffer(0x8D41, color_buffer); | - | ||||||||||||||||||
| 307 | if (funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
| 0 | ||||||||||||||||||
| 308 | funcs.glRenderbufferStorageMultisample(0x8D41, samples, | - | ||||||||||||||||||
| 309 | internal_format, size.width(), size.height()); | - | ||||||||||||||||||
| 310 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 311 | samples = 0; | - | ||||||||||||||||||
| 312 | funcs.glRenderbufferStorage(0x8D41, internal_format, | - | ||||||||||||||||||
| 313 | size.width(), size.height()); | - | ||||||||||||||||||
| 314 | } never executed: end of block | 0 | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | funcs.glFramebufferRenderbuffer(0x8D40, 0x8CE0, | - | ||||||||||||||||||
| 317 | 0x8D41, color_buffer); | - | ||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
never executed: };end of block | 0 | ||||||||||||||||||
| 320 | valid = checkFramebufferStatus(); | - | ||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | if (valid
| 0 | ||||||||||||||||||
| 323 | funcs.glGetRenderbufferParameteriv(0x8D41, 0x8CAB, &samples); never executed: funcs.glGetRenderbufferParameteriv(0x8D41, 0x8CAB, &samples); | 0 | ||||||||||||||||||
| 324 | } never executed: end of block | 0 | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | if (attachment == QGLFramebufferObject::CombinedDepthStencil
| 0 | ||||||||||||||||||
| 331 | && funcs.hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil)
| 0 | ||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | funcs.glGenRenderbuffers(1, &depth_buffer); | - | ||||||||||||||||||
| 334 | funcs.glBindRenderbuffer(0x8D41, depth_buffer); | - | ||||||||||||||||||
| 335 | ((!(funcs.glIsRenderbuffer(depth_buffer))) ? qt_assert("funcs.glIsRenderbuffer(depth_buffer)",__FILE__,565) : qt_noop()); | - | ||||||||||||||||||
| 336 | if (samples != 0
| 0 | ||||||||||||||||||
| 337 | funcs.glRenderbufferStorageMultisample(0x8D41, samples, never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x88F0, size.width(), size.height()); | 0 | ||||||||||||||||||
| 338 | 0x88F0, size.width(), size.height()); never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x88F0, size.width(), size.height()); | 0 | ||||||||||||||||||
| 339 | else | - | ||||||||||||||||||
| 340 | funcs.glRenderbufferStorage(0x8D41, never executed: funcs.glRenderbufferStorage(0x8D41, 0x88F0, size.width(), size.height()); | 0 | ||||||||||||||||||
| 341 | 0x88F0, size.width(), size.height()); never executed: funcs.glRenderbufferStorage(0x8D41, 0x88F0, size.width(), size.height()); | 0 | ||||||||||||||||||
| 342 | - | |||||||||||||||||||
| 343 | stencil_buffer = depth_buffer; | - | ||||||||||||||||||
| 344 | funcs.glFramebufferRenderbuffer(0x8D40, 0x8D00, | - | ||||||||||||||||||
| 345 | 0x8D41, depth_buffer); | - | ||||||||||||||||||
| 346 | funcs.glFramebufferRenderbuffer(0x8D40, 0x8D20, | - | ||||||||||||||||||
| 347 | 0x8D41, stencil_buffer); | - | ||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | valid = checkFramebufferStatus(); | - | ||||||||||||||||||
| 350 | if (!valid
| 0 | ||||||||||||||||||
| 351 | funcs.glDeleteRenderbuffers(1, &depth_buffer); | - | ||||||||||||||||||
| 352 | stencil_buffer = depth_buffer = 0; | - | ||||||||||||||||||
| 353 | } never executed: end of block | 0 | ||||||||||||||||||
| 354 | } never executed: end of block | 0 | ||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | if (depth_buffer == 0
| 0 | ||||||||||||||||||
| 357 | || (
| 0 | ||||||||||||||||||
| 358 | { | - | ||||||||||||||||||
| 359 | funcs.glGenRenderbuffers(1, &depth_buffer); | - | ||||||||||||||||||
| 360 | funcs.glBindRenderbuffer(0x8D41, depth_buffer); | - | ||||||||||||||||||
| 361 | ((!(funcs.glIsRenderbuffer(depth_buffer))) ? qt_assert("funcs.glIsRenderbuffer(depth_buffer)",__FILE__,591) : qt_noop()); | - | ||||||||||||||||||
| 362 | if (samples != 0
| 0 | ||||||||||||||||||
| 363 | if (ctx->contextHandle()->isOpenGLES()
| 0 | ||||||||||||||||||
| 364 | if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)
| 0 | ||||||||||||||||||
| 365 | funcs.glRenderbufferStorageMultisample(0x8D41, samples, never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A6, size.width(), size.height()); | 0 | ||||||||||||||||||
| 366 | 0x81A6, size.width(), size.height()); never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A6, size.width(), size.height()); | 0 | ||||||||||||||||||
| 367 | else | - | ||||||||||||||||||
| 368 | funcs.glRenderbufferStorageMultisample(0x8D41, samples, never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A5, size.width(), size.height()); | 0 | ||||||||||||||||||
| 369 | 0x81A5, size.width(), size.height()); never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, 0x81A5, size.width(), size.height()); | 0 | ||||||||||||||||||
| 370 | } else { | - | ||||||||||||||||||
| 371 | funcs.glRenderbufferStorageMultisample(0x8D41, samples, | - | ||||||||||||||||||
| 372 | 0x1902, size.width(), size.height()); | - | ||||||||||||||||||
| 373 | } never executed: end of block | 0 | ||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | } else { | - | ||||||||||||||||||
| 376 | if (ctx->contextHandle()->isOpenGLES()
| 0 | ||||||||||||||||||
| 377 | if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)
| 0 | ||||||||||||||||||
| 378 | funcs.glRenderbufferStorage(0x8D41, 0x81A6, | - | ||||||||||||||||||
| 379 | size.width(), size.height()); | - | ||||||||||||||||||
| 380 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 381 | funcs.glRenderbufferStorage(0x8D41, 0x81A5, | - | ||||||||||||||||||
| 382 | size.width(), size.height()); | - | ||||||||||||||||||
| 383 | } never executed: end of block | 0 | ||||||||||||||||||
| 384 | } else { | - | ||||||||||||||||||
| 385 | funcs.glRenderbufferStorage(0x8D41, 0x1902, size.width(), size.height()); | - | ||||||||||||||||||
| 386 | } never executed: end of block | 0 | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | } | - | ||||||||||||||||||
| 389 | funcs.glFramebufferRenderbuffer(0x8D40, 0x8D00, | - | ||||||||||||||||||
| 390 | 0x8D41, depth_buffer); | - | ||||||||||||||||||
| 391 | valid = checkFramebufferStatus(); | - | ||||||||||||||||||
| 392 | if (!valid
| 0 | ||||||||||||||||||
| 393 | funcs.glDeleteRenderbuffers(1, &depth_buffer); | - | ||||||||||||||||||
| 394 | depth_buffer = 0; | - | ||||||||||||||||||
| 395 | } never executed: end of block | 0 | ||||||||||||||||||
| 396 | } never executed: end of block | 0 | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | if (stencil_buffer == 0
| 0 | ||||||||||||||||||
| 399 | funcs.glGenRenderbuffers(1, &stencil_buffer); | - | ||||||||||||||||||
| 400 | funcs.glBindRenderbuffer(0x8D41, stencil_buffer); | - | ||||||||||||||||||
| 401 | ((!(funcs.glIsRenderbuffer(stencil_buffer))) ? qt_assert("funcs.glIsRenderbuffer(stencil_buffer)",__FILE__,649) : qt_noop()); | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | - | |||||||||||||||||||
| 404 | - | |||||||||||||||||||
| 405 | - | |||||||||||||||||||
| 406 | GLenum storage = ctx->contextHandle()->isOpenGLES()
| 0 | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | if (samples != 0
| 0 | ||||||||||||||||||
| 410 | funcs.glRenderbufferStorageMultisample(0x8D41, samples, storage, size.width(), size.height()); never executed: funcs.glRenderbufferStorageMultisample(0x8D41, samples, storage, size.width(), size.height()); | 0 | ||||||||||||||||||
| 411 | else | - | ||||||||||||||||||
| 412 | funcs.glRenderbufferStorage(0x8D41, storage, size.width(), size.height()); never executed: funcs.glRenderbufferStorage(0x8D41, storage, size.width(), size.height()); | 0 | ||||||||||||||||||
| 413 | - | |||||||||||||||||||
| 414 | funcs.glFramebufferRenderbuffer(0x8D40, 0x8D20, | - | ||||||||||||||||||
| 415 | 0x8D41, stencil_buffer); | - | ||||||||||||||||||
| 416 | valid = checkFramebufferStatus(); | - | ||||||||||||||||||
| 417 | if (!valid
| 0 | ||||||||||||||||||
| 418 | funcs.glDeleteRenderbuffers(1, &stencil_buffer); | - | ||||||||||||||||||
| 419 | stencil_buffer = 0; | - | ||||||||||||||||||
| 420 | } never executed: end of block | 0 | ||||||||||||||||||
| 421 | } never executed: end of block | 0 | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | valid = checkFramebufferStatus(); | - | ||||||||||||||||||
| 425 | - | |||||||||||||||||||
| 426 | if (depth_buffer
| 0 | ||||||||||||||||||
| 427 | fbo_attachment = QGLFramebufferObject::CombinedDepthStencil; | - | ||||||||||||||||||
| 428 | } never executed: else if (depth_bufferend of block
| 0 | ||||||||||||||||||
| 429 | fbo_attachment = QGLFramebufferObject::Depth; | - | ||||||||||||||||||
| 430 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 431 | fbo_attachment = QGLFramebufferObject::NoAttachment; | - | ||||||||||||||||||
| 432 | } never executed: end of block | 0 | ||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | funcs.glBindFramebuffer(0x8D40, ctx->d_ptr->current_fbo); | - | ||||||||||||||||||
| 435 | if (valid
| 0 | ||||||||||||||||||
| 436 | fbo_guard = createSharedResourceGuard(ctx, fbo, freeFramebufferFunc); | - | ||||||||||||||||||
| 437 | if (color_buffer
| 0 | ||||||||||||||||||
| 438 | color_buffer_guard = createSharedResourceGuard(ctx, color_buffer, freeRenderbufferFunc); never executed: color_buffer_guard = createSharedResourceGuard(ctx, color_buffer, freeRenderbufferFunc); | 0 | ||||||||||||||||||
| 439 | else | - | ||||||||||||||||||
| 440 | texture_guard = createSharedResourceGuard(ctx, texture, freeTextureFunc); never executed: texture_guard = createSharedResourceGuard(ctx, texture, freeTextureFunc); | 0 | ||||||||||||||||||
| 441 | if (depth_buffer
| 0 | ||||||||||||||||||
| 442 | depth_buffer_guard = createSharedResourceGuard(ctx, depth_buffer, freeRenderbufferFunc); never executed: depth_buffer_guard = createSharedResourceGuard(ctx, depth_buffer, freeRenderbufferFunc); | 0 | ||||||||||||||||||
| 443 | if (stencil_buffer
| 0 | ||||||||||||||||||
| 444 | if (stencil_buffer == depth_buffer
| 0 | ||||||||||||||||||
| 445 | stencil_buffer_guard = depth_buffer_guard; never executed: stencil_buffer_guard = depth_buffer_guard; | 0 | ||||||||||||||||||
| 446 | else | - | ||||||||||||||||||
| 447 | stencil_buffer_guard = createSharedResourceGuard(ctx, stencil_buffer, freeRenderbufferFunc); never executed: stencil_buffer_guard = createSharedResourceGuard(ctx, stencil_buffer, freeRenderbufferFunc); | 0 | ||||||||||||||||||
| 448 | } | - | ||||||||||||||||||
| 449 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 450 | if (color_buffer
| 0 | ||||||||||||||||||
| 451 | funcs.glDeleteRenderbuffers(1, &color_buffer); never executed: funcs.glDeleteRenderbuffers(1, &color_buffer); | 0 | ||||||||||||||||||
| 452 | else | - | ||||||||||||||||||
| 453 | funcs.glDeleteTextures(1, &texture); never executed: funcs.glDeleteTextures(1, &texture); | 0 | ||||||||||||||||||
| 454 | if (depth_buffer
| 0 | ||||||||||||||||||
| 455 | funcs.glDeleteRenderbuffers(1, &depth_buffer); never executed: funcs.glDeleteRenderbuffers(1, &depth_buffer); | 0 | ||||||||||||||||||
| 456 | if (stencil_buffer
| 0 | ||||||||||||||||||
| 457 | funcs.glDeleteRenderbuffers(1, &stencil_buffer); never executed: funcs.glDeleteRenderbuffers(1, &stencil_buffer); | 0 | ||||||||||||||||||
| 458 | funcs.glDeleteFramebuffers(1, &fbo); | - | ||||||||||||||||||
| 459 | } never executed: end of block | 0 | ||||||||||||||||||
| 460 | { GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); if (err != 0
never executed: };end of block | 0 | ||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | format.setTextureTarget(target); | - | ||||||||||||||||||
| 463 | format.setSamples(int(samples)); | - | ||||||||||||||||||
| 464 | format.setAttachment(fbo_attachment); | - | ||||||||||||||||||
| 465 | format.setInternalTextureFormat(internal_format); | - | ||||||||||||||||||
| 466 | format.setMipmap(mipmap); | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | glDevice.setFBO(q, attachment); | - | ||||||||||||||||||
| 469 | } never executed: end of block | 0 | ||||||||||||||||||
| 470 | QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target) | - | ||||||||||||||||||
| 471 | : d_ptr(new QGLFramebufferObjectPrivate) | - | ||||||||||||||||||
| 472 | { | - | ||||||||||||||||||
| 473 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 474 | d->init(this, size, NoAttachment, target, | - | ||||||||||||||||||
| 475 | - | |||||||||||||||||||
| 476 | QOpenGLContext::currentContext()->isOpenGLES() ? 0x1908 : 0x8058 | - | ||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | - | |||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | ); | - | ||||||||||||||||||
| 481 | } never executed: end of block | 0 | ||||||||||||||||||
| 482 | QGLFramebufferObject::QGLFramebufferObject(int width, int height, GLenum target) | - | ||||||||||||||||||
| 483 | : d_ptr(new QGLFramebufferObjectPrivate) | - | ||||||||||||||||||
| 484 | { | - | ||||||||||||||||||
| 485 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 486 | d->init(this, QSize(width, height), NoAttachment, target, | - | ||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 | QOpenGLContext::currentContext()->isOpenGLES() ? 0x1908 : 0x8058 | - | ||||||||||||||||||
| 489 | - | |||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | - | |||||||||||||||||||
| 492 | ); | - | ||||||||||||||||||
| 493 | } never executed: end of block | 0 | ||||||||||||||||||
| 494 | - | |||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | - | |||||||||||||||||||
| 497 | - | |||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebufferObjectFormat &format) | - | ||||||||||||||||||
| 502 | : d_ptr(new QGLFramebufferObjectPrivate) | - | ||||||||||||||||||
| 503 | { | - | ||||||||||||||||||
| 504 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 505 | d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), | - | ||||||||||||||||||
| 506 | format.samples(), format.mipmap()); | - | ||||||||||||||||||
| 507 | } never executed: end of block | 0 | ||||||||||||||||||
| 508 | - | |||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | - | |||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | - | |||||||||||||||||||
| 515 | QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFramebufferObjectFormat &format) | - | ||||||||||||||||||
| 516 | : d_ptr(new QGLFramebufferObjectPrivate) | - | ||||||||||||||||||
| 517 | { | - | ||||||||||||||||||
| 518 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 519 | d->init(this, QSize(width, height), format.attachment(), format.textureTarget(), | - | ||||||||||||||||||
| 520 | format.internalTextureFormat(), format.samples(), format.mipmap()); | - | ||||||||||||||||||
| 521 | } never executed: end of block | 0 | ||||||||||||||||||
| 522 | QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment attachment, | - | ||||||||||||||||||
| 523 | GLenum target, GLenum internal_format) | - | ||||||||||||||||||
| 524 | : d_ptr(new QGLFramebufferObjectPrivate) | - | ||||||||||||||||||
| 525 | { | - | ||||||||||||||||||
| 526 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 527 | if (!internal_format
| 0 | ||||||||||||||||||
| 528 | - | |||||||||||||||||||
| 529 | - | |||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | internal_format = QOpenGLContext::currentContext()->isOpenGLES()
never executed: internal_format = QOpenGLContext::currentContext()->isOpenGLES() ? 0x1908 : 0x8058; | 0 | ||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | d->init(this, QSize(width, height), attachment, target, internal_format); | - | ||||||||||||||||||
| 534 | } never executed: end of block | 0 | ||||||||||||||||||
| 535 | QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachment, | - | ||||||||||||||||||
| 536 | GLenum target, GLenum internal_format) | - | ||||||||||||||||||
| 537 | : d_ptr(new QGLFramebufferObjectPrivate) | - | ||||||||||||||||||
| 538 | { | - | ||||||||||||||||||
| 539 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 540 | if (!internal_format
| 0 | ||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | - | |||||||||||||||||||
| 543 | - | |||||||||||||||||||
| 544 | internal_format = QOpenGLContext::currentContext()->isOpenGLES()
never executed: internal_format = QOpenGLContext::currentContext()->isOpenGLES() ? 0x1908 : 0x8058; | 0 | ||||||||||||||||||
| 545 | - | |||||||||||||||||||
| 546 | d->init(this, size, attachment, target, internal_format); | - | ||||||||||||||||||
| 547 | } never executed: end of block | 0 | ||||||||||||||||||
| 548 | - | |||||||||||||||||||
| 549 | - | |||||||||||||||||||
| 550 | - | |||||||||||||||||||
| 551 | - | |||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | - | |||||||||||||||||||
| 554 | QGLFramebufferObject::~QGLFramebufferObject() | - | ||||||||||||||||||
| 555 | { | - | ||||||||||||||||||
| 556 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 557 | - | |||||||||||||||||||
| 558 | delete d->engine; | - | ||||||||||||||||||
| 559 | - | |||||||||||||||||||
| 560 | if (d->texture_guard
| 0 | ||||||||||||||||||
| 561 | d->texture_guard->free(); never executed: d->texture_guard->free(); | 0 | ||||||||||||||||||
| 562 | if (d->color_buffer_guard
| 0 | ||||||||||||||||||
| 563 | d->color_buffer_guard->free(); never executed: d->color_buffer_guard->free(); | 0 | ||||||||||||||||||
| 564 | if (d->depth_buffer_guard
| 0 | ||||||||||||||||||
| 565 | d->depth_buffer_guard->free(); never executed: d->depth_buffer_guard->free(); | 0 | ||||||||||||||||||
| 566 | if (d->stencil_buffer_guard
| 0 | ||||||||||||||||||
| 567 | d->stencil_buffer_guard->free(); never executed: d->stencil_buffer_guard->free(); | 0 | ||||||||||||||||||
| 568 | if (d->fbo_guard
| 0 | ||||||||||||||||||
| 569 | d->fbo_guard->free(); never executed: d->fbo_guard->free(); | 0 | ||||||||||||||||||
| 570 | } never executed: end of block | 0 | ||||||||||||||||||
| 571 | bool QGLFramebufferObject::isValid() const | - | ||||||||||||||||||
| 572 | { | - | ||||||||||||||||||
| 573 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 574 | return never executed: d->valid && d->fbo_guard && d->fbo_guard->id();return d->valid && d->fbo_guard && d->fbo_guard->id();never executed: return d->valid && d->fbo_guard && d->fbo_guard->id(); | 0 | ||||||||||||||||||
| 575 | } | - | ||||||||||||||||||
| 576 | bool QGLFramebufferObject::bind() | - | ||||||||||||||||||
| 577 | { | - | ||||||||||||||||||
| 578 | if (!isValid()
| 0 | ||||||||||||||||||
| 579 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 580 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 581 | const QGLContext *ctx = QGLContext::currentContext();; | - | ||||||||||||||||||
| 582 | if (!ctx
| 0 | ||||||||||||||||||
| 583 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 584 | const QGLContext *current = QGLContext::currentContext(); | - | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | if (!current
| 0 | ||||||||||||||||||
| 587 | QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)
| 0 | ||||||||||||||||||
| 588 | { | - | ||||||||||||||||||
| 589 | QMessageLogger(__FILE__, 1032, __PRETTY_FUNCTION__).warning("QGLFramebufferObject::bind() called from incompatible context"); | - | ||||||||||||||||||
| 590 | } never executed: end of block | 0 | ||||||||||||||||||
| 591 | - | |||||||||||||||||||
| 592 | d->funcs.glBindFramebuffer(0x8D40, d->fbo()); | - | ||||||||||||||||||
| 593 | d->valid = d->checkFramebufferStatus(); | - | ||||||||||||||||||
| 594 | if (d->valid
| 0 | ||||||||||||||||||
| 595 | current->d_ptr->setCurrentFbo(d->fbo()); never executed: current->d_ptr->setCurrentFbo(d->fbo()); | 0 | ||||||||||||||||||
| 596 | return never executed: d->valid;return d->valid;never executed: return d->valid; | 0 | ||||||||||||||||||
| 597 | } | - | ||||||||||||||||||
| 598 | bool QGLFramebufferObject::release() | - | ||||||||||||||||||
| 599 | { | - | ||||||||||||||||||
| 600 | if (!isValid()
| 0 | ||||||||||||||||||
| 601 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 602 | QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 603 | const QGLContext *ctx = QGLContext::currentContext();; | - | ||||||||||||||||||
| 604 | if (!ctx
| 0 | ||||||||||||||||||
| 605 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 | const QGLContext *current = QGLContext::currentContext(); | - | ||||||||||||||||||
| 608 | - | |||||||||||||||||||
| 609 | - | |||||||||||||||||||
| 610 | if (!current
| 0 | ||||||||||||||||||
| 611 | QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)
| 0 | ||||||||||||||||||
| 612 | { | - | ||||||||||||||||||
| 613 | QMessageLogger(__FILE__, 1066, __PRETTY_FUNCTION__).warning("QGLFramebufferObject::release() called from incompatible context"); | - | ||||||||||||||||||
| 614 | } never executed: end of block | 0 | ||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | - | |||||||||||||||||||
| 617 | if (current
| 0 | ||||||||||||||||||
| 618 | current->d_ptr->setCurrentFbo(current->d_ptr->default_fbo); | - | ||||||||||||||||||
| 619 | d->funcs.glBindFramebuffer(0x8D40, current->d_ptr->default_fbo); | - | ||||||||||||||||||
| 620 | } never executed: end of block | 0 | ||||||||||||||||||
| 621 | - | |||||||||||||||||||
| 622 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 623 | } | - | ||||||||||||||||||
| 624 | GLuint QGLFramebufferObject::texture() const | - | ||||||||||||||||||
| 625 | { | - | ||||||||||||||||||
| 626 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 627 | return never executed: d->texture_guard ? d->texture_guard->id() : 0;return d->texture_guard ? d->texture_guard->id() : 0;never executed: return d->texture_guard ? d->texture_guard->id() : 0; | 0 | ||||||||||||||||||
| 628 | } | - | ||||||||||||||||||
| 629 | - | |||||||||||||||||||
| 630 | - | |||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | - | |||||||||||||||||||
| 633 | - | |||||||||||||||||||
| 634 | - | |||||||||||||||||||
| 635 | - | |||||||||||||||||||
| 636 | QSize QGLFramebufferObject::size() const | - | ||||||||||||||||||
| 637 | { | - | ||||||||||||||||||
| 638 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 639 | return never executed: d->size;return d->size;never executed: return d->size; | 0 | ||||||||||||||||||
| 640 | } | - | ||||||||||||||||||
| 641 | - | |||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | - | |||||||||||||||||||
| 644 | - | |||||||||||||||||||
| 645 | QGLFramebufferObjectFormat QGLFramebufferObject::format() const | - | ||||||||||||||||||
| 646 | { | - | ||||||||||||||||||
| 647 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 648 | return never executed: d->format;return d->format;never executed: return d->format; | 0 | ||||||||||||||||||
| 649 | } | - | ||||||||||||||||||
| 650 | QImage QGLFramebufferObject::toImage() const | - | ||||||||||||||||||
| 651 | { | - | ||||||||||||||||||
| 652 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 653 | if (!d->valid
| 0 | ||||||||||||||||||
| 654 | return never executed: QImage();return QImage();never executed: return QImage(); | 0 | ||||||||||||||||||
| 655 | - | |||||||||||||||||||
| 656 | - | |||||||||||||||||||
| 657 | if (format().samples() != 0
| 0 | ||||||||||||||||||
| 658 | QGLFramebufferObject temp(size(), QGLFramebufferObjectFormat()); | - | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | QRect rect(QPoint(0, 0), size()); | - | ||||||||||||||||||
| 661 | blitFramebuffer(&temp, rect, const_cast<QGLFramebufferObject *>(this), rect); | - | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | return never executed: temp.toImage();return temp.toImage();never executed: return temp.toImage(); | 0 | ||||||||||||||||||
| 664 | } | - | ||||||||||||||||||
| 665 | - | |||||||||||||||||||
| 666 | bool wasBound = isBound(); | - | ||||||||||||||||||
| 667 | if (!wasBound
| 0 | ||||||||||||||||||
| 668 | const_cast< never executed: QGLFramebufferObject *>(this)->bind();const_cast<QGLFramebufferObject *>(this)->bind();never executed: const_cast<QGLFramebufferObject *>(this)->bind(); | 0 | ||||||||||||||||||
| 669 | QImage image = qt_gl_read_frame_buffer(d->size, format().internalTextureFormat() != 0x1907, true); | - | ||||||||||||||||||
| 670 | if (!wasBound
| 0 | ||||||||||||||||||
| 671 | const_cast< never executed: QGLFramebufferObject *>(this)->release();const_cast<QGLFramebufferObject *>(this)->release();never executed: const_cast<QGLFramebufferObject *>(this)->release(); | 0 | ||||||||||||||||||
| 672 | - | |||||||||||||||||||
| 673 | return never executed: image;return image;never executed: return image; | 0 | ||||||||||||||||||
| 674 | } | - | ||||||||||||||||||
| 675 | - | |||||||||||||||||||
| 676 | namespace { namespace Q_QGS_qt_buffer_2_engine { typedef QGLEngineThreadStorage<QGL2PaintEngineEx> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QGLEngineThreadStorage<QGL2PaintEngineEx>, Q_QGS_qt_buffer_2_engine::innerFunction, Q_QGS_qt_buffer_2_engine::guard> qt_buffer_2_engine;return &holder.value; | 0 | ||||||||||||||||||
| 677 | - | |||||||||||||||||||
| 678 | - | |||||||||||||||||||
| 679 | QPaintEngine *QGLFramebufferObject::paintEngine() const | - | ||||||||||||||||||
| 680 | { | - | ||||||||||||||||||
| 681 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 682 | if (d->engine
| 0 | ||||||||||||||||||
| 683 | return never executed: d->engine;return d->engine;never executed: return d->engine; | 0 | ||||||||||||||||||
| 684 | - | |||||||||||||||||||
| 685 | QPaintEngine *engine = qt_buffer_2_engine()->engine(); | - | ||||||||||||||||||
| 686 | if (engine->isActive()
| 0 | ||||||||||||||||||
| 687 | d->engine = new QGL2PaintEngineEx; | - | ||||||||||||||||||
| 688 | return never executed: d->engine;return d->engine;never executed: return d->engine; | 0 | ||||||||||||||||||
| 689 | } | - | ||||||||||||||||||
| 690 | return never executed: engine;return engine;never executed: return engine; | 0 | ||||||||||||||||||
| 691 | } | - | ||||||||||||||||||
| 692 | bool QGLFramebufferObject::bindDefault() | - | ||||||||||||||||||
| 693 | { | - | ||||||||||||||||||
| 694 | QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); | - | ||||||||||||||||||
| 695 | - | |||||||||||||||||||
| 696 | if (ctx
| 0 | ||||||||||||||||||
| 697 | QOpenGLFunctions functions(ctx->contextHandle()); | - | ||||||||||||||||||
| 698 | if (!functions.hasOpenGLFeature(QOpenGLFunctions::Framebuffers)
| 0 | ||||||||||||||||||
| 699 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 700 | - | |||||||||||||||||||
| 701 | ctx->d_ptr->setCurrentFbo(ctx->d_ptr->default_fbo); | - | ||||||||||||||||||
| 702 | functions.glBindFramebuffer(0x8D40, ctx->d_ptr->default_fbo); | - | ||||||||||||||||||
| 703 | - | |||||||||||||||||||
| 704 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 705 | QMessageLogger(__FILE__, 1202, __PRETTY_FUNCTION__).warning("QGLFramebufferObject::bindDefault() called without current context."); | - | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | } never executed: end of block | 0 | ||||||||||||||||||
| 708 | - | |||||||||||||||||||
| 709 | return never executed: ctx != 0;return ctx != 0;never executed: return ctx != 0; | 0 | ||||||||||||||||||
| 710 | } | - | ||||||||||||||||||
| 711 | - | |||||||||||||||||||
| 712 | - | |||||||||||||||||||
| 713 | - | |||||||||||||||||||
| 714 | - | |||||||||||||||||||
| 715 | - | |||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | bool QGLFramebufferObject::hasOpenGLFramebufferObjects() | - | ||||||||||||||||||
| 719 | { | - | ||||||||||||||||||
| 720 | return never executed: qgl_hasFeature(QOpenGLFunctions::Framebuffers);return qgl_hasFeature(QOpenGLFunctions::Framebuffers);never executed: return qgl_hasFeature(QOpenGLFunctions::Framebuffers); | 0 | ||||||||||||||||||
| 721 | } | - | ||||||||||||||||||
| 722 | void QGLFramebufferObject::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) | - | ||||||||||||||||||
| 723 | { | - | ||||||||||||||||||
| 724 | const_cast<QGLContext *>(QGLContext::currentContext())->drawTexture(target, textureId, textureTarget); | - | ||||||||||||||||||
| 725 | } never executed: end of block | 0 | ||||||||||||||||||
| 726 | void QGLFramebufferObject::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) | - | ||||||||||||||||||
| 727 | { | - | ||||||||||||||||||
| 728 | const_cast<QGLContext *>(QGLContext::currentContext())->drawTexture(point, textureId, textureTarget); | - | ||||||||||||||||||
| 729 | } never executed: end of block | 0 | ||||||||||||||||||
| 730 | - | |||||||||||||||||||
| 731 | - | |||||||||||||||||||
| 732 | int QGLFramebufferObject::metric(PaintDeviceMetric metric) const | - | ||||||||||||||||||
| 733 | { | - | ||||||||||||||||||
| 734 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 735 | - | |||||||||||||||||||
| 736 | float dpmx = qt_defaultDpiX()*100./2.54; | - | ||||||||||||||||||
| 737 | float dpmy = qt_defaultDpiY()*100./2.54; | - | ||||||||||||||||||
| 738 | int w = d->size.width(); | - | ||||||||||||||||||
| 739 | int h = d->size.height(); | - | ||||||||||||||||||
| 740 | switch (metric) { | - | ||||||||||||||||||
| 741 | case never executed: PdmWidth:case PdmWidth:never executed: case PdmWidth: | 0 | ||||||||||||||||||
| 742 | return never executed: w;return w;never executed: return w; | 0 | ||||||||||||||||||
| 743 | - | |||||||||||||||||||
| 744 | case never executed: PdmHeight:case PdmHeight:never executed: case PdmHeight: | 0 | ||||||||||||||||||
| 745 | return never executed: h;return h;never executed: return h; | 0 | ||||||||||||||||||
| 746 | - | |||||||||||||||||||
| 747 | case never executed: PdmWidthMM:case PdmWidthMM:never executed: case PdmWidthMM: | 0 | ||||||||||||||||||
| 748 | return never executed: qRound(w * 1000 / dpmx);return qRound(w * 1000 / dpmx);never executed: return qRound(w * 1000 / dpmx); | 0 | ||||||||||||||||||
| 749 | - | |||||||||||||||||||
| 750 | case never executed: PdmHeightMM:case PdmHeightMM:never executed: case PdmHeightMM: | 0 | ||||||||||||||||||
| 751 | return never executed: qRound(h * 1000 / dpmy);return qRound(h * 1000 / dpmy);never executed: return qRound(h * 1000 / dpmy); | 0 | ||||||||||||||||||
| 752 | - | |||||||||||||||||||
| 753 | case never executed: PdmNumColors:case PdmNumColors:never executed: case PdmNumColors: | 0 | ||||||||||||||||||
| 754 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 755 | - | |||||||||||||||||||
| 756 | case never executed: PdmDepth:case PdmDepth:never executed: case PdmDepth: | 0 | ||||||||||||||||||
| 757 | return never executed: 32;return 32;never executed: return 32; | 0 | ||||||||||||||||||
| 758 | - | |||||||||||||||||||
| 759 | case never executed: PdmDpiX:case PdmDpiX:never executed: case PdmDpiX: | 0 | ||||||||||||||||||
| 760 | return never executed: qRound(dpmx * 0.0254);return qRound(dpmx * 0.0254);never executed: return qRound(dpmx * 0.0254); | 0 | ||||||||||||||||||
| 761 | - | |||||||||||||||||||
| 762 | case never executed: PdmDpiY:case PdmDpiY:never executed: case PdmDpiY: | 0 | ||||||||||||||||||
| 763 | return never executed: qRound(dpmy * 0.0254);return qRound(dpmy * 0.0254);never executed: return qRound(dpmy * 0.0254); | 0 | ||||||||||||||||||
| 764 | - | |||||||||||||||||||
| 765 | case never executed: PdmPhysicalDpiX:case PdmPhysicalDpiX:never executed: case PdmPhysicalDpiX: | 0 | ||||||||||||||||||
| 766 | return never executed: qRound(dpmx * 0.0254);return qRound(dpmx * 0.0254);never executed: return qRound(dpmx * 0.0254); | 0 | ||||||||||||||||||
| 767 | - | |||||||||||||||||||
| 768 | case never executed: PdmPhysicalDpiY:case PdmPhysicalDpiY:never executed: case PdmPhysicalDpiY: | 0 | ||||||||||||||||||
| 769 | return never executed: qRound(dpmy * 0.0254);return qRound(dpmy * 0.0254);never executed: return qRound(dpmy * 0.0254); | 0 | ||||||||||||||||||
| 770 | - | |||||||||||||||||||
| 771 | case never executed: QPaintDevice::PdmDevicePixelRatio:case QPaintDevice::PdmDevicePixelRatio:never executed: case QPaintDevice::PdmDevicePixelRatio: | 0 | ||||||||||||||||||
| 772 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 773 | - | |||||||||||||||||||
| 774 | case never executed: QPaintDevice::PdmDevicePixelRatioScaled:case QPaintDevice::PdmDevicePixelRatioScaled:never executed: case QPaintDevice::PdmDevicePixelRatioScaled: | 0 | ||||||||||||||||||
| 775 | return never executed: 1 * QPaintDevice::devicePixelRatioFScale();return 1 * QPaintDevice::devicePixelRatioFScale();never executed: return 1 * QPaintDevice::devicePixelRatioFScale(); | 0 | ||||||||||||||||||
| 776 | - | |||||||||||||||||||
| 777 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 778 | QMessageLogger(__FILE__, 1298, __PRETTY_FUNCTION__).warning("QGLFramebufferObject::metric(), Unhandled metric type: %d.\n", metric); | - | ||||||||||||||||||
| 779 | break; never executed: break; | 0 | ||||||||||||||||||
| 780 | } | - | ||||||||||||||||||
| 781 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 782 | } | - | ||||||||||||||||||
| 783 | GLuint QGLFramebufferObject::handle() const | - | ||||||||||||||||||
| 784 | { | - | ||||||||||||||||||
| 785 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 786 | return never executed: d->fbo();return d->fbo();never executed: return d->fbo(); | 0 | ||||||||||||||||||
| 787 | } | - | ||||||||||||||||||
| 788 | QGLFramebufferObject::Attachment QGLFramebufferObject::attachment() const | - | ||||||||||||||||||
| 789 | { | - | ||||||||||||||||||
| 790 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 791 | if (d->valid
| 0 | ||||||||||||||||||
| 792 | return never executed: d->fbo_attachment;return d->fbo_attachment;never executed: return d->fbo_attachment; | 0 | ||||||||||||||||||
| 793 | return never executed: NoAttachment;return NoAttachment;never executed: return NoAttachment; | 0 | ||||||||||||||||||
| 794 | } | - | ||||||||||||||||||
| 795 | bool QGLFramebufferObject::isBound() const | - | ||||||||||||||||||
| 796 | { | - | ||||||||||||||||||
| 797 | const QGLFramebufferObjectPrivate * const d = d_func(); | - | ||||||||||||||||||
| 798 | const QGLContext *current = QGLContext::currentContext(); | - | ||||||||||||||||||
| 799 | if (current
| 0 | ||||||||||||||||||
| 800 | current->d_ptr->refreshCurrentFbo(); | - | ||||||||||||||||||
| 801 | return never executed: current->d_ptr->current_fbo == d->fbo();return current->d_ptr->current_fbo == d->fbo();never executed: return current->d_ptr->current_fbo == d->fbo(); | 0 | ||||||||||||||||||
| 802 | } | - | ||||||||||||||||||
| 803 | - | |||||||||||||||||||
| 804 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 805 | } | - | ||||||||||||||||||
| 806 | bool QGLFramebufferObject::hasOpenGLFramebufferBlit() | - | ||||||||||||||||||
| 807 | { | - | ||||||||||||||||||
| 808 | return never executed: QOpenGLExtensions(QOpenGLContext::currentContext()).hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);return QOpenGLExtensions(QOpenGLContext::currentContext()).hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);never executed: return QOpenGLExtensions(QOpenGLContext::currentContext()).hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit); | 0 | ||||||||||||||||||
| 809 | } | - | ||||||||||||||||||
| 810 | void QGLFramebufferObject::blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect, | - | ||||||||||||||||||
| 811 | QGLFramebufferObject *source, const QRect &sourceRect, | - | ||||||||||||||||||
| 812 | GLbitfield buffers, | - | ||||||||||||||||||
| 813 | GLenum filter) | - | ||||||||||||||||||
| 814 | { | - | ||||||||||||||||||
| 815 | const QGLContext *ctx = QGLContext::currentContext(); | - | ||||||||||||||||||
| 816 | if (!ctx
| 0 | ||||||||||||||||||
| 817 | return; never executed: return; | 0 | ||||||||||||||||||
| 818 | - | |||||||||||||||||||
| 819 | QOpenGLExtensions functions(ctx->contextHandle()); | - | ||||||||||||||||||
| 820 | if (!functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)
| 0 | ||||||||||||||||||
| 821 | return; never executed: return; | 0 | ||||||||||||||||||
| 822 | - | |||||||||||||||||||
| 823 | QSurface *surface = ctx->contextHandle()->surface(); | - | ||||||||||||||||||
| 824 | - | |||||||||||||||||||
| 825 | const int height = static_cast<QWindow *>(surface)->height(); | - | ||||||||||||||||||
| 826 | - | |||||||||||||||||||
| 827 | const int sh = source
| 0 | ||||||||||||||||||
| 828 | const int th = target
| 0 | ||||||||||||||||||
| 829 | - | |||||||||||||||||||
| 830 | const int sx0 = sourceRect.left(); | - | ||||||||||||||||||
| 831 | const int sx1 = sourceRect.left() + sourceRect.width(); | - | ||||||||||||||||||
| 832 | const int sy0 = sh - (sourceRect.top() + sourceRect.height()); | - | ||||||||||||||||||
| 833 | const int sy1 = sh - sourceRect.top(); | - | ||||||||||||||||||
| 834 | - | |||||||||||||||||||
| 835 | const int tx0 = targetRect.left(); | - | ||||||||||||||||||
| 836 | const int tx1 = targetRect.left() + targetRect.width(); | - | ||||||||||||||||||
| 837 | const int ty0 = th - (targetRect.top() + targetRect.height()); | - | ||||||||||||||||||
| 838 | const int ty1 = th - targetRect.top(); | - | ||||||||||||||||||
| 839 | - | |||||||||||||||||||
| 840 | ctx->d_ptr->refreshCurrentFbo(); | - | ||||||||||||||||||
| 841 | - | |||||||||||||||||||
| 842 | functions.glBindFramebuffer(0x8CA8, source ? source->handle() : 0); | - | ||||||||||||||||||
| 843 | functions.glBindFramebuffer(0x8CA9, target ? target->handle() : 0); | - | ||||||||||||||||||
| 844 | - | |||||||||||||||||||
| 845 | functions.glBlitFramebuffer(sx0, sy0, sx1, sy1, | - | ||||||||||||||||||
| 846 | tx0, ty0, tx1, ty1, | - | ||||||||||||||||||
| 847 | buffers, filter); | - | ||||||||||||||||||
| 848 | - | |||||||||||||||||||
| 849 | functions.glBindFramebuffer(0x8D40, ctx->d_ptr->current_fbo); | - | ||||||||||||||||||
| 850 | } never executed: end of block | 0 | ||||||||||||||||||
| 851 | - | |||||||||||||||||||
| 852 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |