summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qblendfunctions.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2016-11-18 16:33:12 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-12-03 13:24:36 +0000
commite3b6f6d16577c74433de1ca9e15402cdf285abca (patch)
treeff6a3f155111c51502bf38b0881452afe6cc61fd /src/gui/painting/qblendfunctions.cpp
parent5cc1265c340656b02f3bd2fccbadd29a21aa8704 (diff)
Fix blending of RGB32 on RGB32 with partial opacity
The alpha channel of an RGB32 image was not properly ignored when doing blending with partial opacity. Now the alpha value is properly ignored, which is both more correct and faster. This also makes SSE2 and AVX2 implementations match NEON which was already doing the right thing (though had dead code for doing it wrong). Change-Id: I4613b8d70ed8c2e36ced10baaa7a4a55bd36a940 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/painting/qblendfunctions.cpp')
-rw-r--r--src/gui/painting/qblendfunctions.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index 0a5d458532..a4a091a29f 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -385,19 +385,25 @@ void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
fflush(stdout);
#endif
-
- if (const_alpha != 256) {
- qt_blend_argb32_on_argb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
- return;
- }
-
const uint *src = (const uint *) srcPixels;
uint *dst = (uint *) destPixels;
- int len = w * 4;
- for (int y=0; y<h; ++y) {
- memcpy(dst, src, len);
- dst = (quint32 *)(((uchar *) dst) + dbpl);
- src = (const quint32 *)(((const uchar *) src) + sbpl);
+ if (const_alpha == 256) {
+ const int len = w * 4;
+ for (int y = 0; y < h; ++y) {
+ memcpy(dst, src, len);
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
+ return;
+ } else if (const_alpha != 0) {
+ const_alpha = (const_alpha * 255) >> 8;
+ int ialpha = 255 - const_alpha;
+ for (int y=0; y<h; ++y) {
+ for (int x=0; x<w; ++x)
+ dst[x] = INTERPOLATE_PIXEL_255(dst[x], ialpha, src[x], const_alpha);
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
}
}
@@ -414,7 +420,7 @@ struct Blend_RGB32_on_RGB32_ConstAlpha {
}
inline void write(quint32 *dst, quint32 src) {
- *dst = BYTE_MUL(src, m_alpha) + BYTE_MUL(*dst, m_ialpha);
+ *dst = INTERPOLATE_PIXEL_255(src, m_alpha, *dst, m_ialpha);
}
inline void flush(void *) {}