diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-25 20:57:38 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-25 20:57:38 +0200 |
commit | 48dce24717ca537a6f5d817b2f5cd689df86ad68 (patch) | |
tree | 72c8cc3161f84b9d97bca5014f107d8190a58338 /src/quick | |
parent | 8b7dbfe1e0c0d4b8d0984fb381f1a0bb6b566e76 (diff) | |
parent | ec73b9ff3b0064cf7760baeb826d912d9a30d227 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I12efb77e812364052eca12ea35219ceff64d7cc3
Diffstat (limited to 'src/quick')
-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 3da7a10456..d6128b339c 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> @@ -209,6 +210,7 @@ public: void activate(); void deactivate(); + bool useSRGB() const; uint m_useSRGB : 1; }; @@ -228,11 +230,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); } @@ -240,7 +257,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); } @@ -265,7 +282,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()); |