diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-26 20:39:48 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-26 20:40:28 +0200 |
commit | 830a55ef58a21bf342eef1c2544bcbc899014e7b (patch) | |
tree | e15d5fbe038eb1c39e16b069453785c09705f328 /src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | |
parent | 86f81f48c6ceed124dabddf68994dcf3c0488509 (diff) | |
parent | 48dce24717ca537a6f5d817b2f5cd689df86ad68 (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Change-Id: If6750f5a11a24c535a2b3c4923bd8dc6a6b818f2
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode_p.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 7c2663d5a3..3501f30487 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -41,6 +41,7 @@ #include <private/qsgmaterialshader_p.h> #include <qopenglshaderprogram.h> +#include <qopenglframebufferobject.h> #include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformintegration.h> @@ -210,6 +211,7 @@ public: void activate(); void deactivate(); + bool useSRGB() const; uint m_useSRGB : 1; }; @@ -229,11 +231,26 @@ void QSG24BitTextMaskShader::initialize() } } +bool QSG24BitTextMaskShader::useSRGB() const +{ +#ifdef Q_OS_MACOS + if (!m_useSRGB) + return false; + + // m_useSRGB is true, but if some QOGLFBO was bound check it's texture format: + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QOpenGLFramebufferObject *qfbo = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo; + return !qfbo || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT; +#else + return m_useSRGB; +#endif +} + void QSG24BitTextMaskShader::activate() { QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); funcs->glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR); - if (m_useSRGB) + if (useSRGB()) funcs->glEnable(GL_FRAMEBUFFER_SRGB); } @@ -241,7 +258,7 @@ void QSG24BitTextMaskShader::deactivate() { QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); funcs->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - if (m_useSRGB) + if (useSRGB()) funcs->glDisable(GL_FRAMEBUFFER_SRGB); } @@ -266,7 +283,7 @@ void QSG24BitTextMaskShader::updateState(const RenderState &state, QSGMaterial * if (oldMaterial == 0 || material->color() != oldMaterial->color() || state.isOpacityDirty()) { QVector4D color = material->color(); - if (m_useSRGB) + if (useSRGB()) color = qt_sRGB_to_linear_RGB(color); QOpenGLContext::currentContext()->functions()->glBlendColor(color.x(), color.y(), color.z(), color.w()); color = qsg_premultiply(color, state.opacity()); |