diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 17:46:16 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 17:46:34 +0200 |
commit | 440286655e0ca271506cf7cc02ad0dbf4baef9ca (patch) | |
tree | 896fa81adb8b14a69355a3a6cf64d06ec8173c9a /src/gui/painting/qplatformbackingstore.cpp | |
parent | 1e27ad1697187549151657ba187928e439300db7 (diff) | |
parent | e164d61ca8263fc4b46fdd916e1ea77c7dd2b735 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I4a78428a8ea273b6960792e3b8043f816fa37fcf
Diffstat (limited to 'src/gui/painting/qplatformbackingstore.cpp')
-rw-r--r-- | src/gui/painting/qplatformbackingstore.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index c71d82546a..45e90bd99b 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -338,7 +338,16 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i } } - if (!d_ptr->context->makeCurrent(window)) { + bool current = d_ptr->context->makeCurrent(window); + + if (!current && !d_ptr->context->isValid()) { + delete d_ptr->blitter; + d_ptr->blitter = nullptr; + d_ptr->textureId = 0; + current = d_ptr->context->create() && d_ptr->context->makeCurrent(window); + } + + if (!current) { qCWarning(lcQpaBackingStore, "composeAndFlush: makeCurrent() failed"); return; } @@ -446,14 +455,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); } |