summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage_p.h
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-03-13 13:04:40 +0100
committerJohan Helsing <johan.helsing@qt.io>2018-03-19 08:23:54 +0000
commitefa6e989125b3a9cf54a408aae8a86ef4bddf778 (patch)
tree8960e3999024da8e5d73a9439c470be6781e35b2 /src/gui/image/qimage_p.h
parentd3121e3888ae43a7dc074f5d8acc26b1973a7726 (diff)
QPixmap don't assume QPlatformScreen::format is opaque
QRasterPlatformPixmap::systemOpaqueFormat returned QPlatformScreen::format without checking that the format was actually opaque. This caused several QPixmap tests to fail on Wayland because Wayland compositors don't communicate the native format of the screen, just a list of supported pixel formats, so we just return ARGB32_premultiplied in QWaylandScreen::format(). Rename the method systemOpaqueFormat to systemNativeFormat since that's how it's used most of the time. And do a conversion when we actually care whether the format is opaque or not. Task-number: QTBUG-51748 Change-Id: I47dc1c3f185fb802016ca361206d47d02e8d3cf1 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/image/qimage_p.h')
-rw-r--r--src/gui/image/qimage_p.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index befecbfe8b..f5fea2ed00 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -172,6 +172,31 @@ inline int qt_depthForFormat(QImage::Format format)
#pragma optimize("", on)
#endif
+inline QImage::Format qt_opaqueVersion(QImage::Format format)
+{
+ switch (format) {
+ case QImage::Format_ARGB8565_Premultiplied:
+ return QImage::Format_RGB16;
+ case QImage::Format_ARGB8555_Premultiplied:
+ return QImage::Format_RGB555;
+ case QImage::Format_ARGB6666_Premultiplied:
+ return QImage::Format_RGB666;
+ case QImage::Format_ARGB4444_Premultiplied:
+ return QImage::Format_RGB444;
+ case QImage::Format_RGBA8888:
+ case QImage::Format_RGBA8888_Premultiplied:
+ return QImage::Format_RGBX8888;
+ case QImage::Format_A2BGR30_Premultiplied:
+ return QImage::Format_BGR30;
+ case QImage::Format_A2RGB30_Premultiplied:
+ return QImage::Format_RGB30;
+ case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_ARGB32:
+ default:
+ return QImage::Format_RGB32;
+ }
+}
+
inline QImage::Format qt_alphaVersion(QImage::Format format)
{
switch (format) {
@@ -201,6 +226,11 @@ inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format)
return qt_depthForFormat(format) == qt_depthForFormat(toFormat) ? toFormat : format;
}
+inline QImage::Format qt_opaqueVersionForPainting(QImage::Format format)
+{
+ return qt_opaqueVersion(format);
+}
+
inline QImage::Format qt_alphaVersionForPainting(QImage::Format format)
{
QImage::Format toFormat = qt_alphaVersion(format);