From 500f28f04a08e37525e3d1deb5cfe6e908c66b15 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Tue, 9 Feb 2010 14:52:16 +0100 Subject: Refactor comp_func_solid_Clear() and comp_func_solid_Source() Put the common code together with a #define. Remove the check for the length from comp_func_Clear_impl and move it to qt_memfill() --- src/gui/painting/qdrawhelper.cpp | 36 +++++++++++++++------------------- src/gui/painting/qdrawhelper_mmx_p.h | 38 +++++++++++++++--------------------- src/gui/painting/qdrawhelper_p.h | 3 +++ 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 660a2a8..7a3da20 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1267,32 +1267,28 @@ static const uint L2CacheLineLengthInInts = L2CacheLineLength/sizeof(uint); result = 0 d = d * cia */ +#define comp_func_Clear_impl(dest, length, const_alpha)\ +{\ + if (const_alpha == 255) {\ + QT_MEMFILL_UINT(dest, length, 0);\ + } else {\ + int ialpha = 255 - const_alpha;\ + PRELOAD_INIT(dest)\ + for (int i = 0; i < length; ++i) {\ + PRELOAD_COND(dest)\ + dest[i] = BYTE_MUL(dest[i], ialpha);\ + }\ + }\ +} + static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) { - if (const_alpha == 255) { - QT_MEMFILL_UINT(dest, length, 0); - } else { - int ialpha = 255 - const_alpha; - PRELOAD_INIT(dest) - for (int i = 0; i < length; ++i) { - PRELOAD_COND(dest) - dest[i] = BYTE_MUL(dest[i], ialpha); - } - } + comp_func_Clear_impl(dest, length, const_alpha); } static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha) { - if (const_alpha == 255) { - QT_MEMFILL_UINT(dest, length, 0); - } else { - int ialpha = 255 - const_alpha; - PRELOAD_INIT(dest) - for (int i = 0; i < length; ++i) { - PRELOAD_COND(dest) - dest[i] = BYTE_MUL(dest[i], ialpha); - } - } + comp_func_Clear_impl(dest, length, const_alpha); } /* diff --git a/src/gui/painting/qdrawhelper_mmx_p.h b/src/gui/painting/qdrawhelper_mmx_p.h index 8482262..f8bc480 100644 --- a/src/gui/painting/qdrawhelper_mmx_p.h +++ b/src/gui/painting/qdrawhelper_mmx_p.h @@ -146,36 +146,30 @@ struct QMMXCommonIntrinsics result = 0 d = d * cia */ +#define comp_func_Clear_impl(dest, length, const_alpha)\ +{\ + if (const_alpha == 255) {\ + qt_memfill(static_cast(dest), quint32(0), length);\ + } else {\ + C_FF; C_80; C_00;\ + m64 ia = MM::negate(MM::load_alpha(const_alpha));\ + for (int i = 0; i < length; ++i) {\ + dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia));\ + }\ + MM::end();\ + }\ +} + template static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) { - if (!length) - return; - - if (const_alpha == 255) { - qt_memfill(static_cast(dest), quint32(0), length); - } else { - C_FF; C_80; C_00; - m64 ia = MM::negate(MM::load_alpha(const_alpha)); - for (int i = 0; i < length; ++i) { - dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia)); - } - } - MM::end(); + comp_func_Clear_impl(dest, length, const_alpha); } template static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha) { - if (const_alpha == 255) { - qt_memfill(static_cast(dest), quint32(0), length); - } else { - C_FF; C_80; C_00; - m64 ia = MM::negate(MM::load_alpha(const_alpha)); - for (int i = 0; i < length; ++i) - dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia)); - } - MM::end(); + comp_func_Clear_impl(dest, length, const_alpha); } /* diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 6c47aac..cb0db4f 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -1549,6 +1549,9 @@ template<> inline void qt_memfill(quint8 *dest, quint8 color, int count) template inline void qt_memfill(T *dest, T value, int count) { + if (!count) + return; + int n = (count + 7) / 8; switch (count & 0x07) { -- cgit v0.12