diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-06 11:01:39 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-08 19:08:43 +0000 |
commit | 1bcfc3de7586ddb9f5d1b778b97b26ae3dc9584d (patch) | |
tree | 66571c15008a0978c8b2335d668656075a504086 /src/gui/image/qimage_p.h | |
parent | c04cf29b78f3f5747c58dd89ca21523e387ee3ac (diff) |
Use backing store formats with alpha
We depend on being able to punch holes in the backing store when
integrating with FBO elements. To do that we need a format with an alpha
channel. This was only working previously because RGB32 didn't mask when
filling or when converting to ARGB32_PM, but other formats didn't.
Also unifies the logic for getting alpha versions of QImage formats.
Task-number: QTBUG-50281
Change-Id: Ied1325f60e2b67d9ea2dfa9701b06fc2231ebfca
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/gui/image/qimage_p.h')
-rw-r--r-- | src/gui/image/qimage_p.h | 35 |
1 files changed, 35 insertions, 0 deletions
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 |