aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-08-27 08:06:36 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-27 08:06:41 +0200
commit3c69ee0f05e7c96938c8b2fd70f122cbaf07232a (patch)
treeac7b7629ac99702f4c67981c83aad36355c91c04 /src/quick/scenegraph
parent31a2cbbbc2dcf7d87a4b90c90c193e09e9676d6c (diff)
parent018cd6d70f18762d20cc501ac352fa5f94eb7f66 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h3
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp23
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp6
3 files changed, 27 insertions, 5 deletions
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 43cf1c28ab..899278843e 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -139,7 +139,8 @@ public Q_SLOTS:
void textureFactoryDestroyed(QObject *o);
protected:
- QSGContext *m_sg;
+ // Hold m_sg with QPointer in the rare case it gets deleted before us.
+ QPointer<QSGContext> m_sg;
QMutex m_mutex;
QHash<QQuickTextureFactory *, QSGTexture *> m_textures;
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());
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index 4fcc81fb18..6f10611ba3 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -70,6 +70,9 @@ QSGDefaultRenderContext::QSGDefaultRenderContext(QSGContext *context)
*/
void QSGDefaultRenderContext::initialize(void *context)
{
+ if (!m_sg)
+ return;
+
QOpenGLContext *openglContext = static_cast<QOpenGLContext *>(context);
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
@@ -163,7 +166,8 @@ void QSGDefaultRenderContext::invalidate()
m_gl->setProperty(QSG_RENDERCONTEXT_PROPERTY, QVariant());
m_gl = 0;
- m_sg->renderContextInvalidated(this);
+ if (m_sg)
+ m_sg->renderContextInvalidated(this);
emit invalidated();
}