summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2016-01-13 07:19:44 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-01-13 07:19:44 +0000
commit9a969182cfa452fdb305bc9fe0becc6b358f91c1 (patch)
tree9850ac418b869e42e17d82cc14d2fe0aa93a3192 /src/gui
parentf7020a31c02f4d1e5a46ce2ea20e38751f9afeed (diff)
parent6b8c0a50585bb637c5cd33ca8ffde0cb9c4e3664 (diff)
Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/dev
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage.cpp27
-rw-r--r--src/gui/image/qimage_p.h35
-rw-r--r--src/gui/image/qpixmap_raster.cpp27
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp2
4 files changed, 39 insertions, 52 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index a992ad6fea..6ec1eecfb1 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -4623,32 +4623,7 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
if (complex_xform || mode == Qt::SmoothTransformation) {
if (d->format < QImage::Format_RGB32 || !hasAlphaChannel()) {
- switch(d->format) {
- case QImage::Format_RGB16:
- target_format = Format_ARGB8565_Premultiplied;
- break;
- case QImage::Format_RGB555:
- target_format = Format_ARGB8555_Premultiplied;
- break;
- case QImage::Format_RGB666:
- target_format = Format_ARGB6666_Premultiplied;
- break;
- case QImage::Format_RGB444:
- target_format = Format_ARGB4444_Premultiplied;
- break;
- case QImage::Format_RGBX8888:
- target_format = Format_RGBA8888_Premultiplied;
- break;
- case QImage::Format_BGR30:
- target_format = Format_A2BGR30_Premultiplied;
- break;
- case QImage::Format_RGB30:
- target_format = Format_A2RGB30_Premultiplied;
- break;
- default:
- target_format = Format_ARGB32_Premultiplied;
- break;
- }
+ target_format = qt_alphaVersion(d->format);
}
}
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 3badda0864..f9ad6c0ac0 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -161,10 +161,45 @@ inline int qt_depthForFormat(QImage::Format format)
}
return depth;
}
+
#if defined(_M_ARM)
#pragma optimize("", on)
#endif
+inline QImage::Format qt_alphaVersion(QImage::Format format)
+{
+ switch (format) {
+ case QImage::Format_RGB16:
+ return QImage::Format_ARGB8565_Premultiplied;
+ case QImage::Format_RGB555:
+ return QImage::Format_ARGB8555_Premultiplied;
+ case QImage::Format_RGB666:
+ return QImage::Format_ARGB6666_Premultiplied;
+ case QImage::Format_RGB444:
+ return QImage::Format_ARGB4444_Premultiplied;
+ case QImage::Format_RGBX8888:
+ return QImage::Format_RGBA8888_Premultiplied;
+ case QImage::Format_BGR30:
+ return QImage::Format_A2BGR30_Premultiplied;
+ case QImage::Format_RGB30:
+ return QImage::Format_A2RGB30_Premultiplied;
+ default:
+ break;
+ }
+ return QImage::Format_ARGB32_Premultiplied;
+}
+
+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))
+ toFormat = QImage::Format_ARGB32_Premultiplied;
+#endif
+ return toFormat;
+}
+
QT_END_NAMESPACE
#endif // QIMAGE_P_H
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index a2b84b358e..bbdf77355e 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -178,20 +178,7 @@ void QRasterPlatformPixmap::fill(const QColor &color)
int alpha = color.alpha();
if (alpha != 255) {
if (!image.hasAlphaChannel()) {
- QImage::Format toFormat;
-#if !(defined(__ARM_NEON__) || defined(__SSE2__))
- if (image.format() == QImage::Format_RGB16)
- toFormat = QImage::Format_ARGB8565_Premultiplied;
- else if (image.format() == QImage::Format_RGB666)
- toFormat = QImage::Format_ARGB6666_Premultiplied;
- else if (image.format() == QImage::Format_RGB555)
- toFormat = QImage::Format_ARGB8555_Premultiplied;
- else if (image.format() == QImage::Format_RGB444)
- toFormat = QImage::Format_ARGB4444_Premultiplied;
- else
-#endif
- toFormat = QImage::Format_ARGB32_Premultiplied;
-
+ QImage::Format toFormat = qt_alphaVersionForPainting(image.format());
if (!image.isNull() && qt_depthForFormat(image.format()) == qt_depthForFormat(toFormat)) {
image.detach();
image.d->format = toFormat;
@@ -314,17 +301,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC
: QImage::Format_RGB32;
} else {
QImage::Format opaqueFormat = QNativeImage::systemFormat();
- QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
-
-#if !defined(__ARM_NEON__) && !defined(__SSE2__)
- switch (opaqueFormat) {
- case QImage::Format_RGB16:
- alphaFormat = QImage::Format_ARGB8565_Premultiplied;
- break;
- default: // We don't care about the others...
- break;
- }
-#endif
+ QImage::Format alphaFormat = qt_alphaVersionForPainting(opaqueFormat);
if (!sourceImage.hasAlphaChannel()) {
format = opaqueFormat;
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 651149c4c6..b8ab98e290 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -4193,7 +4193,7 @@ protected:
void QGradientCache::generateGradientColorTable(const QGradient& gradient, QRgba64 *colorTable, int size, int opacity) const
{
- QGradientStops stops = gradient.stops();
+ const QGradientStops stops = gradient.stops();
int stopCount = stops.count();
Q_ASSERT(stopCount > 0);