Allow render-to-texture widgets to tell if they want premul blending
Instead of assuming they do not (like in >= 5.12.3) or they do (like in < 5.12.3). QOpenGLWidget and QQuickWidget will likely want the opposite. So allow specifying this with a QPlatformTextureList flag, similarly to how we do it for sRGB for QOpenGLWidget. Task-number: QTBUG-77471 Change-Id: I594ca919c8eca190fa70c6aa84f46f456fcd80e1 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>bb10
parent
6de5cf2df8
commit
228f0c1d2e
|
|
@ -446,14 +446,22 @@ 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.
|
||||
bool blendIsPremultiplied = d_ptr->premultiplied;
|
||||
for (int i = 0; i < textures->count(); ++i) {
|
||||
if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
|
||||
const QPlatformTextureList::Flags flags = textures->flags(i);
|
||||
if (flags.testFlag(QPlatformTextureList::NeedsPremultipliedAlphaBlending)) {
|
||||
if (!blendIsPremultiplied) {
|
||||
funcs->glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
blendIsPremultiplied = true;
|
||||
}
|
||||
} else {
|
||||
if (blendIsPremultiplied) {
|
||||
funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
blendIsPremultiplied = false;
|
||||
}
|
||||
}
|
||||
if (flags.testFlag(QPlatformTextureList::StacksOnTop))
|
||||
blitTextureForWidget(textures, i, window, deviceWindowRect, d_ptr->blitter, offset, canUseSrgb);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ class Q_GUI_EXPORT QPlatformTextureList : public QObject
|
|||
public:
|
||||
enum Flag {
|
||||
StacksOnTop = 0x01,
|
||||
TextureIsSrgb = 0x02
|
||||
TextureIsSrgb = 0x02,
|
||||
NeedsPremultipliedAlphaBlending = 0x04
|
||||
};
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue