aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets/qquickwidget.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-04-15 18:14:15 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-04-16 14:48:36 +0000
commita7eeec59adba0e9a6f08e9ab1503d4ecfca349ba (patch)
tree1736fa7207813b858c3d70cda5370c6c936fa43c /src/quickwidgets/qquickwidget.cpp
parent3aeacf42168339a914cde039c89a5f3d56bab803 (diff)
Support sRGB for text with QQuickWidget
Otherwise we get visually different results with QQuickWindow and QQuickWidget on OS X. Task-number: QTBUG-42861 Change-Id: Icbf6f6e980129f5de73a88e7be7bef4f592e875e Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
-rw-r--r--src/quickwidgets/qquickwidget.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 8b7a42de57..38dde806ed 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -755,6 +755,16 @@ void QQuickWidget::createFramebufferObject()
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(samples);
+ // The default framebuffer for normal windows have sRGB support on OS X which leads to the Qt Quick text item
+ // utilizing sRGB blending. To get identical results with QQuickWidget we have to have our framebuffer backed
+ // by an sRGB texture.
+#ifdef Q_OS_OSX
+ 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
+
const QSize fboSize = size() * devicePixelRatio();
// Could be a simple hide - show, in which case the previous fbo is just fine.
@@ -763,6 +773,17 @@ void QQuickWidget::createFramebufferObject()
d->fbo = new QOpenGLFramebufferObject(fboSize, format);
}
+ // When compositing in the backingstore, sampling the sRGB texture would perform an
+ // sRGB-linear conversion which is not what we want when the final framebuffer (the window's)
+ // is sRGB too. Disable the conversion.
+#ifdef Q_OS_OSX
+ if (format.internalTextureFormat() == GL_SRGB8_ALPHA8_EXT) {
+ QOpenGLFunctions *funcs = context->functions();
+ funcs->glBindTexture(GL_TEXTURE_2D, d->fbo->texture());
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
+ }
+#endif
+
// Even though this is just an offscreen window we should set the position on it, as it might be
// useful for an item to know the actual position of the scene.
// Note: The position will be update when we get a move event (see: updatePosition()).