summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage_p.h
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>2021-01-24 23:39:51 +0100
commit0ce98b1cf8f811d0fda28c48bc93c426f41ed4a3 (patch)
tree66f1def4ec293270fe36ec130d957bd9acb4c66d /src/gui/image/qimage_p.h
parent41937df503b0c09ea319194d78a41a16ef5e0bbf (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. Change-Id: Ia05ff518fea36b7e3ed5c089fa9e8681a02fc574 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 30811f6428549bbdc54c2566b1493f83d3c24a66) 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.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 eb44a0190d..b272377fb2 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;