diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-03-08 10:55:14 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-03-30 19:22:17 +0000 |
commit | 28a264cfe2d161f2eba3b1efa3ea4985445cd2de (patch) | |
tree | 911b8189c4869721f89c5574623172ddcd0ff238 /src | |
parent | 387f120bf9d6c718796efe5d0db772abc71ab442 (diff) |
Fix alpha blending regression with WA_StacksOnTop QOpenGLWidgets
0bc42886898 in Qt 5.6 introduced support for premultiplied alpha in the
raster-rendered QWidget content. Unfortunately this introduced a
regression for OpenGL content from QOpenGLWidgets with WA_StacksOnTop
set: these used standard alpha blending in 5.5 and earlier, and
switching them to premultiplied (in case the - unrelated - raster
content has a _Premultiplied QImage format) breaks all content that
was done with non-premultiplied alpha in mind, for example the qopenglwidget
example's "Transparent background" checkbox.
Restore the pre-5.6 behavior.
Fixes: QTBUG-74285
Change-Id: I76fcadd53cd436efa2b619b8d6739270995d044f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/painting/qplatformbackingstore.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index afb4613ba5..c71d82546a 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -446,6 +446,11 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i d_ptr->blitter->setRedBlueSwizzle(false); } + // There is no way to tell if the OpenGL-rendered content is premultiplied or not. + // For compatibility, assume that it is not, and use normal alpha blend always. + if (d_ptr->premultiplied) + funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE); + // Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set. for (int i = 0; i < textures->count(); ++i) { if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) |