mirror of https://gitee.com/openkylin/kwin.git
plugins/qpa: initialize buffer in backingstore
This commit is contained in:
parent
ee34562420
commit
8f2e59a943
|
@ -49,6 +49,18 @@ void BackingStore::resize(const QSize &size, const QRegion &staticContents)
|
|||
m_frontBuffer.setDevicePixelRatio(devicePixelRatio);
|
||||
}
|
||||
|
||||
void BackingStore::beginPaint(const QRegion ®ion)
|
||||
{
|
||||
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);
|
||||
|
@ -57,6 +69,7 @@ static QRect scaledRect(const QRect &rect, qreal devicePixelRatio)
|
|||
static void blitImage(const QImage &source, QImage &target, const QRegion ®ion)
|
||||
{
|
||||
QPainter painter(&target);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
for (const QRect &rect : region) {
|
||||
painter.drawImage(rect, source, scaledRect(rect, source.devicePixelRatio()));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
QPaintDevice *paintDevice() override;
|
||||
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override;
|
||||
void resize(const QSize &size, const QRegion &staticContents) override;
|
||||
void beginPaint(const QRegion ®ion) override;
|
||||
|
||||
private:
|
||||
QImage m_backBuffer;
|
||||
|
|
Loading…
Reference in New Issue