From 5d9a57432e0d7afb2b9826dc3292d5c1caa105db Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 23 Sep 2012 10:46:05 +0200 Subject: Move the fetch and store pixel functions to qdrawhelper.cpp These functions have begun showing in the tst_symbols unit test as "symbol does not start with q". Since they're never called directly, they're never inlined. Since they were inline, the compiler was probably deciding to not export them. Something changed and it could be anything (new compiler version, new options, etc.). So mark them static. Change-Id: I838dfc94edd7f09c202743bff0daf9d20c10c3a6 Reviewed-by: Lars Knoll --- src/gui/painting/qdrawhelper.cpp | 111 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'src/gui/painting/qdrawhelper.cpp') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index ab19aefa41..ce1567953c 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -250,6 +250,117 @@ static const uint *QT_FASTCALL convertFromARGB32PM(uint *buffer, const uint *src return buffer; } +template static +uint QT_FASTCALL fetchPixel(const uchar *src, int index); + +template <> +inline uint QT_FASTCALL fetchPixel(const uchar *src, int index) +{ + return (src[index >> 3] >> (index & 7)) & 1; +} + +template <> +inline uint QT_FASTCALL fetchPixel(const uchar *src, int index) +{ + return (src[index >> 3] >> (~index & 7)) & 1; +} + +template <> +inline uint QT_FASTCALL fetchPixel(const uchar *src, int index) +{ + return src[index]; +} + +template <> +inline uint QT_FASTCALL fetchPixel(const uchar *src, int index) +{ + return reinterpret_cast(src)[index]; +} + +template <> +inline uint QT_FASTCALL fetchPixel(const uchar *src, int index) +{ + return reinterpret_cast(src)[index]; +} + +template <> +inline uint QT_FASTCALL fetchPixel(const uchar *src, int index) +{ + return reinterpret_cast(src)[index]; +} + +template +inline const uint *QT_FASTCALL fetchPixels(uint *buffer, const uchar *src, int index, int count) +{ + for (int i = 0; i < count; ++i) + buffer[i] = fetchPixel(src, index + i); + return buffer; +} + +template <> +inline const uint *QT_FASTCALL fetchPixels(uint *, const uchar *src, int index, int) +{ + return reinterpret_cast(src) + index; +} + +template static +void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel); + +template <> +inline void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel) +{ + if (pixel) + dest[index >> 3] |= 1 << (index & 7); + else + dest[index >> 3] &= ~(1 << (index & 7)); +} + +template <> +inline void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel) +{ + if (pixel) + dest[index >> 3] |= 1 << (~index & 7); + else + dest[index >> 3] &= ~(1 << (~index & 7)); +} + +template <> +inline void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel) +{ + dest[index] = uchar(pixel); +} + +template <> +inline void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel) +{ + reinterpret_cast(dest)[index] = quint16(pixel); +} + +template <> +inline void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel) +{ + reinterpret_cast(dest)[index] = quint24(pixel); +} + +template <> +inline void QT_FASTCALL storePixel(uchar *dest, int index, uint pixel) +{ + reinterpret_cast(dest)[index] = pixel; +} + +template +inline void QT_FASTCALL storePixels(uchar *dest, const uint *src, int index, int count) +{ + for (int i = 0; i < count; ++i) + storePixel(dest, index + i, src[i]); +} + +template <> +inline void QT_FASTCALL storePixels(uchar *dest, const uint *src, int index, int count) +{ + memcpy(reinterpret_cast(dest) + index, src, count * sizeof(uint)); +} + // Note: // convertToArgb32() assumes that no color channel is less than 4 bits. // convertFromArgb32() assumes that no color channel is more than 8 bits. -- cgit v1.2.3