summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-01-14 17:48:38 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-01-17 01:31:55 +0000
commit1172e18c3c180f2f3641e6c29688199eb5c46650 (patch)
tree0c0e5df6c065ca73664d8e2a18a7bb782c1214cd /src/plugins/platforms/windows
parent9bb24615ad8644cfb7879ed42ee36b4497541805 (diff)
Promote backingstore image format to alpha
Like xcb does since 1bcfc3de7586ddb9f5d1b778b97b26ae3dc9584d. For TranslucentBackground (ARGB32_Premultiplied) there is no change in practice. For RGB32 we will promote to ARGB32_Premultiplied but everything should behave like before, except that we do not rely on undefined behavior anymore when QOpenGL/QuickWidget is in use. For RGB16 this will enable QOpenGL/QuickWidget since there the hole punching mechanism needs an alpha channel always. Change-Id: Id04ea548cee245ec91642f1358a5e501b62ff64c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.cpp18
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.h1
2 files changed, 15 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
index 135c9eb601..a6b1d0af26 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
@@ -39,6 +39,7 @@
#include <QtGui/QWindow>
#include <QtGui/QPainter>
#include <private/qhighdpiscaling_p.h>
+#include <private/qimage_p.h>
#include <QtCore/QDebug>
@@ -52,7 +53,8 @@ QT_BEGIN_NAMESPACE
*/
QWindowsBackingStore::QWindowsBackingStore(QWindow *window) :
- QPlatformBackingStore(window)
+ QPlatformBackingStore(window),
+ m_alphaNeedsFill(false)
{
qCDebug(lcQpaBackingStore) << __FUNCTION__ << this << window;
}
@@ -144,8 +146,16 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion &region)
<< " from: " << (m_image.isNull() ? QSize() : m_image->image().size());
}
#endif
- const QImage::Format format = window()->format().hasAlpha() ?
- QImage::Format_ARGB32_Premultiplied : QWindowsNativeImage::systemFormat();
+ QImage::Format format = window()->format().hasAlpha() ?
+ QImage::Format_ARGB32_Premultiplied : QWindowsNativeImage::systemFormat();
+
+ // The backingstore composition (enabling render-to-texture widgets)
+ // punches holes in the backingstores using the alpha channel. Hence
+ // the need for a true alpha format.
+ if (QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha)
+ m_alphaNeedsFill = true;
+ else // upgrade but here we know app painting does not rely on alpha hence no need to fill
+ format = qt_alphaVersionForPainting(format);
QWindowsNativeImage *oldwni = m_image.data();
QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format);
@@ -186,7 +196,7 @@ void QWindowsBackingStore::beginPaint(const QRegion &region)
if (QWindowsContext::verbose > 1)
qCDebug(lcQpaBackingStore) <<__FUNCTION__ << region;
- if (m_image->image().hasAlphaChannel()) {
+ if (m_alphaNeedsFill) {
QPainter p(&m_image->image());
p.setCompositionMode(QPainter::CompositionMode_Source);
const QColor blank = Qt::transparent;
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.h b/src/plugins/platforms/windows/qwindowsbackingstore.h
index 4badcf1b09..1d644923bb 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.h
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.h
@@ -65,6 +65,7 @@ public:
private:
QScopedPointer<QWindowsNativeImage> m_image;
+ bool m_alphaNeedsFill;
};
QT_END_NAMESPACE