From d1b52baab4ca98825d93864e4d6ae95dd3e7d733 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 1 Jan 2021 04:56:36 +0200 Subject: [PATCH] remove unused trivial qt_memconvert() and qt_rectconvert() implementations Signed-off-by: Ivailo Monev --- src/gui/painting/qdrawhelper_p.h | 77 +++++++++++----------------------------- 1 file changed, 21 insertions(+), 56 deletions(-) diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 1218cbbaa..036528b16 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -397,51 +397,35 @@ inline void qt_rectfill(T *dest, const T value, template inline void qt_memconvert(DST *dest, const SRC *src, int count) { - if (sizeof(DST) == 1) { - while (count) { - int n = 1; - const SRC color = *src++; - const DST dstColor = qt_colorConvert(color, 0); - while (--count && (*src == color || dstColor == qt_colorConvert(*src, 0))) { - ++n; - ++src; - } - qt_memfill(dest, dstColor, n); - dest += n; - } - } else { - /* Duff's device */ - int n = (count + 7) / 8; - switch (count & 0x07) - { - case 0: do { *dest++ = qt_colorConvert(*src++, 0); - case 7: *dest++ = qt_colorConvert(*src++, 0); - case 6: *dest++ = qt_colorConvert(*src++, 0); - case 5: *dest++ = qt_colorConvert(*src++, 0); - case 4: *dest++ = qt_colorConvert(*src++, 0); - case 3: *dest++ = qt_colorConvert(*src++, 0); - case 2: *dest++ = qt_colorConvert(*src++, 0); - case 1: *dest++ = qt_colorConvert(*src++, 0); - } while (--n > 0); - } + // quint32 to quint16 and vise-versa + Q_ASSERT(sizeof(DST) != sizeof(SRC)) + Q_ASSERT(sizeof(DST) == sizeof(quint16) || sizeof(DST) == sizeof(quint32)) + Q_ASSERT(sizeof(SRC) == sizeof(quint16) || sizeof(SRC) == sizeof(quint32)) + /* Duff's device */ + int n = (count + 7) / 8; + switch (count & 0x07) + { + case 0: do { *dest++ = qt_colorConvert(*src++, 0); + case 7: *dest++ = qt_colorConvert(*src++, 0); + case 6: *dest++ = qt_colorConvert(*src++, 0); + case 5: *dest++ = qt_colorConvert(*src++, 0); + case 4: *dest++ = qt_colorConvert(*src++, 0); + case 3: *dest++ = qt_colorConvert(*src++, 0); + case 2: *dest++ = qt_colorConvert(*src++, 0); + case 1: *dest++ = qt_colorConvert(*src++, 0); + } while (--n > 0); } } -#define QT_TRIVIAL_MEMCONVERT_IMPL(T) \ - template <> \ - inline void qt_memconvert(T *dest, const T *src, int count) \ - { \ - ::memcpy(dest, src, count * sizeof(T)); \ - } -QT_TRIVIAL_MEMCONVERT_IMPL(quint32) -QT_TRIVIAL_MEMCONVERT_IMPL(quint16) -#undef QT_TRIVIAL_MEMCONVERT_IMPL - template inline void qt_rectconvert(DST *dest, const SRC *src, int width, int height, int dstStride, int srcStride) { + // quint32 to quint16 and vise-versa + Q_ASSERT(sizeof(DST) != sizeof(SRC)) + Q_ASSERT(sizeof(DST) == sizeof(quint16) || sizeof(DST) == sizeof(quint32)) + Q_ASSERT(sizeof(SRC) == sizeof(quint16) || sizeof(SRC) == sizeof(quint32)) char *d = (char*)dest; const char *s = (const char*)(src); for (int i = 0; i < height; ++i) { @@ -451,25 +435,6 @@ inline void qt_rectconvert(DST *dest, const SRC *src, } } -#define QT_RECTCONVERT_TRIVIAL_IMPL(T) \ - template <> \ - inline void qt_rectconvert(T *dest, const T *src, \ - int width, int height, \ - int dstStride, int srcStride) \ - { \ - char *d = (char*)dest; \ - const char *s = (const char*)(src); \ - for (int i = 0; i < height; ++i) { \ - ::memcpy(d, s, width * sizeof(T)); \ - d += dstStride; \ - s += srcStride; \ - } \ - } - -QT_RECTCONVERT_TRIVIAL_IMPL(quint32) -QT_RECTCONVERT_TRIVIAL_IMPL(quint16) -#undef QT_RECTCONVERT_TRIVIAL_IMPL - static inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } static const uint qt_bayer_matrix[16][16] = { -- 2.11.0