plugins/qpa: initialize buffer in backingstore

BUG: 437062
This commit is contained in:
Mouse Zhang 2023-05-22 16:52:13 +08:00 committed by Vlad Zahorodnii
parent 79fd2a4937
commit f3e4495e44
2 changed files with 14 additions and 0 deletions

View file

@ -47,6 +47,18 @@ void BackingStore::resize(const QSize &size, const QRegion &staticContents)
m_frontBuffer.setDevicePixelRatio(devicePixelRatio);
}
void BackingStore::beginPaint(const QRegion &region)
{
if (m_backBuffer.hasAlphaChannel()) {
QPainter p(paintDevice());
p.setCompositionMode(QPainter::CompositionMode_Source);
const QColor blank = Qt::transparent;
for (const QRect &rect : region) {
p.fillRect(rect, blank);
}
}
}
static QRect scaledRect(const QRect &rect, qreal devicePixelRatio)
{
return QRect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio);
@ -55,6 +67,7 @@ static QRect scaledRect(const QRect &rect, qreal devicePixelRatio)
static void blitImage(const QImage &source, QImage &target, const QRegion &region)
{
QPainter painter(&target);
painter.setCompositionMode(QPainter::CompositionMode_Source);
for (const QRect &rect : region) {
painter.drawImage(rect, source, scaledRect(rect, source.devicePixelRatio()));
}

View file

@ -27,6 +27,7 @@ public:
QPaintDevice *paintDevice() override;
void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;
void resize(const QSize &size, const QRegion &staticContents) override;
void beginPaint(const QRegion &region) override;
private:
QImage m_backBuffer;