diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-02-21 10:32:07 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-02-26 20:06:11 +0000 |
commit | f9f9bea370fee029b28164c708b29d852e576945 (patch) | |
tree | 1af3042fa450cb6db16fcd94e6d4a450da42914e /src/widgets/kernel/qopenglwidget.cpp | |
parent | 5bb4d064945db43d62ea24b5d23bf4b0b4420e38 (diff) |
Compose renderToTexture widgets with sRGB when needed
Just requesting an sRGB texture for a QOpenGLWidget does not lead to
anything useful when it comes to the end result, the content will just get
darkened. For proper operation the target window's default framebuffer
must be sRGB capable and linearization during blending must be enabled.
Task-number: QTBUG-50987
Change-Id: Ibad0657c29a720590fa22c84c4bc303302de6dc0
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/widgets/kernel/qopenglwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index fd45abc8a2..4d45782170 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -581,6 +581,7 @@ public: void recreateFbo(); GLuint textureId() const Q_DECL_OVERRIDE; + QPlatformTextureList::Flags textureListFlags() Q_DECL_OVERRIDE; void initialize(); void invokeUserPaint(); @@ -656,6 +657,35 @@ GLuint QOpenGLWidgetPrivate::textureId() const return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); } +#ifndef GL_SRGB +#define GL_SRGB 0x8C40 +#endif +#ifndef GL_SRGB8 +#define GL_SRGB8 0x8C41 +#endif +#ifndef GL_SRGB_ALPHA +#define GL_SRGB_ALPHA 0x8C42 +#endif +#ifndef GL_SRGB8_ALPHA8 +#define GL_SRGB8_ALPHA8 0x8C43 +#endif + +QPlatformTextureList::Flags QOpenGLWidgetPrivate::textureListFlags() +{ + QPlatformTextureList::Flags flags = QWidgetPrivate::textureListFlags(); + switch (textureFormat) { + case GL_SRGB: + case GL_SRGB8: + case GL_SRGB_ALPHA: + case GL_SRGB8_ALPHA8: + flags |= QPlatformTextureList::TextureIsSrgb; + break; + default: + break; + } + return flags; +} + void QOpenGLWidgetPrivate::reset() { Q_Q(QOpenGLWidget); |