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>bb10
parent
e629efc82c
commit
c78925f487
|
|
@ -156,17 +156,22 @@ void QWasmBackingStore::beginPaint(const QRegion ®ion)
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue