Optimize direct argb32 blend functions

They were slower than the long path version due to working too hard.
This also unduplicates code by using the blend_pixel function.

Change-Id: Ibf84b8f749cf40d4c852b459dc76860afd850d32
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2018-04-26 14:24:10 +02:00
parent d5e655f388
commit 9bc616948f

View File

@ -430,28 +430,28 @@ struct Blend_RGB32_on_RGB32_ConstAlpha {
}; };
struct Blend_ARGB32_on_ARGB32_SourceAlpha { struct Blend_ARGB32_on_ARGB32_SourceAlpha {
inline void write(quint32 *dst, quint32 src) { inline void write(quint32 *dst, quint32 src)
*dst = src + BYTE_MUL(*dst, qAlpha(~src)); {
blend_pixel(*dst, src);
} }
inline void flush(void *) {} inline void flush(void *) {}
}; };
struct Blend_ARGB32_on_ARGB32_SourceAndConstAlpha { struct Blend_ARGB32_on_ARGB32_SourceAndConstAlpha {
inline Blend_ARGB32_on_ARGB32_SourceAndConstAlpha(quint32 alpha) { inline Blend_ARGB32_on_ARGB32_SourceAndConstAlpha(quint32 alpha)
{
m_alpha = (alpha * 255) >> 8; m_alpha = (alpha * 255) >> 8;
m_ialpha = 255 - m_alpha;
} }
inline void write(quint32 *dst, quint32 src) { inline void write(quint32 *dst, quint32 src)
src = BYTE_MUL(src, m_alpha); {
*dst = src + BYTE_MUL(*dst, qAlpha(~src)); blend_pixel(*dst, src, m_alpha);
} }
inline void flush(void *) {} inline void flush(void *) {}
quint32 m_alpha; quint32 m_alpha;
quint32 m_ialpha;
}; };
void qt_scale_image_rgb32_on_rgb32(uchar *destPixels, int dbpl, void qt_scale_image_rgb32_on_rgb32(uchar *destPixels, int dbpl,