Clear backingstore for windows with alpha channel.

Fixes painting artifacts in translucent windows.

Task-number: QTBUG-28531

Change-Id: I00a7a86f88a40d356fa3e37bd497a288b2118469
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
Friedemann Kleint 2013-01-10 15:33:51 +01:00 committed by The Qt Project
parent ffd912a51d
commit c95b0982d5
2 changed files with 13 additions and 5 deletions

View File

@ -45,6 +45,7 @@
#include "qwindowscontext.h"
#include <QtGui/QWindow>
#include <QtGui/QPainter>
#include <QtCore/QDebug>
@ -147,8 +148,10 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion &region)
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 &region)
{
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

View File

@ -272,7 +272,6 @@ void QXcbBackingStore::beginPaint(const QRegion &region)
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 &region)
p.fillRect(*it, blank);
}
}
#endif
}
void QXcbBackingStore::endPaint(const QRegion &)