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>
This commit is contained in:
Allan Sandfeld Jensen 2020-12-07 11:37:21 +01:00
parent 9e1433dfdd
commit 30811f6428

View File

@ -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;