summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qblendfunctions.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-05-27 14:25:25 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-05-27 14:27:14 (GMT)
commitb66f7a2e95c32c64701a992f28d99e32f48e2db1 (patch)
treed422cb20a046702d5452eaa3c52da887baa26ece /src/gui/painting/qblendfunctions.cpp
parent9f525dcc7280cd387332c6a39b3d7057f6f87928 (diff)
downloadQt-b66f7a2e95c32c64701a992f28d99e32f48e2db1.zip
Qt-b66f7a2e95c32c64701a992f28d99e32f48e2db1.tar.gz
Qt-b66f7a2e95c32c64701a992f28d99e32f48e2db1.tar.bz2
Optimized fast scaling of ARGB8565 images onto RGB16 images.
There was an optimized blend function for this case but not an optimized scale function. Performance increase seems to be in the order of 5x. Reviewed-by: Trond
Diffstat (limited to 'src/gui/painting/qblendfunctions.cpp')
-rw-r--r--src/gui/painting/qblendfunctions.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index 8f4a2bf..f83ff7b 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -104,6 +104,37 @@ struct Blend_RGB16_on_RGB16_ConstAlpha {
quint32 m_ialpha;
};
+struct Blend_ARGB24_on_RGB16_SourceAlpha {
+ inline void write(quint16 *dst, qargb8565 src) {
+ const uint alpha = src.alpha();
+ if (alpha) {
+ quint16 s = qrgb565(src).rawValue();
+ if (alpha < 255)
+ s += BYTE_MUL_RGB16(*dst, 255 - alpha);
+ *dst = s;
+ }
+ }
+};
+
+struct Blend_ARGB24_on_RGB16_SourceAndConstAlpha {
+ inline Blend_ARGB24_on_RGB16_SourceAndConstAlpha(quint32 alpha) {
+ m_alpha = (alpha * 255) >> 8;
+ }
+
+ inline void write(quint16 *dst, qargb8565 src) {
+ src = src.byte_mul(src.alpha(m_alpha));
+ const uint alpha = src.alpha();
+ if (alpha) {
+ quint16 s = qrgb565(src).rawValue();
+ if (alpha < 255)
+ s += BYTE_MUL_RGB16(*dst, 255 - alpha);
+ *dst = s;
+ }
+ }
+
+ quint32 m_alpha;
+};
+
struct Blend_ARGB32_on_RGB16_SourceAlpha {
inline void write(quint16 *dst, quint32 src) {
const quint8 alpha = qAlpha(src);
@@ -237,6 +268,32 @@ void qt_scale_image_rgb16_on_rgb16(uchar *destPixels, int dbpl,
}
}
+void qt_scale_image_argb24_on_rgb16(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ const QRectF &targetRect,
+ const QRectF &sourceRect,
+ const QRect &clip,
+ int const_alpha)
+{
+#ifdef QT_DEBUG_DRAW
+ printf("qt_scale_argb24_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
+ destPixels, dbpl, srcPixels, sbpl,
+ targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
+ sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
+ const_alpha);
+#endif
+ if (const_alpha == 256) {
+ Blend_ARGB24_on_RGB16_SourceAlpha noAlpha;
+ qt_scale_image_16bit<qargb8565>(destPixels, dbpl, srcPixels, sbpl,
+ targetRect, sourceRect, clip, noAlpha);
+ } else {
+ Blend_ARGB24_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
+ qt_scale_image_16bit<qargb8565>(destPixels, dbpl, srcPixels, sbpl,
+ targetRect, sourceRect, clip, constAlpha);
+ }
+}
+
+
void qt_scale_image_argb32_on_rgb16(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
const QRectF &targetRect,
@@ -874,7 +931,7 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB32,
qt_scale_image_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
qt_scale_image_rgb16_on_rgb16, // Format_RGB16,
- 0, // Format_ARGB8565_Premultiplied,
+ qt_scale_image_argb24_on_rgb16, // Format_ARGB8565_Premultiplied,
0, // Format_RGB666,
0, // Format_ARGB6666_Premultiplied,
0, // Format_RGB555,