summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-12-07 11:37:21 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-12-15 15:54:46 +0100
commit30811f6428549bbdc54c2566b1493f83d3c24a66 (patch)
tree04ffc4c0de7aa0ac1a78db9f4577cf17acb28445 /src/gui
parent9e1433dfddbb0b017c8eca4d71aa09d873a06a3e (diff)
Fix qt_alphaVersion and qt_opaqueVersion in the trivial case
The case no conversion was needed wasn't handled, but was assumed to be handled by some call sites. This can speed up QPixmaps on devices with non-standard screen formats. [ChangeLog][QPixmap] Opaque pixmaps on devices with a non-standard opaque format will now correctly match format for faster blitting. Same with semitransparent pixmaps on devices with a non-standard semitransparent format. Pick-to: 6.0 5.15 Change-Id: Ia05ff518fea36b7e3ed5c089fa9e8681a02fc574 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage_p.h57
1 files changed, 53 insertions, 4 deletions
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 2fbb646c2e..64f5be9e76 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -249,14 +249,38 @@ inline QImage::Format qt_opaqueVersion(QImage::Format format)
return QImage::Format_RGBX64;
case QImage::Format_ARGB32_Premultiplied:
case QImage::Format_ARGB32:
- default:
return QImage::Format_RGB32;
+ case QImage::Format_RGB16:
+ case QImage::Format_RGB32:
+ case QImage::Format_RGB444:
+ case QImage::Format_RGB555:
+ case QImage::Format_RGB666:
+ case QImage::Format_RGB888:
+ case QImage::Format_BGR888:
+ case QImage::Format_RGBX8888:
+ case QImage::Format_BGR30:
+ case QImage::Format_RGB30:
+ case QImage::Format_RGBX64:
+ case QImage::Format_Grayscale8:
+ case QImage::Format_Grayscale16:
+ return format;
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ case QImage::Format_Indexed8:
+ case QImage::Format_Alpha8:
+ case QImage::Format_Invalid:
+ case QImage::NImageFormats:
+ break;
}
+ return QImage::Format_RGB32;
}
inline QImage::Format qt_alphaVersion(QImage::Format format)
{
switch (format) {
+ case QImage::Format_RGB32:
+ case QImage::Format_ARGB32:
+ return QImage::Format_ARGB32_Premultiplied;
case QImage::Format_RGB16:
return QImage::Format_ARGB8565_Premultiplied;
case QImage::Format_RGB555:
@@ -266,14 +290,35 @@ inline QImage::Format qt_alphaVersion(QImage::Format format)
case QImage::Format_RGB444:
return QImage::Format_ARGB4444_Premultiplied;
case QImage::Format_RGBX8888:
+ case QImage::Format_RGBA8888:
return QImage::Format_RGBA8888_Premultiplied;
case QImage::Format_BGR30:
return QImage::Format_A2BGR30_Premultiplied;
case QImage::Format_RGB30:
return QImage::Format_A2RGB30_Premultiplied;
case QImage::Format_RGBX64:
+ case QImage::Format_RGBA64:
+ case QImage::Format_Grayscale16:
return QImage::Format_RGBA64_Premultiplied;
- default:
+ case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ case QImage::Format_ARGB6666_Premultiplied:
+ case QImage::Format_ARGB4444_Premultiplied:
+ case QImage::Format_RGBA8888_Premultiplied:
+ case QImage::Format_A2BGR30_Premultiplied:
+ case QImage::Format_A2RGB30_Premultiplied:
+ case QImage::Format_RGBA64_Premultiplied:
+ return format;
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ case QImage::Format_Indexed8:
+ case QImage::Format_RGB888:
+ case QImage::Format_BGR888:
+ case QImage::Format_Alpha8:
+ case QImage::Format_Grayscale8:
+ case QImage::Format_Invalid:
+ case QImage::NImageFormats:
break;
}
return QImage::Format_ARGB32_Premultiplied;
@@ -310,7 +355,11 @@ inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format)
inline QImage::Format qt_opaqueVersionForPainting(QImage::Format format)
{
- return qt_opaqueVersion(format);
+ QImage::Format toFormat = qt_opaqueVersion(format);
+ // If we are switching depth anyway upgrade to RGB32
+ if (qt_depthForFormat(format) != qt_depthForFormat(toFormat) && qt_depthForFormat(toFormat) <= 32)
+ toFormat = QImage::Format_RGB32;
+ return toFormat;
}
inline QImage::Format qt_alphaVersionForPainting(QImage::Format format)
@@ -318,7 +367,7 @@ inline QImage::Format qt_alphaVersionForPainting(QImage::Format format)
QImage::Format toFormat = qt_alphaVersion(format);
#if defined(__ARM_NEON__) || defined(__SSE2__)
// If we are switching depth anyway and we have optimized ARGB32PM routines, upgrade to that.
- if (qt_depthForFormat(format) != qt_depthForFormat(toFormat))
+ if (qt_depthForFormat(format) != qt_depthForFormat(toFormat) && qt_depthForFormat(toFormat) <= 32)
toFormat = QImage::Format_ARGB32_Premultiplied;
#endif
return toFormat;