From c95b0982d5466069de3ac491ce3cbf9337060e3d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 10 Jan 2013 15:33:51 +0100 Subject: [PATCH] Clear backingstore for windows with alpha channel. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes painting artifacts in translucent windows. Task-number: QTBUG-28531 Change-Id: I00a7a86f88a40d356fa3e37bd497a288b2118469 Reviewed-by: Samuel Rødal --- .../platforms/windows/qwindowsbackingstore.cpp | 16 +++++++++++++--- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 2 -- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index b7937b4d84..5d3822d2cd 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -45,6 +45,7 @@ #include "qwindowscontext.h" #include +#include #include @@ -147,8 +148,10 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion ®ion) nsp << " from: " << m_image->image().size(); } #endif - m_image.reset(new QWindowsNativeImage(size.width(), size.height(), - QWindowsNativeImage::systemFormat())); + QImage::Format format = QWindowsNativeImage::systemFormat(); + if (format == QImage::Format_RGB32 && rasterWindow()->window()->format().hasAlpha()) + format = QImage::Format_ARGB32; + m_image.reset(new QWindowsNativeImage(size.width(), size.height(), format)); } } @@ -168,9 +171,16 @@ bool QWindowsBackingStore::scroll(const QRegion &area, int dx, int dy) void QWindowsBackingStore::beginPaint(const QRegion ®ion) { - Q_UNUSED(region); if (QWindowsContext::verboseBackingStore > 1) qDebug() << __FUNCTION__; + + if (m_image->image().hasAlphaChannel()) { + QPainter p(&m_image->image()); + p.setCompositionMode(QPainter::CompositionMode_Source); + const QColor blank = Qt::transparent; + foreach (const QRect &r, region.rects()) + p.fillRect(r, blank); + } } QWindowsWindow *QWindowsBackingStore::rasterWindow() const diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 649469ab9d..42abf046a9 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -272,7 +272,6 @@ void QXcbBackingStore::beginPaint(const QRegion ®ion) m_image->preparePaint(region); -#if 0 if (m_image->image()->hasAlphaChannel()) { QPainter p(m_image->image()); p.setCompositionMode(QPainter::CompositionMode_Source); @@ -282,7 +281,6 @@ void QXcbBackingStore::beginPaint(const QRegion ®ion) p.fillRect(*it, blank); } } -#endif } void QXcbBackingStore::endPaint(const QRegion &)