diff options
Diffstat (limited to 'src/gui/painting')
28 files changed, 1334 insertions, 422 deletions
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index ed45b8ea17..a5a395cce2 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -91,15 +91,13 @@ SOURCES += \ painting/qpaintbuffer.cpp \ painting/qpathsimplifier.cpp -contains(QT_CPU_FEATURES.$$QT_ARCH, sse2) { - SOURCES += painting/qdrawhelper_sse2.cpp - SSSE3_SOURCES += painting/qdrawhelper_ssse3.cpp -} -IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp +SSE2_SOURCES += painting/qdrawhelper_sse2.cpp +SSSE3_SOURCES += painting/qdrawhelper_ssse3.cpp -!ios:contains(QT_CPU_FEATURES.$$QT_ARCH, neon) { - SOURCES += painting/qdrawhelper_neon.cpp - HEADERS += painting/qdrawhelper_neon_p.h +!ios { + CONFIG += no_clang_integrated_as + NEON_SOURCES += painting/qdrawhelper_neon.cpp + NEON_HEADERS += painting/qdrawhelper_neon_p.h NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S } diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp index f22c37aecc..438eb6f34f 100644 --- a/src/gui/painting/qblendfunctions.cpp +++ b/src/gui/painting/qblendfunctions.cpp @@ -403,7 +403,168 @@ void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl, } } +template<QtPixelOrder PixelOrder> +static void qt_blend_argb32pm_on_a2rgb30pm(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ +#ifdef QT_DEBUG_DRAW + fprintf(stdout, "qt_blend_argb32pm_on_a2rgb30pm: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", + destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); + fflush(stdout); +#endif + + const uint *src = (const uint *) srcPixels; + uint *dst = (uint *) destPixels; + if (const_alpha == 256) { + for (int y=0; y<h; ++y) { + for (int x=0; x<w; ++x) { + uint s = src[x]; + dst[x] = qConvertArgb32ToA2rgb30<PixelOrder>(s) + BYTE_MUL_RGB30(dst[x], 255 - qAlpha(s)); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } else if (const_alpha != 0) { + const_alpha = (const_alpha * 255) >> 8; + for (int y=0; y<h; ++y) { + for (int x=0; x<w; ++x) { + uint s = BYTE_MUL(src[x], const_alpha); + dst[x] = qConvertArgb32ToA2rgb30<PixelOrder>(s) + BYTE_MUL_RGB30(dst[x], 255 - qAlpha(s)); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } +} + +template<QtPixelOrder PixelOrder> +void qt_blend_rgb32_on_rgb30(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ +#ifdef QT_DEBUG_DRAW + fprintf(stdout, "qt_blend_rgb32_on_rgb30: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", + destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); + fflush(stdout); +#endif + + if (const_alpha != 256) { + qt_blend_argb32pm_on_a2rgb30pm<PixelOrder>(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); + return; + } + + const uint *src = (const uint *) srcPixels; + uint *dst = (uint *) destPixels; + for (int y = 0; y < h; ++y) { + for (int x = 0; x < w; ++x) { + dst[x] = qConvertRgb32ToRgb30<PixelOrder>(src[x]); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } +} + +static void qt_blend_a2rgb30pm_on_a2rgb30pm(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ +#ifdef QT_DEBUG_DRAW + fprintf(stdout, "qt_blend_a2rgb30pm_on_a2rgb30pm: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", + destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); + fflush(stdout); +#endif + + const uint *src = (const uint *) srcPixels; + uint *dst = (uint *) destPixels; + if (const_alpha == 256) { + for (int y=0; y<h; ++y) { + for (int x=0; x<w; ++x) { + uint s = src[x]; + dst[x] = s + BYTE_MUL_RGB30(dst[x], 255 - qAlphaRgb30(s)); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } else if (const_alpha != 0) { + const uint const_alpha255 = (const_alpha * 255) >> 8; + for (int y=0; y<h; ++y) { + for (int x=0; x<w; ++x) { + uint a = (qAlphaRgb30(src[x]) * const_alpha) >> 8; + uint s = BYTE_MUL_RGB30(src[x], const_alpha255); + dst[x] = s + BYTE_MUL_RGB30(dst[x], 255 - a); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } +} + + +void qt_blend_rgb30_on_rgb30(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ +#ifdef QT_DEBUG_DRAW + fprintf(stdout, "qt_blend_rgb30_on_rgb30: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", + destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); + fflush(stdout); +#endif + + if (const_alpha != 256) { + qt_blend_a2rgb30pm_on_a2rgb30pm(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); + } +} +static void qt_blend_a2bgr30pm_on_a2rgb30pm(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ +#ifdef QT_DEBUG_DRAW + fprintf(stdout, "qt_blend_a2bgr30pm_on_a2rgb32pm: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n", + destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); + fflush(stdout); +#endif + + const uint *src = (const uint *) srcPixels; + uint *dst = (uint *) destPixels; + if (const_alpha == 256) { + for (int y=0; y<h; ++y) { + for (int x=0; x<w; ++x) { + uint s = qRgbSwapRgb30(src[x]); + dst[x] = s + BYTE_MUL_RGB30(dst[x], 255 - qAlphaRgb30(s)); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } else if (const_alpha != 0) { + const uint const_alpha255 = (const_alpha * 255) >> 8; + for (int y=0; y<h; ++y) { + for (int x=0; x<w; ++x) { + uint a = (qAlphaRgb30(src[x]) * const_alpha) >> 8; + uint s = BYTE_MUL_RGB30(src[x], const_alpha255); + dst[x] = qRgbSwapRgb30(s) + BYTE_MUL_RGB30(dst[x], 255 - a); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } +} struct Blend_RGB32_on_RGB32_NoAlpha { inline void write(quint32 *dst, quint32 src) { *dst = src; } @@ -607,7 +768,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGRs30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_Mono 0, // Format_Invalid, @@ -628,7 +793,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_MonoLSB 0, // Format_Invalid, @@ -649,7 +818,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_Indexed8 0, // Format_Invalid, @@ -670,7 +843,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB32 0, // Format_Invalid, @@ -691,7 +868,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB32 0, // Format_Invalid, @@ -712,7 +893,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB32_Premultiplied 0, // Format_Invalid, @@ -733,7 +918,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB16 0, // Format_Invalid, @@ -754,7 +943,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB8565_Premultiplied 0, // Format_Invalid, @@ -775,7 +968,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB666 0, // Format_Invalid, @@ -796,7 +993,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB6666_Premultiplied 0, // Format_Invalid, @@ -817,7 +1018,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB555 0, // Format_Invalid, @@ -838,7 +1043,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB8555_Premultiplied 0, // Format_Invalid, @@ -859,7 +1068,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB888 0, // Format_Invalid, @@ -880,7 +1093,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB444 0, // Format_Invalid, @@ -901,7 +1118,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB4444_Premultiplied 0, // Format_Invalid, @@ -922,7 +1143,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBX8888 0, // Format_Invalid, @@ -948,8 +1173,12 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = #else 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, #endif + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBA8888 0, // Format_Invalid, @@ -970,7 +1199,11 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBA8888_Premultiplied 0, // Format_Invalid, @@ -996,9 +1229,113 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = #else 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, #endif - } + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_BGR30 + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_A2BGR30_Premultiplied + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_RGB30 + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_A2RGB30_Premultiplied + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, }; @@ -1022,7 +1359,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_Mono 0, // Format_Invalid, @@ -1043,7 +1384,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_MonoLSB 0, // Format_Invalid, @@ -1064,7 +1409,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_Indexed8 0, // Format_Invalid, @@ -1085,7 +1434,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB32 0, // Format_Invalid, @@ -1106,7 +1459,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB32 0, // Format_Invalid, @@ -1127,7 +1484,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB32_Premultiplied 0, // Format_Invalid, @@ -1148,7 +1509,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB16 0, // Format_Invalid, @@ -1169,7 +1534,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB8565_Premultiplied 0, // Format_Invalid, @@ -1190,7 +1559,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB666 0, // Format_Invalid, @@ -1211,7 +1584,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB6666_Premultiplied 0, // Format_Invalid, @@ -1232,7 +1609,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB555 0, // Format_Invalid, @@ -1253,7 +1634,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB8555_Premultiplied 0, // Format_Invalid, @@ -1274,7 +1659,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB888 0, // Format_Invalid, @@ -1295,7 +1684,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB444 0, // Format_Invalid, @@ -1316,7 +1709,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB4444_Premultiplied 0, // Format_Invalid, @@ -1337,7 +1734,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBX8888 0, // Format_Invalid, @@ -1363,8 +1764,12 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = #else 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, #endif + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBA8888 0, // Format_Invalid, @@ -1385,7 +1790,11 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBA8888_Premultiplied 0, // Format_Invalid, @@ -1411,9 +1820,113 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = #else 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, #endif - } + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0, // Format_A2RGB30_Premultiplied, + }, + { // Format_BGR30 + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + qt_blend_rgb32_on_rgb30<PixelOrderBGR>, // Format_RGB32, + 0, // Format_ARGB32, + qt_blend_argb32pm_on_a2rgb30pm<PixelOrderBGR>, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + qt_blend_rgb30_on_rgb30, // Format_RGB30, + qt_blend_a2rgb30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_RGB30, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied, + }, + { // Format_A2BGR30_Premultiplied + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + qt_blend_rgb32_on_rgb30<PixelOrderBGR>, // Format_RGB32, + 0, // Format_ARGB32, + qt_blend_argb32pm_on_a2rgb30pm<PixelOrderBGR>, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + qt_blend_rgb30_on_rgb30, // Format_BGR30, + qt_blend_a2rgb30pm_on_a2rgb30pm, // Format_A2BGR30_Premultiplied, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_RGB30, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied, + }, + { // Format_RGB30 + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + qt_blend_rgb32_on_rgb30<PixelOrderRGB>, // Format_RGB32, + 0, // Format_ARGB32, + qt_blend_argb32pm_on_a2rgb30pm<PixelOrderRGB>, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_BGR30, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2BGR30_Premultiplied, + qt_blend_rgb30_on_rgb30, // Format_RGB30, + qt_blend_a2rgb30pm_on_a2rgb30pm, // Format_A2RGB30_Premultiplied, + }, + { // Format_A2RGB30_Premultiplied + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + qt_blend_rgb32_on_rgb30<PixelOrderRGB>, // Format_RGB32, + 0, // Format_ARGB32, + qt_blend_argb32pm_on_a2rgb30pm<PixelOrderRGB>, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_BGR30, + qt_blend_a2bgr30pm_on_a2rgb30pm, // Format_A2BGR30_Premultiplied, + qt_blend_rgb30_on_rgb30, // Format_RGB30, + qt_blend_a2rgb30pm_on_a2rgb30pm // Format_A2RGB30_Premultiplied, + }, }; SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats] = { @@ -1436,7 +1949,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_Mono 0, // Format_Invalid, @@ -1457,7 +1974,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_MonoLSB 0, // Format_Invalid, @@ -1478,7 +1999,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_Indexed8 0, // Format_Invalid, @@ -1499,7 +2024,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB32 0, // Format_Invalid, @@ -1520,7 +2049,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB32 0, // Format_Invalid, @@ -1541,7 +2074,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB32_Premultiplied 0, // Format_Invalid, @@ -1562,7 +2099,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB16 0, // Format_Invalid, @@ -1583,7 +2124,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB8565_Premultiplied 0, // Format_Invalid, @@ -1604,7 +2149,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB666 0, // Format_Invalid, @@ -1625,7 +2174,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB6666_Premultiplied 0, // Format_Invalid, @@ -1646,7 +2199,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB555 0, // Format_Invalid, @@ -1667,7 +2224,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB8555_Premultiplied 0, // Format_Invalid, @@ -1688,7 +2249,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB888 0, // Format_Invalid, @@ -1709,7 +2274,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGB444 0, // Format_Invalid, @@ -1730,7 +2299,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_ARGB4444_Premultiplied 0, // Format_Invalid, @@ -1751,7 +2324,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBX8888 0, // Format_Invalid, @@ -1777,8 +2354,12 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo #else 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, #endif + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBA8888 0, // Format_Invalid, @@ -1799,7 +2380,11 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB4444_Premultiplied, 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, }, { // Format_RGBA8888_Premultiplied 0, // Format_Invalid, @@ -1825,9 +2410,113 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo #else 0, // Format_RGBX8888, 0, // Format_RGBA8888, - 0 // Format_RGBA8888_Premultiplied, + 0, // Format_RGBA8888_Premultiplied, #endif - } + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_BGR30 + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_A2BGR30_Premultiplied + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_RGB30 + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, + { // Format_A2RGB30_Premultiplied + 0, // Format_Invalid, + 0, // Format_Mono, + 0, // Format_MonoLSB, + 0, // Format_Indexed8, + 0, // Format_RGB32, + 0, // Format_ARGB32, + 0, // Format_ARGB32_Premultiplied, + 0, // Format_RGB16, + 0, // Format_ARGB8565_Premultiplied, + 0, // Format_RGB666, + 0, // Format_ARGB6666_Premultiplied, + 0, // Format_RGB555, + 0, // Format_ARGB8555_Premultiplied, + 0, // Format_RGB888, + 0, // Format_RGB444, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0, // Format_RGBA8888_Premultiplied, + 0, // Format_BGR30, + 0, // Format_A2BGR30_Premultiplied, + 0, // Format_RGB30, + 0 // Format_A2RGB30_Premultiplied, + }, }; QT_END_NAMESPACE diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h index 5c625f664e..b13b793a3d 100644 --- a/src/gui/painting/qblittable_p.h +++ b/src/gui/painting/qblittable_p.h @@ -75,6 +75,9 @@ public: SourceOverScaledPixmapCapability = 0x0008, AlphaFillRectCapability = 0x0010, OpacityPixmapCapability = 0x0020, + DrawScaledCachedGlyphsCapability = 0x0040, + SubPixelGlyphsCapability = 0x0080, + ComplexClipCapability = 0x0100, // Internal ones OutlineCapability = 0x0001000 @@ -103,6 +106,17 @@ public: Q_UNUSED(opacity); qWarning("Please implement drawPixmapOpacity function in your platform or remove OpacityPixmapCapability from it"); } + virtual bool drawCachedGlyphs(const QPaintEngineState *state, QFontEngine::GlyphFormat glyphFormat, int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, QFontEngine *fontEngine) { + Q_UNUSED(state); + Q_UNUSED(glyphFormat); + Q_UNUSED(numGlyphs); + Q_UNUSED(glyphs); + Q_UNUSED(positions); + Q_UNUSED(fontEngine); + qWarning("Please implement drawCachedGlyphs function in your platform or remove DrawCachedGlyphsCapability from it"); + return true; + } + QImage *lock(); void unlock(); diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 1ede5a3682..e5de2678a4 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -173,7 +173,7 @@ public: QColor toCmyk() const; QColor toHsl() const; - QColor convertTo(Spec colorSpec) const; + QColor convertTo(Spec colorSpec) const Q_REQUIRED_RESULT; static QColor fromRgb(QRgb rgb); static QColor fromRgba(QRgb rgba); @@ -190,10 +190,10 @@ public: static QColor fromHsl(int h, int s, int l, int a = 255); static QColor fromHslF(qreal h, qreal s, qreal l, qreal a = 1.0); - QColor light(int f = 150) const; - QColor lighter(int f = 150) const; - QColor dark(int f = 200) const; - QColor darker(int f = 200) const; + QColor light(int f = 150) const Q_REQUIRED_RESULT; + QColor lighter(int f = 150) const Q_REQUIRED_RESULT; + QColor dark(int f = 200) const Q_REQUIRED_RESULT; + QColor darker(int f = 200) const Q_REQUIRED_RESULT; QColor &operator=(const QColor &); QColor &operator=(Qt::GlobalColor color); diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index 72b6279b2f..adc81582e2 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -301,9 +301,8 @@ inline bool operator<(const RGBData &data, const char *name) static bool get_named_rgb(const char *name_no_space, QRgb *rgb) { - QByteArray name = QByteArray(name_no_space).toLower(); - const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name.constData()); - if ((r != rgbTbl + rgbTblSize) && !(name.constData() < *r)) { + const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name_no_space); + if ((r != rgbTbl + rgbTblSize) && !(name_no_space < *r)) { *rgb = r->value; return true; } @@ -319,7 +318,7 @@ bool qt_get_named_rgb(const char *name, QRgb* rgb) int pos = 0; for(int i = 0; i < len; i++) { if(name[i] != '\t' && name[i] != ' ') - name_no_space[pos++] = name[i]; + name_no_space[pos++] = QChar::toLower(name[i]); } name_no_space[pos] = 0; @@ -334,7 +333,7 @@ bool qt_get_named_rgb(const QChar *name, int len, QRgb *rgb) int pos = 0; for(int i = 0; i < len; i++) { if(name[i] != QLatin1Char('\t') && name[i] != QLatin1Char(' ')) - name_no_space[pos++] = name[i].toLatin1(); + name_no_space[pos++] = name[i].toLower().toLatin1(); } name_no_space[pos] = 0; return get_named_rgb(name_no_space, rgb); @@ -352,6 +351,7 @@ QStringList qt_get_colornames() { int i = 0; QStringList lst; + lst.reserve(rgbTblSize); for (i = 0; i < rgbTblSize; i++) lst << QLatin1String(rgbTbl[i].name); return lst; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 9293fc32dc..55a48395c8 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -575,6 +575,42 @@ static const uint *QT_FASTCALL convertRGBXFromARGB32PM(uint *buffer, const uint return buffer; } +template<QtPixelOrder PixelOrder> +static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const uint *src, int count, + const QPixelLayout *, const QRgb *) +{ + for (int i = 0; i < count; ++i) + buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]); + return buffer; +} + +template<QtPixelOrder PixelOrder> +static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const uint *src, int count, + const QPixelLayout *, const QRgb *) +{ + for (int i = 0; i < count; ++i) + buffer[i] = qConvertArgb32ToA2rgb30<PixelOrder>(src[i]); + return buffer; +} + +template<QtPixelOrder PixelOrder> +static const uint *QT_FASTCALL convertRGB30FromRGB32(uint *buffer, const uint *src, int count, + const QPixelLayout *, const QRgb *) +{ + for (int i = 0; i < count; ++i) + buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(src[i]); + return buffer; +} + +template<QtPixelOrder PixelOrder> +static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint *src, int count, + const QPixelLayout *, const QRgb *) +{ + for (int i = 0; i < count; ++i) + buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(qUnpremultiply(src[i])); + return buffer; +} + template <QPixelLayout::BPP bpp> static uint QT_FASTCALL fetchPixel(const uchar *src, int index); @@ -722,8 +758,12 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = { #else { 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBXFromARGB32PM, convertRGBXFromRGB32 }, // Format_RGBX8888 { 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertRGBA8888ToARGB32PM, convertRGBA8888FromARGB32PM, 0 }, // Format_RGBA8888 (ABGR32) - { 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, 0 } // Format_RGBA8888_Premultiplied + { 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertRGBA8888PMToARGB32PM, convertRGBA8888PMFromARGB32PM, 0 }, // Format_RGBA8888_Premultiplied #endif + { 10, 20, 10, 10, 10, 0, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertRGB30FromARGB32PM<PixelOrderBGR>, convertRGB30FromRGB32<PixelOrderBGR> }, // Format_BGR30 + { 10, 20, 10, 10, 10, 0, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderBGR>, convertA2RGB30PMFromARGB32PM<PixelOrderBGR>, 0 }, // Format_A2BGR30_Premultiplied + { 10, 0, 10, 10, 10, 20, 0, 30, false, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertRGB30FromARGB32PM<PixelOrderRGB>, convertRGB30FromRGB32<PixelOrderRGB> }, // Format_RGB30 + { 10, 0, 10, 10, 10, 20, 2, 30, true, QPixelLayout::BPP32, convertA2RGB30PMToARGB32PM<PixelOrderRGB>, convertA2RGB30PMFromARGB32PM<PixelOrderRGB>, 0 }, // Format_A2RGB30_Premultiplied }; FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = { @@ -831,6 +871,10 @@ static DestFetchProc destFetchProc[QImage::NImageFormats] = destFetch, // Format_RGBX8888 destFetch, // Format_RGBA8888 destFetch, // Format_RGBA8888_Premultiplied + destFetch, // Format_BGR30 + destFetch, // Format_A2BGR30_Premultiplied + destFetch, // Format_RGB30 + destFetch, // Format_A2RGB30_Premultiplied }; /* @@ -970,7 +1014,11 @@ static DestStoreProc destStoreProc[QImage::NImageFormats] = destStore, // Format_ARGB4444_Premultiplied destStore, // Format_RGBX8888 destStore, // Format_RGBA8888 - destStore // Format_RGBA8888_Premultiplied + destStore, // Format_RGBA8888_Premultiplied + destStore, // Format_BGR30 + destStore, // Format_A2BGR30_Premultiplied + destStore, // Format_RGB30 + destStore, // Format_A2RGB30_Premultiplied }; /* @@ -2221,7 +2269,11 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchUntransformed, // ARGB4444_Premultiplied fetchUntransformed, // RGBX8888 fetchUntransformed, // RGBA8888 - fetchUntransformed // RGBA8888_Premultiplied + fetchUntransformed, // RGBA8888_Premultiplied + fetchUntransformed, // Format_BGR30 + fetchUntransformed, // Format_A2BGR30_Premultiplied + fetchUntransformed, // Format_RGB30 + fetchUntransformed, // Format_A2RGB30_Premultiplied }, // Tiled { @@ -2243,7 +2295,11 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchUntransformed, // ARGB4444_Premultiplied fetchUntransformed, // RGBX8888 fetchUntransformed, // RGBA8888 - fetchUntransformed // RGBA8888_Premultiplied + fetchUntransformed, // RGBA8888_Premultiplied + fetchUntransformed, // BGR30 + fetchUntransformed, // A2BGR30_Premultiplied + fetchUntransformed, // RGB30 + fetchUntransformed // A2RGB30_Premultiplied }, // Transformed { @@ -2266,6 +2322,10 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformed<BlendTransformed>, // RGBX8888 fetchTransformed<BlendTransformed>, // RGBA8888 fetchTransformed<BlendTransformed>, // RGBA8888_Premultiplied + fetchTransformed<BlendTransformed>, // BGR30 + fetchTransformed<BlendTransformed>, // A2BGR30_Premultiplied + fetchTransformed<BlendTransformed>, // RGB30 + fetchTransformed<BlendTransformed>, // A2RGB30_Premultiplied }, { 0, // TransformedTiled @@ -2287,6 +2347,10 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformed<BlendTransformedTiled>, // RGBX8888 fetchTransformed<BlendTransformedTiled>, // RGBA8888 fetchTransformed<BlendTransformedTiled>, // RGBA8888_Premultiplied + fetchTransformed<BlendTransformedTiled>, // BGR30 + fetchTransformed<BlendTransformedTiled>, // A2BGR30_Premultiplied + fetchTransformed<BlendTransformedTiled>, // RGB30 + fetchTransformed<BlendTransformedTiled>, // A2RGB30_Premultiplied }, { 0, // Bilinear @@ -2307,7 +2371,11 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformedBilinear<BlendTransformedBilinear>, // ARGB4444_Premultiplied fetchTransformedBilinear<BlendTransformedBilinear>, // RGBX8888 fetchTransformedBilinear<BlendTransformedBilinear>, // RGBA8888 - fetchTransformedBilinear<BlendTransformedBilinear> // RGBA8888_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinear>, // RGBA8888_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinear>, // BGR30 + fetchTransformedBilinear<BlendTransformedBilinear>, // A2BGR30_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinear>, // RGB30 + fetchTransformedBilinear<BlendTransformedBilinear>, // A2RGB30_Premultiplied }, { 0, // BilinearTiled @@ -2328,7 +2396,11 @@ static SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformedBilinear<BlendTransformedBilinearTiled>, // ARGB4444_Premultiplied fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGBX8888 fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGBA8888 - fetchTransformedBilinear<BlendTransformedBilinearTiled> // RGBA8888_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGBA8888_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinearTiled>, // BGR30 + fetchTransformedBilinear<BlendTransformedBilinearTiled>, // A2BGR30_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGB30 + fetchTransformedBilinear<BlendTransformedBilinearTiled> // A2RGB30_Premultiplied }, }; @@ -4263,7 +4335,6 @@ static CompositionFunctionSolid functionForModeSolid_C[] = { rasterop_solid_NotSource, rasterop_solid_NotSourceAndDestination, rasterop_solid_SourceAndNotDestination, - rasterop_solid_SourceAndNotDestination, rasterop_solid_NotSourceOrDestination, rasterop_solid_SourceOrNotDestination, rasterop_solid_ClearDestination, @@ -4307,7 +4378,6 @@ static CompositionFunction functionForMode_C[] = { rasterop_NotSource, rasterop_NotSourceAndDestination, rasterop_SourceAndNotDestination, - rasterop_SourceAndNotDestination, rasterop_NotSourceOrDestination, rasterop_SourceOrNotDestination, rasterop_ClearDestination, @@ -5749,6 +5819,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_untransformed_generic, blend_untransformed_generic, blend_untransformed_generic, + blend_untransformed_generic, + blend_untransformed_generic, + blend_untransformed_generic, + blend_untransformed_generic, }, // Tiled { @@ -5771,6 +5845,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_tiled_generic, blend_tiled_generic, blend_tiled_generic, + blend_tiled_generic, + blend_tiled_generic, + blend_tiled_generic, + blend_tiled_generic, }, // Transformed { @@ -5793,6 +5871,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, blend_src_generic, blend_src_generic, + blend_src_generic, + blend_src_generic, + blend_src_generic, + blend_src_generic, }, // TransformedTiled { @@ -5814,6 +5896,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, blend_src_generic, blend_src_generic, + blend_src_generic, + blend_src_generic, + blend_src_generic, + blend_src_generic, blend_src_generic }, // Bilinear @@ -5837,6 +5923,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, blend_src_generic, blend_src_generic, + blend_src_generic, + blend_src_generic, + blend_src_generic, + blend_src_generic, }, // BilinearTiled { @@ -5859,6 +5949,10 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // RGBX8888 blend_src_generic, // RGBA8888 blend_src_generic, // RGBA8888_Premultiplied + blend_src_generic, // BGR30 + blend_src_generic, // A2BGR30_Premultiplied + blend_src_generic, // RGB30 + blend_src_generic, // A2RGB30_Premultiplied } }; @@ -6379,7 +6473,6 @@ static void qt_rectfill_nonpremul_rgba(QRasterBuffer *rasterBuffer, ARGB2RGBA(qUnpremultiply(color)), x, y, width, height, rasterBuffer->bytesPerLine()); } - // Map table for destination image format. Contains function pointers // for blends of various types unto the destination @@ -6527,7 +6620,43 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = #endif 0, qt_rectfill_rgba - } + }, + // Format_BGR30 + { + blend_color_generic, + blend_src_generic, + 0, + 0, + 0, + 0 + }, + // Format_A2BGR30_Premultiplied + { + blend_color_generic, + blend_src_generic, + 0, + 0, + 0, + 0 + }, + // Format_RGB30 + { + blend_color_generic, + blend_src_generic, + 0, + 0, + 0, + 0 + }, + // Format_A2RGB30_Premultiplied + { + blend_color_generic, + blend_src_generic, + 0, + 0, + 0, + 0 + }, }; #if defined(Q_CC_MSVC) && !defined(_MIPS_) @@ -6588,10 +6717,13 @@ void qt_memfill16(quint16 *dest, quint16 color, int count) } #endif #if !defined(__SSE2__) && !defined(__ARM_NEON__) +# ifdef QT_COMPILER_SUPPORTS_MIPS_DSP +extern "C" void qt_memfill32_asm_mips_dsp(quint32 *, quint32, int); +# endif + void qt_memfill32(quint32 *dest, quint32 color, int count) { # ifdef QT_COMPILER_SUPPORTS_MIPS_DSP - extern "C" qt_memfill32_asm_mips_dsp(quint32 *, quint32, int); qt_memfill32_asm_mips_dsp(dest, color, count); # else qt_memfill_template<quint32>(dest, color, count); @@ -6667,14 +6799,6 @@ void qInitDrawhelperAsm() functionForModeSolidAsm = qt_functionForModeSolid_SSE2; #endif // SSE2 -#ifdef QT_COMPILER_SUPPORTS_IWMMXT - if (features & IWMMXT) { - functionForModeAsm = qt_functionForMode_IWMMXT; - functionForModeSolidAsm = qt_functionForModeSolid_IWMMXT; - qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_iwmmxt; - } -#endif // IWMMXT - #if defined(__ARM_NEON__) && !defined(Q_OS_IOS) qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon; @@ -6713,7 +6837,13 @@ void qInitDrawhelperAsm() qt_fetch_radial_gradient = qt_fetch_radial_gradient_neon; #endif -#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) +#ifdef Q_PROCESSOR_MIPS_32 + qt_memfill32 = qt_memfill32_asm_mips_dsp; +#endif // Q_PROCESSOR_MIPS_32 + +#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) + if (features & (DSP | DSPR2)) { + // Composition functions are all DSP r1 functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp; functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp; functionForMode_C[QPainter::CompositionMode_DestinationOver] = comp_func_DestinationOver_mips_dsp; @@ -6757,8 +6887,9 @@ void qInitDrawhelperAsm() #else qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dsp; #endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2 + } +#endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2 -#endif // QT_COMPILER_SUPPORTS_MIPS_DSP if (functionForModeSolidAsm) { const int destinationMode = QPainter::CompositionMode_Destination; functionForModeSolidAsm[destinationMode] = functionForModeSolid_C[destinationMode]; diff --git a/src/gui/painting/qdrawhelper_iwmmxt.cpp b/src/gui/painting/qdrawhelper_iwmmxt.cpp deleted file mode 100644 index 7b734fdfc6..0000000000 --- a/src/gui/painting/qdrawhelper_iwmmxt.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifdef QT_COMPILER_SUPPORTS_IWMMXT - -#include <mmintrin.h> -#if defined(Q_OS_WINCE) -# include "qplatformdefs.h" -#endif -#if !defined(__IWMMXT__) && !defined(Q_OS_WINCE) -# include <xmmintrin.h> -#elif defined(Q_OS_WINCE_STD) && defined(_X86_) -# pragma warning(disable: 4391) -# include <xmmintrin.h> -#endif - -#include <private/qdrawhelper_sse_p.h> - -QT_BEGIN_NAMESPACE - -#ifndef _MM_SHUFFLE -#define _MM_SHUFFLE(fp3,fp2,fp1,fp0) \ - (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | (fp0)) -#endif - -struct QIWMMXTIntrinsics : public QMMXCommonIntrinsics -{ - static inline m64 alpha(m64 x) { - return _mm_shuffle_pi16 (x, _MM_SHUFFLE(3, 3, 3, 3)); - } - - static inline m64 _load_alpha(uint x, const m64 &mmx_0x0000) { - m64 t = _mm_unpacklo_pi8(_mm_cvtsi32_si64(x), mmx_0x0000); - return _mm_shuffle_pi16(t, _MM_SHUFFLE(0, 0, 0, 0)); - } - - static inline void end() { - } -}; - -CompositionFunctionSolid qt_functionForModeSolid_IWMMXT[numCompositionFunctions] = { - comp_func_solid_SourceOver<QIWMMXTIntrinsics>, - comp_func_solid_DestinationOver<QIWMMXTIntrinsics>, - comp_func_solid_Clear<QIWMMXTIntrinsics>, - comp_func_solid_Source<QIWMMXTIntrinsics>, - 0, - comp_func_solid_SourceIn<QIWMMXTIntrinsics>, - comp_func_solid_DestinationIn<QIWMMXTIntrinsics>, - comp_func_solid_SourceOut<QIWMMXTIntrinsics>, - comp_func_solid_DestinationOut<QIWMMXTIntrinsics>, - comp_func_solid_SourceAtop<QIWMMXTIntrinsics>, - comp_func_solid_DestinationAtop<QIWMMXTIntrinsics>, - comp_func_solid_XOR<QIWMMXTIntrinsics>, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // svg 1.2 modes - rasterop_solid_SourceOrDestination<QIWMMXTIntrinsics>, - rasterop_solid_SourceAndDestination<QIWMMXTIntrinsics>, - rasterop_solid_SourceXorDestination<QIWMMXTIntrinsics>, - rasterop_solid_NotSourceAndNotDestination<QIWMMXTIntrinsics>, - rasterop_solid_NotSourceOrNotDestination<QIWMMXTIntrinsics>, - rasterop_solid_NotSourceXorDestination<QIWMMXTIntrinsics>, - rasterop_solid_NotSource<QIWMMXTIntrinsics>, - rasterop_solid_NotSourceAndDestination<QIWMMXTIntrinsics>, - rasterop_solid_SourceAndNotDestination<QIWMMXTIntrinsics>, - rasterop_solid_NotSourceOrDestination<QIWMMXTIntrinsics>, - rasterop_solid_SourceOrNotDestination<QIWMMXTIntrinsics>, - rasterop_solid_ClearDestination<QIWMMXTIntrinsics>, - rasterop_solid_SetDestination<QIWMMXTIntrinsics>, - rasterop_solid_NotDestination<QIWMMXTIntrinsics> -}; - -CompositionFunction qt_functionForMode_IWMMXT[] = { - comp_func_SourceOver<QIWMMXTIntrinsics>, - comp_func_DestinationOver<QIWMMXTIntrinsics>, - comp_func_Clear<QIWMMXTIntrinsics>, - comp_func_Source<QIWMMXTIntrinsics>, - comp_func_Destination, - comp_func_SourceIn<QIWMMXTIntrinsics>, - comp_func_DestinationIn<QIWMMXTIntrinsics>, - comp_func_SourceOut<QIWMMXTIntrinsics>, - comp_func_DestinationOut<QIWMMXTIntrinsics>, - comp_func_SourceAtop<QIWMMXTIntrinsics>, - comp_func_DestinationAtop<QIWMMXTIntrinsics>, - comp_func_XOR<QIWMMXTIntrinsics>, - comp_func_Plus, - comp_func_Multiply, - comp_func_Screen, - comp_func_Overlay, - comp_func_Darken, - comp_func_Lighten, - comp_func_ColorDodge, - comp_func_ColorBurn, - comp_func_HardLight, - comp_func_SoftLight, - comp_func_Difference, - comp_func_Exclusion, - rasterop_SourceOrDestination, - rasterop_SourceAndDestination, - rasterop_SourceXorDestination, - rasterop_NotSourceAndNotDestination, - rasterop_NotSourceOrNotDestination, - rasterop_NotSourceXorDestination, - rasterop_NotSource, - rasterop_NotSourceAndDestination, - rasterop_SourceAndNotDestination, - rasterop_NotSourceOrDestination, - rasterop_SourceOrNotDestination, - rasterop_ClearDestination, - rasterop_SetDestination, - rasterop_NotDestination -}; - -void qt_blend_color_argb_iwmmxt(int count, const QSpan *spans, void *userData) -{ - qt_blend_color_argb_x86<QIWMMXTIntrinsics>(count, spans, userData, - (CompositionFunctionSolid*)qt_functionForModeSolid_IWMMXT); -} - -#endif // QT_COMPILER_SUPPORTS_IWMMXT - -QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 1c05fc305a..d6b557af01 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -672,6 +672,36 @@ static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16_32(uint x, uint a) { return t; } +#if defined(Q_CC_RVCT) +# pragma push +# pragma arm +#endif +static Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } +#if defined(Q_CC_RVCT) +# pragma pop +#endif + +static Q_ALWAYS_INLINE uint BYTE_MUL_RGB30(uint x, uint a) { + uint xa = x >> 30; + uint xr = (x >> 20) & 0x3ff; + uint xg = (x >> 10) & 0x3ff; + uint xb = x & 0x3ff; + xa = qt_div_255(xa * a); + xr = qt_div_255(xr * a); + xg = qt_div_255(xg * a); + xb = qt_div_255(xb * a); + return (xa << 30) | (xr << 20) | (xg << 10) | xb; +} + +static Q_ALWAYS_INLINE uint qAlphaRgb30(uint c) +{ + uint a = c >> 30; + a |= a << 2; + a |= a << 4; + return a; +} + + // FIXME: Remove when all Qt modules have stopped using PREMUL and INV_PREMUL #define PREMUL(x) qPremultiply(x) #define INV_PREMUL(p) qUnpremultiply(p) @@ -795,15 +825,6 @@ do { \ } \ } while (0) -#if defined(Q_CC_RVCT) -# pragma push -# pragma arm -#endif -static Q_ALWAYS_INLINE int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } -#if defined(Q_CC_RVCT) -# pragma pop -#endif - inline ushort qConvertRgb32To16(uint c) { return (((c) >> 3) & 0x001f) @@ -819,6 +840,84 @@ inline QRgb qConvertRgb16To32(uint c) | ((((c) << 8) & 0xf80000) | (((c) << 3) & 0x70000)); } +enum QtPixelOrder { + PixelOrderRGB, + PixelOrderBGR +}; + +template<enum QtPixelOrder> inline uint qConvertArgb32ToA2rgb30(QRgb); + +template<enum QtPixelOrder> inline uint qConvertRgb32ToRgb30(QRgb); + +template<enum QtPixelOrder> inline QRgb qConvertA2rgb30ToArgb32(uint c); + +template<> +inline uint qConvertArgb32ToA2rgb30<PixelOrderBGR>(QRgb c) +{ + return (c & 0xc0000000) + | (((c << 22) & 0x3fc00000) | ((c << 14) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c >> 14) & 0x000003fc) | ((c >> 22) & 0x00000003)); +} + +template<> +inline uint qConvertArgb32ToA2rgb30<PixelOrderRGB>(QRgb c) +{ + return (c & 0xc0000000) + | (((c << 6) & 0x3fc00000) | ((c >> 2) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c << 2) & 0x000003fc) | ((c >> 6) & 0x00000003)); +} + +template<> +inline uint qConvertRgb32ToRgb30<PixelOrderBGR>(QRgb c) +{ + return 0xc0000000 + | (((c << 22) & 0x3fc00000) | ((c << 14) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c >> 14) & 0x000003fc) | ((c >> 22) & 0x00000003)); +} + +template<> +inline uint qConvertRgb32ToRgb30<PixelOrderRGB>(QRgb c) +{ + return 0xc0000000 + | (((c << 6) & 0x3fc00000) | ((c >> 2) & 0x00300000)) + | (((c << 4) & 0x000ff000) | ((c >> 4) & 0x00000c00)) + | (((c << 2) & 0x000003fc) | ((c >> 6) & 0x00000003)); +} + +template<> +inline QRgb qConvertA2rgb30ToArgb32<PixelOrderBGR>(uint c) +{ + uint a = c >> 30; + a |= a << 2; + a |= a << 4; + return (a << 24) + | ((c << 14) & 0x00ff0000) + | ((c >> 4) & 0x0000ff00) + | ((c >> 22) & 0x000000ff); +} + +template<> +inline QRgb qConvertA2rgb30ToArgb32<PixelOrderRGB>(uint c) +{ + uint a = c >> 30; + a |= a << 2; + a |= a << 4; + return (a << 24) + | ((c >> 6) & 0x00ff0000) + | ((c >> 4) & 0x0000ff00) + | ((c >> 2) & 0x000000ff); +} + +inline uint qRgbSwapRgb30(uint c) +{ + const uint ag = c & 0xc00ffc00; + const uint rb = c & 0x3ff003ff; + return ag | (rb << 20) | (rb >> 20); +} + inline int qRed565(quint16 rgb) { const int r = (rgb & 0xf800); return (r >> 8) | (r >> 13); diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h index 97c1f87c2a..dfbb38eb2d 100644 --- a/src/gui/painting/qdrawhelper_x86_p.h +++ b/src/gui/painting/qdrawhelper_x86_p.h @@ -82,13 +82,6 @@ extern CompositionFunction qt_functionForMode_SSE2[]; extern CompositionFunctionSolid qt_functionForModeSolid_SSE2[]; #endif // __SSE2__ -#ifdef QT_COMPILER_SUPPORTS_IWMMXT -void qt_blend_color_argb_iwmmxt(int count, const QSpan *spans, void *userData); - -extern CompositionFunction qt_functionForMode_IWMMXT[]; -extern CompositionFunctionSolid qt_functionForModeSolid_IWMMXT[]; -#endif - static const int numCompositionFunctions = 38; QT_END_NAMESPACE diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index d2c1ae3a3c..93062899d3 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -100,7 +100,7 @@ public: bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); } qreal determinant() const { return _m11*_m22 - _m12*_m21; } - QMatrix inverted(bool *invertible = 0) const; + QMatrix inverted(bool *invertible = 0) const Q_REQUIRED_RESULT; bool operator==(const QMatrix &) const; bool operator!=(const QMatrix &) const; diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp index 087231df43..a5e12da3d1 100644 --- a/src/gui/painting/qmemrotate.cpp +++ b/src/gui/painting/qmemrotate.cpp @@ -532,7 +532,11 @@ MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3] = { 0, 0, 0 }, // Format_ARGB4444_Premultiplied, { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBX8888, { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBA8888, - { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 } // Format_RGBA8888_Premultiplied, + { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBA8888_Premultiplied, + { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_BGB30, + { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_A2BGR30_Premultiplied, + { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGB30, + { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_A2RGB30_Premultiplied, }; QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 421d706230..e8bdc495c2 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -1242,6 +1242,11 @@ void QPaintBufferEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con void QPaintBufferEngine::drawStaticTextItem(QStaticTextItem *staticTextItem) { + if (staticTextItem->usesRawFont) { + QPaintEngineEx::drawStaticTextItem(staticTextItem); // Draw as path + return; + } + QVariantList variants; variants << QVariant(staticTextItem->font); diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index 7b928ba5f6..2a17a13517 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -250,7 +250,7 @@ private: friend class QFontEngineWin; friend class QMacPrintEngine; friend class QMacPrintEnginePrivate; - friend class QFontEngineQPA; + friend class QFontEngineQPF2; friend class QPainter; friend class QPainterPrivate; friend class QWidget; diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 67a692e2db..9a3b8f421b 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -132,6 +132,19 @@ public: return checkStateAgainstMask(capabillitiesState, opacityPixmapMask); } + bool canBlitterDrawCachedGlyphs(const QTransform &transform, QFontEngine::GlyphFormat requestedGlyphFormat, bool complexClip) const + { + if (transform.type() > QTransform::TxScale) + return false; + if (!(m_capabilities & QBlittable::DrawScaledCachedGlyphsCapability)) + return false; + if (requestedGlyphFormat == QFontEngine::Format_ARGB && !(m_capabilities & QBlittable::SubPixelGlyphsCapability)) + return false; + if (complexClip && !(m_capabilities & QBlittable::ComplexClipCapability)) + return false; + return true; + } + inline void updateState(uint mask, bool on) { updateStateBits(&capabillitiesState, mask, on); } @@ -798,6 +811,28 @@ void QBlitterPaintEngine::drawStaticTextItem(QStaticTextItem *sti) #endif } +bool QBlitterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, QFontEngine *fontEngine) +{ + Q_D(QBlitterPaintEngine); + QFontEngine::GlyphFormat glyphFormat = d->glyphCacheFormat; + if (fontEngine->glyphFormat != QFontEngine::Format_None) + glyphFormat = fontEngine->glyphFormat; + + const QClipData *clipData = d->clip(); + const bool complexClip = clipData && !clipData->hasRectClip; + + const QPainterState *s = state(); + if (d->caps.canBlitterDrawCachedGlyphs(s->transform(), glyphFormat, complexClip)) { + d->unlock(); + const bool result = d->pmData->blittable()->drawCachedGlyphs(s, glyphFormat, numGlyphs, glyphs, positions, fontEngine); + // Lock again as the raster paint engine might draw decorations now. + d->lock(); + return result; + } else { + return QRasterPaintEngine::drawCachedGlyphs(numGlyphs, glyphs, positions, fontEngine); + } +} + QT_END_NAMESPACE #endif //QT_NO_BLITTABLE diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index d917a30f1f..72dba8e49e 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -107,6 +107,7 @@ public: void drawPoints(const QPoint *points, int pointCount); void stroke(const QVectorPath &path, const QPen &pen); void drawStaticTextItem(QStaticTextItem *); + bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, QFontEngine *fontEngine); }; QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 2f7e32285f..914691375a 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -423,6 +423,8 @@ void QRasterPaintEngine::init() case QImage::Format_ARGB32: case QImage::Format_RGBA8888_Premultiplied: case QImage::Format_RGBA8888: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: gccaps |= PorterDuff; break; case QImage::Format_RGB32: @@ -432,6 +434,8 @@ void QRasterPaintEngine::init() case QImage::Format_RGB888: case QImage::Format_RGB16: case QImage::Format_RGBX8888: + case QImage::Format_BGR30: + case QImage::Format_RGB30: break; default: break; @@ -2243,6 +2247,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe case QImage::Format_ARGB8555_Premultiplied: case QImage::Format_ARGB4444_Premultiplied: case QImage::Format_RGBA8888_Premultiplied: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: // Combine premultiplied color with the opacity set on the painter. d->solid_color_filler.solid.color = ((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff) diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 4bfdbd91e0..c4703b3712 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -250,7 +250,7 @@ private: QRect toNormalizedFillRect(const QRectF &rect); inline void ensureBrush(const QBrush &brush) { - if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) + if (!qbrush_fast_equals(state()->lastBrush, brush) || state()->fillFlags) updateBrush(brush); } inline void ensureBrush() { ensureBrush(state()->brush); } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3f387d575b..3af8fdea2e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -229,16 +229,11 @@ QTransform QPainterPrivate::viewTransform() const int QPainterPrivate::effectiveDevicePixelRatio() const { - // Limited feature introduction for Qt 5.0.0, remove ifdef in a later release. -#ifdef Q_OS_MAC // Special cases for devices that does not support PdmDevicePixelRatio go here: if (device->devType() == QInternal::Printer) return 1; return qMax(1, device->metric(QPaintDevice::PdmDevicePixelRatio)); -#else - return 1; -#endif } QTransform QPainterPrivate::hidpiScaleTransform() const @@ -1111,6 +1106,11 @@ void QPainterPrivate::updateState(QPainterState *newState) \li \inlineimage qpainter-pathstroking.png \endtable + Text drawing is done using drawText(). When you need + fine-grained positioning, boundingRect() tells you where a given + drawText() command will draw. + + \section1 Drawing Pixmaps and Images There are functions to draw pixmaps/images, namely drawPixmap(), drawImage() and drawTiledPixmap(). Both drawPixmap() and drawImage() @@ -1118,15 +1118,25 @@ void QPainterPrivate::updateState(QPainterState *newState) on-screen while drawImage() may be faster on a QPrinter or other devices. - Text drawing is done using drawText(). When you need - fine-grained positioning, boundingRect() tells you where a given - drawText() command will draw. - There is a drawPicture() function that draws the contents of an entire QPicture. The drawPicture() function is the only function that disregards all the painter's settings as QPicture has its own settings. + \section2 Drawing High Resolution Versions of Pixmaps and Images + + High resolution versions of pixmaps have a \e{device pixel ratio} value larger + than 1 (see QImageReader, QPixmap::devicePixelRatio()). Should it match the value + of the underlying QPaintDevice, it is drawn directly onto the device with no + additional transformation applied. + + This is for example the case when drawing a QPixmap of 64x64 pixels size with + a device pixel ratio of 2 onto a high DPI screen which also has + a device pixel ratio of 2. Note that the pixmap is then effectively 32x32 + pixels in \e{user space}. Code paths in Qt that calculate layout geometry + based on the pixmap size will use this size. The net effect of this is that + the pixmap is displayed as high DPI pixmap rather than a large pixmap. + \section1 Rendering Quality To get the optimal rendering result using QPainter, you should use @@ -5029,6 +5039,8 @@ static inline QPointF roundInDeviceCoordinates(const QPointF &p, const QTransfor into the given \a target in the paint device. \note The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree. + \note See \l{Drawing High Resolution Versions of Pixmaps and Images} on how this is affected + by QPixmap::devicePixelRatio(). \table 100% \row @@ -5043,7 +5055,7 @@ static inline QPointF roundInDeviceCoordinates(const QPointF &p, const QTransfor transparent. Drawing bitmaps with gradient or texture colors is not supported. - \sa drawImage() + \sa drawImage(), QPixmap::devicePixelRatio() */ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) { @@ -5607,6 +5619,8 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positio staticTextItem.numGlyphs = glyphCount; staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray)); staticTextItem.glyphPositions = positions; + // The font property is meaningless, the fontengine must be used directly: + staticTextItem.usesRawFont = true; extended->drawStaticTextItem(&staticTextItem); } else { @@ -6422,6 +6436,7 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText continue; + multi->ensureEngineAt(which); QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); ti2.width = 0; // set the high byte to zero and calc the width @@ -6449,6 +6464,7 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText which = e; } + multi->ensureEngineAt(which); QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); ti2.width = 0; // set the high byte to zero and calc the width @@ -7404,8 +7420,6 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, tf |= Qt::TextDontPrint; uint maxUnderlines = 0; - int numUnderlines = 0; - QVarLengthArray<int, 32> underlinePositions(1); QFontMetricsF fm(fnt); QString text = str; @@ -7436,11 +7450,15 @@ start_lengthVariant: } } + // no need to do extra work for underlines if we don't paint + if (tf & Qt::TextDontPrint) + maxUnderlines = 0; + + QList<QTextLayout::FormatRange> underlineFormats; int length = offset - old_offset; if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) { - underlinePositions.resize(maxUnderlines + 1); - QChar *cout = text.data() + old_offset; + QChar *cout0 = cout; QChar *cin = cout; int l = length; while (l) { @@ -7450,8 +7468,24 @@ start_lengthVariant: --l; if (!l) break; - if (*cin != QLatin1Char('&') && !hidemnmemonic) - underlinePositions[numUnderlines++] = cout - text.data() - old_offset; + if (*cin != QLatin1Char('&') && !hidemnmemonic) { + QTextLayout::FormatRange range; + range.start = cout - cout0; + range.length = 1; + range.format.setFontUnderline(true); + underlineFormats.append(range); + } + } else if (hidemnmemonic && *cin == QLatin1Char('(') && l >= 4 && + cin[1] == QLatin1Char('&') && cin[2] != QLatin1Char('&') && + cin[3] == QLatin1Char(')')) { + int n = 0; + while ((cout - n) > cout0 && (cout - n - 1)->isSpace()) + ++n; + cout -= n; + cin += 4; + length -= n + 4; + l -= 4; + continue; } *cout = *cin; ++cout; @@ -7460,11 +7494,6 @@ start_lengthVariant: } } - // no need to do extra work for underlines if we don't paint - if (tf & Qt::TextDontPrint) - numUnderlines = 0; - - underlinePositions[numUnderlines] = -1; qreal height = 0; qreal width = 0; @@ -7497,7 +7526,7 @@ start_lengthVariant: engine.forceJustification = true; QTextLayout textLayout(&engine); textLayout.setCacheEnabled(true); - textLayout.engine()->underlinePositions = underlinePositions.data(); + textLayout.setAdditionalFormats(underlineFormats); if (finalText.isEmpty()) { height = fm.height(); @@ -7685,6 +7714,8 @@ void QPainterState::init(QPainter *p) { into the \a target rectangle in the paint device. \note The image is scaled to fit the rectangle, if both the image and rectangle size disagree. + \note See \l{Drawing High Resolution Versions of Pixmaps and Images} on how this is affected + by QImage::devicePixelRatio(). If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the \a flags to @@ -7696,7 +7727,7 @@ void QPainterState::init(QPainter *p) { \snippet code/src_gui_painting_qpainter.cpp 20 \endtable - \sa drawPixmap() + \sa drawPixmap(), QImage::devicePixelRatio() */ /*! diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index aa2b9bea54..7a29bb87b4 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1644,7 +1644,8 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const if (count == 0) return polys; - QList<QRectF> bounds; + QVector<QRectF> bounds; + bounds.reserve(count); for (int i=0; i<count; ++i) bounds += subpaths.at(i).boundingRect(); diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index c0b3769c2d..b661057f64 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -327,17 +327,29 @@ QPen::QPen(const QBrush &brush, qreal width, Qt::PenStyle s, Qt::PenCapStyle c, QPen::QPen(const QPen &p) { d = p.d; - d->ref.ref(); + if (d) + d->ref.ref(); } /*! + \fn QPen::QPen(QPen &&pen) + \since 5.4 + + Constructs a pen that is moved from the given \a pen. + + The moved-from pen can only be assigned to, copied, or + destroyed. Any other operation (prior to assignment) leads to + undefined behavior. +*/ + +/*! Destroys the pen. */ QPen::~QPen() { - if (!d->ref.deref()) + if (d && !d->ref.deref()) delete d; } @@ -373,7 +385,7 @@ void QPen::detach() QPen &QPen::operator=(const QPen &p) { - qAtomicAssign(d, p.d); + QPen(p).swap(*this); return *this; } diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index c5144f784f..486f699476 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -72,6 +72,8 @@ public: QPen &operator=(const QPen &pen); #ifdef Q_COMPILER_RVALUE_REFS + inline QPen(QPen &&other) + : d(other.d) { other.d = 0; } inline QPen &operator=(QPen &&other) { qSwap(d, other.d); return *this; } #endif diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 0fe883cf2b..407e032027 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -81,6 +81,7 @@ public: #ifndef QT_NO_OPENGL mutable GLuint textureId; mutable QSize textureSize; + mutable bool needsSwizzle; QOpenGLTextureBlitter *blitter; #endif }; @@ -91,6 +92,7 @@ struct QBackingstoreTextureInfo { GLuint textureId; QRect rect; + bool stacksOnTop; }; Q_DECLARE_TYPEINFO(QBackingstoreTextureInfo, Q_MOVABLE_TYPE); @@ -128,6 +130,12 @@ GLuint QPlatformTextureList::textureId(int index) const return d->textures.at(index).textureId; } +bool QPlatformTextureList::stacksOnTop(int index) const +{ + Q_D(const QPlatformTextureList); + return d->textures.at(index).stacksOnTop; +} + QRect QPlatformTextureList::geometry(int index) const { Q_D(const QPlatformTextureList); @@ -149,12 +157,13 @@ bool QPlatformTextureList::isLocked() const return d->locked; } -void QPlatformTextureList::appendTexture(GLuint textureId, const QRect &geometry) +void QPlatformTextureList::appendTexture(GLuint textureId, const QRect &geometry, bool stacksOnTop) { Q_D(QPlatformTextureList); QBackingstoreTextureInfo bi; bi.textureId = textureId; bi.rect = geometry; + bi.stacksOnTop = stacksOnTop; d->textures.append(bi); } @@ -222,13 +231,16 @@ static QRegion deviceRegion(const QRegion ®ion, QWindow *window) void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, - QPlatformTextureList *textures, QOpenGLContext *context) + QPlatformTextureList *textures, QOpenGLContext *context, + bool translucentBackground) { Q_UNUSED(offset); context->makeCurrent(window); QOpenGLFunctions *funcs = context->functions(); funcs->glViewport(0, 0, window->width() * window->devicePixelRatio(), window->height() * window->devicePixelRatio()); + funcs->glClearColor(0, 0, 0, translucentBackground ? 0 : 1); + funcs->glClear(GL_COLOR_BUFFER_BIT); if (!d_ptr->blitter) { d_ptr->blitter = new QOpenGLTextureBlitter; @@ -239,29 +251,46 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i QRect windowRect(QPoint(), window->size() * window->devicePixelRatio()); + // Textures for renderToTexture widgets. for (int i = 0; i < textures->count(); ++i) { - GLuint textureId = textures->textureId(i); - funcs->glBindTexture(GL_TEXTURE_2D, textureId); - - QRect targetRect = deviceRect(textures->geometry(i), window); - QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect); - d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft); + if (!textures->stacksOnTop(i)) { + QRect targetRect = deviceRect(textures->geometry(i), window); + QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect); + d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft); + } } - GLuint textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize); - if (!textureId) - return; - funcs->glEnable(GL_BLEND); funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // Do not write out alpha. We need blending, but only for RGB. The toplevel may have + // alpha enabled in which case blending (writing out < 1.0 alpha values) would lead to + // semi-transparency even when it is not wanted. + funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + + // Backingstore texture with the normal widgets. + GLuint textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize, &d_ptr->needsSwizzle); + if (textureId) { + QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect); + if (d_ptr->needsSwizzle) + d_ptr->blitter->setSwizzleRB(true); + d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft); + if (d_ptr->needsSwizzle) + d_ptr->blitter->setSwizzleRB(false); + } - QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect); - d_ptr->blitter->setSwizzleRB(true); - d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft); - d_ptr->blitter->setSwizzleRB(false); + // Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set. + for (int i = 0; i < textures->count(); ++i) { + if (textures->stacksOnTop(i)) { + QRect targetRect = deviceRect(textures->geometry(i), window); + QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect); + d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft); + } + } + funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); funcs->glDisable(GL_BLEND); d_ptr->blitter->release(); + context->swapBuffers(window); } @@ -291,9 +320,15 @@ QImage QPlatformBackingStore::toImage() const The default implementation returns a cached texture if \a dirtyRegion is empty and the window has not been resized, otherwise it retrieves the content using toImage() and performs a texture upload. - */ -GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize) const + If the red and blue components have to swapped, \a needsSwizzle will be set to \c true. + This allows creating textures from images in formats like QImage::Format_RGB32 without + any further image conversion. Instead, the swizzling will be done in the shaders when + performing composition. Other formats, that do not need such swizzling due to being + already byte ordered RGBA, for example QImage::Format_RGBA8888, must result in having \a + needsSwizzle set to false. + */ +GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, bool *needsSwizzle) const { QImage image = toImage(); QSize imageSize = image.size(); @@ -304,8 +339,16 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu if (dirtyRegion.isEmpty() && !resized) return d_ptr->textureId; - if (image.format() != QImage::Format_RGB32 && image.format() != QImage::Format_RGBA8888) - image = image.convertToFormat(QImage::Format_RGBA8888); + // Fast path for RGB32 and RGBA8888, convert everything else to RGBA8888. + if (image.format() == QImage::Format_RGB32) { + if (needsSwizzle) + *needsSwizzle = true; + } else { + if (needsSwizzle) + *needsSwizzle = false; + if (image.format() != QImage::Format_RGBA8888) + image = image.convertToFormat(QImage::Format_RGBA8888); + } QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); @@ -322,8 +365,8 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu #endif funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageSize.width(), imageSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast<uchar*>(image.constBits())); @@ -335,29 +378,32 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu QRect rect = dirtyRegion.boundingRect() & imageRect; #ifndef QT_OPENGL_ES_2 - funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, image.width()); - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, - image.constScanLine(rect.y()) + rect.x() * 4); - funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); -#else - // if the rect is wide enough it's cheaper to just - // extend it instead of doing an image copy - if (rect.width() >= imageRect.width() / 2) { - rect.setX(0); - rect.setWidth(imageRect.width()); - } - - // if the sub-rect is full-width we can pass the image data directly to - // OpenGL instead of copying, since there's no gap between scanlines - - if (rect.width() == imageRect.width()) { - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, - image.constScanLine(rect.y())); - } else { + if (!QOpenGLContext::currentContext()->isOpenGLES()) { + funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, image.width()); funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, - image.copy(rect).constBits()); - } + image.constScanLine(rect.y()) + rect.x() * 4); + funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + } else #endif + { + // if the rect is wide enough it's cheaper to just + // extend it instead of doing an image copy + if (rect.width() >= imageRect.width() / 2) { + rect.setX(0); + rect.setWidth(imageRect.width()); + } + + // if the sub-rect is full-width we can pass the image data directly to + // OpenGL instead of copying, since there's no gap between scanlines + + if (rect.width() == imageRect.width()) { + funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, + image.constScanLine(rect.y())); + } else { + funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, + image.copy(rect).constBits()); + } + } } return d_ptr->textureId; diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h index 4728622cac..2c183f6d6f 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -84,10 +84,11 @@ public: bool isEmpty() const { return count() == 0; } GLuint textureId(int index) const; QRect geometry(int index) const; + bool stacksOnTop(int index) const; void lock(bool on); bool isLocked() const; - void appendTexture(GLuint textureId, const QRect &geometry); + void appendTexture(GLuint textureId, const QRect &geometry, bool stacksOnTop = false); void clear(); Q_SIGNALS: @@ -109,9 +110,11 @@ public: // offset is the (child) window's offset in relation to the window surface. virtual void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) = 0; #ifndef QT_NO_OPENGL - virtual void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, QPlatformTextureList *textures, QOpenGLContext *context); + virtual void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, + QPlatformTextureList *textures, QOpenGLContext *context, + bool translucentBackground); virtual QImage toImage() const; - virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize) const; + virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, bool *needsSwizzle) const; #endif virtual void resize(const QSize &size, const QRegion &staticContents) = 0; diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index 1039e842ab..b696fe279a 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -71,8 +71,8 @@ public: void translate(int dx, int dy); void translate(const QPoint &offset); - QPolygon translated(int dx, int dy) const; - inline QPolygon translated(const QPoint &offset) const; + QPolygon translated(int dx, int dy) const Q_REQUIRED_RESULT; + inline QPolygon translated(const QPoint &offset) const Q_REQUIRED_RESULT; QRect boundingRect() const; @@ -88,9 +88,9 @@ public: bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const; - QPolygon united(const QPolygon &r) const; - QPolygon intersected(const QPolygon &r) const; - QPolygon subtracted(const QPolygon &r) const; + QPolygon united(const QPolygon &r) const Q_REQUIRED_RESULT; + QPolygon intersected(const QPolygon &r) const Q_REQUIRED_RESULT; + QPolygon subtracted(const QPolygon &r) const Q_REQUIRED_RESULT; }; inline QPolygon::QPolygon(int asize) : QVector<QPoint>(asize) {} diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 20c62fdd9d..1e778af3f6 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -450,7 +450,10 @@ QDebug operator<<(QDebug s, const QRegion &r) \sa united(), operator+() */ -const QRegion QRegion::operator|(const QRegion &r) const +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +const +#endif +QRegion QRegion::operator|(const QRegion &r) const { return united(r); } /*! @@ -459,14 +462,20 @@ const QRegion QRegion::operator|(const QRegion &r) const \sa united(), operator|() */ -const QRegion QRegion::operator+(const QRegion &r) const +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +const +#endif +QRegion QRegion::operator+(const QRegion &r) const { return united(r); } /*! \overload \since 4.4 */ -const QRegion QRegion::operator+(const QRect &r) const +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +const +#endif +QRegion QRegion::operator+(const QRect &r) const { return united(r); } /*! @@ -475,14 +484,20 @@ const QRegion QRegion::operator+(const QRect &r) const \sa intersected() */ -const QRegion QRegion::operator&(const QRegion &r) const +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +const +#endif +QRegion QRegion::operator&(const QRegion &r) const { return intersected(r); } /*! \overload \since 4.4 */ -const QRegion QRegion::operator&(const QRect &r) const +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +const +#endif +QRegion QRegion::operator&(const QRect &r) const { return intersected(r); } @@ -493,7 +508,10 @@ const QRegion QRegion::operator&(const QRect &r) const \sa subtracted() */ -const QRegion QRegion::operator-(const QRegion &r) const +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +const +#endif +QRegion QRegion::operator-(const QRegion &r) const { return subtracted(r); } /*! @@ -502,7 +520,10 @@ const QRegion QRegion::operator-(const QRegion &r) const \sa xored() */ -const QRegion QRegion::operator^(const QRegion &r) const +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE +const +#endif +QRegion QRegion::operator^(const QRegion &r) const { return xored(r); } /*! @@ -1066,34 +1087,18 @@ Q_GUI_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) struct QRegionPrivate { int numRects; + int innerArea; QVector<QRect> rects; QRect extents; QRect innerRect; - int innerArea; inline QRegionPrivate() : numRects(0), innerArea(-1) {} - inline QRegionPrivate(const QRect &r) { - numRects = 1; - extents = r; - innerRect = r; - innerArea = r.width() * r.height(); - } - - inline QRegionPrivate(const QRegionPrivate &r) { - rects = r.rects; - numRects = r.numRects; - extents = r.extents; - innerRect = r.innerRect; - innerArea = r.innerArea; - } - - inline QRegionPrivate &operator=(const QRegionPrivate &r) { - rects = r.rects; - numRects = r.numRects; - extents = r.extents; - innerRect = r.innerRect; - innerArea = r.innerArea; - return *this; + inline QRegionPrivate(const QRect &r) + : numRects(1), + innerArea(r.width() * r.height()), + extents(r), + innerRect(r) + { } void intersect(const QRect &r); @@ -3537,8 +3542,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) POINTBLOCK *tmpPtBlock; int numFullPtBlocks = 0; - if (!(region = new QRegionPrivate)) - return 0; + region = new QRegionPrivate; /* special case a rectangle */ if (((Count == 4) || diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 0e436e3fb4..8ab1a8e3b3 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -86,23 +86,23 @@ public: void translate(int dx, int dy); inline void translate(const QPoint &p) { translate(p.x(), p.y()); } - QRegion translated(int dx, int dy) const; - inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); } + QRegion translated(int dx, int dy) const Q_REQUIRED_RESULT; + inline QRegion translated(const QPoint &p) const Q_REQUIRED_RESULT { return translated(p.x(), p.y()); } - QRegion united(const QRegion &r) const; - QRegion united(const QRect &r) const; - QRegion intersected(const QRegion &r) const; - QRegion intersected(const QRect &r) const; - QRegion subtracted(const QRegion &r) const; - QRegion xored(const QRegion &r) const; + QRegion united(const QRegion &r) const Q_REQUIRED_RESULT; + QRegion united(const QRect &r) const Q_REQUIRED_RESULT; + QRegion intersected(const QRegion &r) const Q_REQUIRED_RESULT; + QRegion intersected(const QRect &r) const Q_REQUIRED_RESULT; + QRegion subtracted(const QRegion &r) const Q_REQUIRED_RESULT; + QRegion xored(const QRegion &r) const Q_REQUIRED_RESULT; #if QT_DEPRECATED_SINCE(5, 0) - inline QT_DEPRECATED QRegion unite(const QRegion &r) const { return united(r); } - inline QT_DEPRECATED QRegion unite(const QRect &r) const { return united(r); } - inline QT_DEPRECATED QRegion intersect(const QRegion &r) const { return intersected(r); } - inline QT_DEPRECATED QRegion intersect(const QRect &r) const { return intersected(r); } - inline QT_DEPRECATED QRegion subtract(const QRegion &r) const { return subtracted(r); } - inline QT_DEPRECATED QRegion eor(const QRegion &r) const { return xored(r); } + inline QT_DEPRECATED QRegion unite(const QRegion &r) const Q_REQUIRED_RESULT { return united(r); } + inline QT_DEPRECATED QRegion unite(const QRect &r) const Q_REQUIRED_RESULT { return united(r); } + inline QT_DEPRECATED QRegion intersect(const QRegion &r) const Q_REQUIRED_RESULT { return intersected(r); } + inline QT_DEPRECATED QRegion intersect(const QRect &r) const Q_REQUIRED_RESULT { return intersected(r); } + inline QT_DEPRECATED QRegion subtract(const QRegion &r) const Q_REQUIRED_RESULT { return subtracted(r); } + inline QT_DEPRECATED QRegion eor(const QRegion &r) const Q_REQUIRED_RESULT { return xored(r); } #endif bool intersects(const QRegion &r) const; @@ -112,7 +112,8 @@ public: QVector<QRect> rects() const; void setRects(const QRect *rect, int num); int rectCount() const; - +#ifdef Q_COMPILER_MANGLES_RETURN_TYPE + // ### Qt 6: remove these, they're kept for MSVC compat const QRegion operator|(const QRegion &r) const; const QRegion operator+(const QRegion &r) const; const QRegion operator+(const QRect &r) const; @@ -120,6 +121,15 @@ public: const QRegion operator&(const QRect &r) const; const QRegion operator-(const QRegion &r) const; const QRegion operator^(const QRegion &r) const; +#else + QRegion operator|(const QRegion &r) const; + QRegion operator+(const QRegion &r) const; + QRegion operator+(const QRect &r) const; + QRegion operator&(const QRegion &r) const; + QRegion operator&(const QRect &r) const; + QRegion operator-(const QRegion &r) const; + QRegion operator^(const QRegion &r) const; +#endif // Q_COMPILER_MANGLES_RETURN_TYPE QRegion& operator|=(const QRegion &r); QRegion& operator+=(const QRegion &r); QRegion& operator+=(const QRect &r); diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 83edeb41a6..fb8c23835d 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -50,20 +50,6 @@ QT_BEGIN_NAMESPACE // #define CACHE_DEBUG -// returns the highest number closest to v, which is a power of 2 -// NB! assumes 32 bit ints -static inline int qt_next_power_of_two(int v) -{ - v--; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - ++v; - return v; -} - int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const { // Test 12 different subpixel positions since it factors into 3*4 so it gives @@ -199,7 +185,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const if (fontEngine->maxCharWidth() <= QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH) m_w = QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; else - m_w = qt_next_power_of_two(fontEngine->maxCharWidth()); + m_w = qNextPowerOfTwo(qCeil(fontEngine->maxCharWidth()) - 1); } // now actually use the coords and paint the wanted glyps into cache. @@ -261,9 +247,9 @@ void QTextureGlyphCache::fillInPendingGlyphs() if (isNull() || requiredHeight > m_h || requiredWidth > m_w) { if (isNull()) - createCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight)); + createCache(qNextPowerOfTwo(requiredWidth - 1), qNextPowerOfTwo(requiredHeight - 1)); else - resizeCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight)); + resizeCache(qNextPowerOfTwo(requiredWidth - 1), qNextPowerOfTwo(requiredHeight - 1)); } { diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 060362f63e..e6acbe0490 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -104,9 +104,9 @@ public: qreal m21, qreal m22, qreal m23, qreal m31, qreal m32, qreal m33); - QTransform inverted(bool *invertible = 0) const; - QTransform adjoint() const; - QTransform transposed() const; + QTransform inverted(bool *invertible = 0) const Q_REQUIRED_RESULT; + QTransform adjoint() const Q_REQUIRED_RESULT; + QTransform transposed() const Q_REQUIRED_RESULT; QTransform &translate(qreal dx, qreal dy); QTransform &scale(qreal sx, qreal sy); |