summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmbackingstore.cpp
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2022-04-12 12:43:07 +0200
committerMorten Sørvig <morten.sorvig@qt.io>2022-04-19 14:46:18 +0200
commitc78925f487c82f6ffbf9a8bceda8bef4b214bc3b (patch)
tree9123652d2cc44dd6b9a6fb144b1436d73988aeea /src/plugins/platforms/wasm/qwasmbackingstore.cpp
parente629efc82c2e26559159abfe44d8414997bc3d68 (diff)
wasm: propagate QWindow format to backing store
Qt backing store images should have alpha iff that was requested by the QWindow's surface format. This changes wasm to be in line with the other platforms, and enables use of transparency for Qt windows. Change beginPaint() to clear the backing store only if the format/image has alpha. This is also established behavior Qt's backing stores. Change-Id: Idafe658e24d864f7c4f9e68ee39cb409982b5852 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: David Skoland <david.skoland@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmbackingstore.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmbackingstore.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp
index 90fb168288d..83afa568fb6 100644
--- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp
+++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp
@@ -156,17 +156,22 @@ void QWasmBackingStore::beginPaint(const QRegion &region)
resize(backingStore()->size(), backingStore()->staticContents());
QPainter painter(&m_image);
- painter.setCompositionMode(QPainter::CompositionMode_Source);
- const QColor blank = Qt::transparent;
- for (const QRect &rect : region)
- painter.fillRect(rect, blank);
+
+ if (m_image.hasAlphaChannel()) {
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ const QColor blank = Qt::transparent;
+ for (const QRect &rect : region)
+ painter.fillRect(rect, blank);
+ }
}
void QWasmBackingStore::resize(const QSize &size, const QRegion &staticContents)
{
Q_UNUSED(staticContents);
- m_image = QImage(size * window()->devicePixelRatio(), QImage::Format_RGB32);
+ QImage::Format format = window()->format().hasAlpha() ?
+ QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
+ m_image = QImage(size * window()->devicePixelRatio(), format);
m_image.setDevicePixelRatio(window()->devicePixelRatio());
m_recreateTexture = true;
}