Fix alpha blending regression with WA_StacksOnTop QOpenGLWidgets

0bc4288689 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>
This commit is contained in:
Laszlo Agocs 2019-03-08 10:55:14 +01:00
parent 387f120bf9
commit 28a264cfe2

View File

@ -446,6 +446,11 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
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))