From 0681e603803634f89f72b37b216b91cab2e085d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Fri, 5 Aug 2016 10:51:49 +0100 Subject: Cache the current QOpenGLFramebufferObject This doesn't cover FBOs bound directly with glBindFramebuffer(), but it's perfect to create a fast path for code we know uses QOGLFBO, thus avoiding expensive glGetIntegerv() driver calls. The use case is to use this in QSG24BitTextMaskShader::activate(), where we need to check if the current FBO is sRGB capable. Change-Id: I434eeeb7e6a3d16be9327315536ad7280245085d Reviewed-by: Laszlo Agocs Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglframebufferobject.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui/opengl/qopenglframebufferobject.cpp') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 6fc18b1d01..1ee90a0827 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1068,6 +1068,7 @@ bool QOpenGLFramebufferObject::bind() d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, d->fbo()); QOpenGLContextPrivate::get(current)->qgl_current_fbo_invalid = true; + QOpenGLContextPrivate::get(current)->qgl_current_fbo = this; if (d->format.samples() == 0) { // Create new textures to replace the ones stolen via takeTexture(). @@ -1107,7 +1108,9 @@ bool QOpenGLFramebufferObject::release() if (current) { d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, current->defaultFramebufferObject()); - QOpenGLContextPrivate::get(current)->qgl_current_fbo_invalid = true; + QOpenGLContextPrivate *contextPrv = QOpenGLContextPrivate::get(current); + contextPrv->qgl_current_fbo_invalid = true; + contextPrv->qgl_current_fbo = Q_NULLPTR; } return true; -- cgit v1.2.3