aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultlayer.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-07-15 21:08:50 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-07-15 21:08:50 +0200
commitf23ad9d576267676066da7f6c2c9b1743de9fae4 (patch)
tree03147f35bc21f07d818feddfa8f25159b6c40c5b /src/quick/scenegraph/qsgdefaultlayer.cpp
parentd7ebaa1611758a9677809d77e0b11f501c103f8d (diff)
parent20b96e21090fd008cc4a0d39300402fa3865d705 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: examples/quick/demos/photoviewer/deployment.pri One side made it redundant; the other removed part of it; remove it all ! src/quick/scenegraph/util/qsgatlastexture.cpp One side changed a preprocessor condition, the other a code condition, on adjacent lines; keep both changes. tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp One side changed a condition, the other the content of its block; keep both. Change-Id: Idb8937f92a7edb28212449dfe0c5cfdb8e6de986
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultlayer.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultlayer.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/quick/scenegraph/qsgdefaultlayer.cpp b/src/quick/scenegraph/qsgdefaultlayer.cpp
index 2f1c1d454c..ceab64478b 100644
--- a/src/quick/scenegraph/qsgdefaultlayer.cpp
+++ b/src/quick/scenegraph/qsgdefaultlayer.cpp
@@ -48,6 +48,29 @@ DEFINE_BOOL_CONFIG_OPTION(qmlFboOverlay, QML_FBO_OVERLAY)
#endif
DEFINE_BOOL_CONFIG_OPTION(qmlFboFlushBeforeDetach, QML_FBO_FLUSH_BEFORE_DETACH)
+
+
+static QOpenGLFramebufferObject *createFramebuffer(const QSize &size,
+ QOpenGLFramebufferObjectFormat format)
+{
+#ifdef Q_OS_MACOS
+ QOpenGLContext *context = QOpenGLContext::currentContext();
+ if (context->hasExtension("GL_ARB_framebuffer_sRGB")
+ && context->hasExtension("GL_EXT_texture_sRGB")
+ && context->hasExtension("GL_EXT_texture_sRGB_decode"))
+ format.setInternalTextureFormat(GL_SRGB8_ALPHA8_EXT);
+#endif
+ QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(size, format);
+#ifdef Q_OS_MACOS
+ if (format.internalTextureFormat() == GL_SRGB8_ALPHA8_EXT) {
+ QOpenGLFunctions *funcs = context->functions();
+ funcs->glBindTexture(GL_TEXTURE_2D, fbo->texture());
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
+ }
+#endif
+ return fbo;
+}
+
namespace
{
class BindableFbo : public QSGBindable
@@ -330,7 +353,7 @@ void QSGDefaultLayer::grab()
format.setInternalTextureFormat(m_format);
format.setSamples(m_context->openglContext()->format().samples());
- m_secondaryFbo = new QOpenGLFramebufferObject(m_size, format);
+ m_secondaryFbo = createFramebuffer(m_size, format);
m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_secondaryFbo);
} else {
QOpenGLFramebufferObjectFormat format;
@@ -339,14 +362,14 @@ void QSGDefaultLayer::grab()
if (m_recursive) {
deleteFboLater = true;
delete m_secondaryFbo;
- m_secondaryFbo = new QOpenGLFramebufferObject(m_size, format);
+ m_secondaryFbo = createFramebuffer(m_size, format);
funcs->glBindTexture(GL_TEXTURE_2D, m_secondaryFbo->texture());
updateBindOptions(true);
m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_secondaryFbo);
} else {
delete m_fbo;
delete m_secondaryFbo;
- m_fbo = new QOpenGLFramebufferObject(m_size, format);
+ m_fbo = createFramebuffer(m_size, format);
m_secondaryFbo = 0;
funcs->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
updateBindOptions(true);
@@ -360,7 +383,7 @@ void QSGDefaultLayer::grab()
Q_ASSERT(m_fbo);
Q_ASSERT(!m_multisampling);
- m_secondaryFbo = new QOpenGLFramebufferObject(m_size, m_fbo->format());
+ m_secondaryFbo = createFramebuffer(m_size, m_fbo->format());
funcs->glBindTexture(GL_TEXTURE_2D, m_secondaryFbo->texture());
updateBindOptions(true);
}