diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/painting.pri | 9 | ||||
-rw-r--r-- | src/gui/painting/qblendfunctions.cpp | 465 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 43 | ||||
-rw-r--r-- | src/gui/painting/qcolor.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qcolor_p.cpp | 12 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 206 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 24 | ||||
-rw-r--r-- | src/gui/painting/qimagescale.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qmemrotate.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/qpaintbuffer.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 4 |
11 files changed, 698 insertions, 81 deletions
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 47ba27d72a..aadcc0f686 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -91,9 +91,12 @@ SSE2_SOURCES += painting/qdrawhelper_sse2.cpp SSSE3_SOURCES += painting/qdrawhelper_ssse3.cpp IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp AVX_SOURCES += painting/qdrawhelper_avx.cpp -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 + +!ios { + 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 +} MIPS_DSP_SOURCES += painting/qdrawhelper_mips_dsp.cpp MIPS_DSP_HEADERS += painting/qdrawhelper_mips_dsp_p.h painting/qt_mips_asm_dsp_p.h diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp index 6d9168ecf4..23eaa9a3e7 100644 --- a/src/gui/painting/qblendfunctions.cpp +++ b/src/gui/painting/qblendfunctions.cpp @@ -604,7 +604,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_Mono 0, // Format_Invalid, @@ -622,7 +625,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_MonoLSB 0, // Format_Invalid, @@ -640,7 +646,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_Indexed8 0, // Format_Invalid, @@ -658,7 +667,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB32 0, // Format_Invalid, @@ -676,7 +688,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB32 0, // Format_Invalid, @@ -694,7 +709,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB32_Premultiplied 0, // Format_Invalid, @@ -712,7 +730,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB16 0, // Format_Invalid, @@ -730,7 +751,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB8565_Premultiplied 0, // Format_Invalid, @@ -748,7 +772,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB666 0, // Format_Invalid, @@ -766,7 +793,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB6666_Premultiplied 0, // Format_Invalid, @@ -784,7 +814,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB555 0, // Format_Invalid, @@ -802,7 +835,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB8555_Premultiplied 0, // Format_Invalid, @@ -820,7 +856,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB888 0, // Format_Invalid, @@ -838,7 +877,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB444 0, // Format_Invalid, @@ -856,7 +898,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB4444_Premultiplied 0, // Format_Invalid, @@ -874,7 +919,85 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, + }, + { // Format_RGBX8888 + 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, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_scale_image_rgb32_on_rgb32, // Format_RGBX8888, + 0, // Format_RGBA8888, + qt_scale_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied, +#else + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, +#endif + }, + { // Format_RGBA8888 + 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, + }, + { // Format_RGBA8888_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, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_scale_image_rgb32_on_rgb32, // Format_RGBX8888, + 0, // Format_RGBA8888, + qt_scale_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied, +#else + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, +#endif } }; @@ -896,7 +1019,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_Mono 0, // Format_Invalid, @@ -914,7 +1040,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_MonoLSB 0, // Format_Invalid, @@ -932,7 +1061,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_Indexed8 0, // Format_Invalid, @@ -950,7 +1082,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB32 0, // Format_Invalid, @@ -968,7 +1103,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB32 0, // Format_Invalid, @@ -986,7 +1124,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB32_Premultiplied 0, // Format_Invalid, @@ -1004,7 +1145,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB16 0, // Format_Invalid, @@ -1022,7 +1166,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB8565_Premultiplied 0, // Format_Invalid, @@ -1040,7 +1187,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB666 0, // Format_Invalid, @@ -1058,7 +1208,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB6666_Premultiplied 0, // Format_Invalid, @@ -1076,7 +1229,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB555 0, // Format_Invalid, @@ -1094,7 +1250,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB8555_Premultiplied 0, // Format_Invalid, @@ -1112,7 +1271,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB888 0, // Format_Invalid, @@ -1130,7 +1292,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB444 0, // Format_Invalid, @@ -1148,7 +1313,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB4444_Premultiplied 0, // Format_Invalid, @@ -1166,7 +1334,85 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] = 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, + }, + { // Format_RGBX8888 + 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, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_blend_rgb32_on_rgb32, // Format_RGBX8888, + 0, // Format_RGBA8888, + qt_blend_argb32_on_argb32, // Format_RGBA8888_Premultiplied, +#else + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, +#endif + }, + { // Format_RGBA8888 + 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, + }, + { // Format_RGBA8888_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, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_blend_rgb32_on_rgb32, // Format_RGBX8888, + 0, // Format_RGBA8888, + qt_blend_argb32_on_argb32, // Format_RGBA8888_Premultiplied, +#else + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, +#endif } }; @@ -1187,7 +1433,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_Mono 0, // Format_Invalid, @@ -1205,7 +1454,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_MonoLSB 0, // Format_Invalid, @@ -1223,7 +1475,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_Indexed8 0, // Format_Invalid, @@ -1241,7 +1496,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB32 0, // Format_Invalid, @@ -1259,7 +1517,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB32 0, // Format_Invalid, @@ -1277,7 +1538,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB32_Premultiplied 0, // Format_Invalid, @@ -1295,7 +1559,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB16 0, // Format_Invalid, @@ -1313,7 +1580,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB8565_Premultiplied 0, // Format_Invalid, @@ -1331,7 +1601,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB666 0, // Format_Invalid, @@ -1349,7 +1622,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB6666_Premultiplied 0, // Format_Invalid, @@ -1367,7 +1643,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB555 0, // Format_Invalid, @@ -1385,7 +1664,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB8555_Premultiplied 0, // Format_Invalid, @@ -1403,7 +1685,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB888 0, // Format_Invalid, @@ -1421,7 +1706,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_RGB444 0, // Format_Invalid, @@ -1439,7 +1727,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, }, { // Format_ARGB4444_Premultiplied 0, // Format_Invalid, @@ -1457,7 +1748,85 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo 0, // Format_ARGB8555_Premultiplied, 0, // Format_RGB888, 0, // Format_RGB444, - 0 // Format_ARGB4444_Premultiplied, + 0, // Format_ARGB4444_Premultiplied, + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, + }, + { // Format_RGBX8888 + 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, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_transform_image_rgb32_on_rgb32, // Format_RGBX8888, + 0, // Format_RGBA8888, + qt_transform_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied, +#else + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, +#endif + }, + { // Format_RGBA8888 + 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, + }, + { // Format_RGBA8888_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, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_transform_image_rgb32_on_rgb32, // Format_RGBX8888, + 0, // Format_RGBA8888, + qt_transform_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied, +#else + 0, // Format_RGBX8888, + 0, // Format_RGBA8888, + 0 // Format_RGBA8888_Premultiplied, +#endif } }; diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 12ca84d8d1..c93320c491 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -90,7 +90,8 @@ QT_BEGIN_NAMESPACE specified. A color can be set by passing an RGB string (such as "#112233"), - or a color name (such as "blue"), to the setNamedColor() function. + or an ARGB string (such as "#ff112233") or a color name (such as "blue"), + to the setNamedColor() function. The color names are taken from the SVG 1.0 color names. The name() function returns the name of the color in the format "#RRGGBB". Colors can also be set using setRgb(), setHsv() and @@ -301,6 +302,17 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QColor::NameFormat + + How to format the output of the name() function + + \value HexRgb #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. \c{#RRGGBB}). + \value HexArgb #AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. \c{#AARRGGBB}). + + \sa name() +*/ + +/*! \fn Spec QColor::spec() const Returns how the color was specified. @@ -489,8 +501,28 @@ QColor::QColor(Spec spec) QString QColor::name() const { + return name(HexRgb); +} + +/*! + \since 5.2 + + Returns the name of the color in the specified \a format. + + \sa setNamedColor(), NameFormat +*/ + +QString QColor::name(NameFormat format) const +{ QString s; - s.sprintf("#%02x%02x%02x", red(), green(), blue()); + switch (format) { + case HexRgb: + s.sprintf("#%02x%02x%02x", red(), green(), blue()); + break; + case HexArgb: + s.sprintf("#%02x%02x%02x%02x", alpha(), red(), green(), blue()); + break; + } return s; } @@ -501,6 +533,7 @@ QString QColor::name() const \list \li #RGB (each of R, G, and B is a single hex digit) \li #RRGGBB + \li #AARRGGBB (Since 5.2) \li #RRRGGGBBB \li #RRRRGGGGBBBB \li A name from the list of colors defined in the list of \l{http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword names} @@ -545,9 +578,9 @@ bool QColor::setColorFromString(const QString &name) } if (name.startsWith(QLatin1Char('#'))) { - QRgb rgb; - if (qt_get_hex_rgb(name.constData(), name.length(), &rgb)) { - setRgb(rgb); + QRgb rgba; + if (qt_get_hex_rgb(name.constData(), name.length(), &rgba)) { + setRgba(rgba); return true; } else { invalidate(); diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index ef3503e8d8..1ede5a3682 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -65,6 +65,7 @@ class Q_GUI_EXPORT QColor { public: enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl }; + enum NameFormat { HexRgb, HexArgb }; QColor(); QColor(Qt::GlobalColor color); @@ -77,7 +78,9 @@ public: bool isValid() const; + // ### Qt 6: merge overloads QString name() const; + QString name(NameFormat format) const; void setNamedColor(const QString& name); static QStringList colorNames(); diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index 35e607ec54..b913f5338c 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -79,7 +79,8 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb) return false; name++; int len = qstrlen(name); - int r, g, b; + int a, r, g, b; + a = 255; if (len == 12) { r = hex2int(name); g = hex2int(name + 4); @@ -88,6 +89,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb) r = hex2int(name); g = hex2int(name + 3); b = hex2int(name + 6); + } else if (len == 8) { + a = hex2int(name); + r = hex2int(name + 2); + g = hex2int(name + 4); + b = hex2int(name + 6); } else if (len == 6) { r = hex2int(name); g = hex2int(name + 2); @@ -99,11 +105,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb) } else { r = g = b = -1; } - if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255) { + if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) { *rgb = 0; return false; } - *rgb = qRgb(r, g ,b); + *rgb = qRgba(r, g ,b, a); return true; } diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index de0ab53c1b..a037545dc2 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -255,6 +255,33 @@ static const uint *QT_FASTCALL convertFromARGB32PM(uint *buffer, const uint *src return buffer; } +static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count, + const QPixelLayout *layout, const QRgb *) +{ + Q_ASSERT(layout->redWidth <= 8); + Q_ASSERT(layout->greenWidth <= 8); + Q_ASSERT(layout->blueWidth <= 8); + Q_ASSERT(layout->alphaWidth == 0); + + const uint redMask = (1 << layout->redWidth) - 1; + const uint greenMask = (1 << layout->greenWidth) - 1; + const uint blueMask = (1 << layout->blueWidth) - 1; + + const uchar redRightShift = 24 - layout->redWidth; + const uchar greenRightShift = 16 - layout->greenWidth; + const uchar blueRightShift = 8 - layout->blueWidth; + + for (int i = 0; i < count; ++i) { + uint color = INV_PREMUL(src[i]); + uint red = ((color >> redRightShift) & redMask) << layout->redShift; + uint green = ((color >> greenRightShift) & greenMask) << layout->greenShift; + uint blue = ((color >> blueRightShift) & blueMask) << layout->blueShift; + uint alpha = 0xff << layout->alphaShift; + buffer[i] = red | green | blue | alpha; + } + return buffer; +} + template <QPixelLayout::BPP bpp> static uint QT_FASTCALL fetchPixel(const uchar *src, int index); @@ -386,7 +413,16 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = { { 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertToARGB32PM, convertFromARGB32PM }, // Format_ARGB8555_Premultiplied { 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32, convertFromARGB32PM }, // Format_RGB888 { 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, convertFromARGB32PM }, // Format_RGB444 - { 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertToARGB32PM, convertFromARGB32PM } // Format_ARGB4444_Premultiplied + { 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertToARGB32PM, convertFromARGB32PM }, // Format_ARGB4444_Premultiplied +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + { 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertToRGB32, convertRGBFromARGB32PM }, // Format_RGBX8888 + { 8, 24, 8, 16, 8, 8, 8, 0, false, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888 + { 8, 24, 8, 16, 8, 8, 8, 0, true, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888_Premultiplied +#else + { 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertToRGB32, convertRGBFromARGB32PM }, // Format_RGBX8888 + { 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888 (ABGR32) + { 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM } // Format_RGBA8888_Premultiplied +#endif }; FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = { @@ -490,7 +526,10 @@ static DestFetchProc destFetchProc[QImage::NImageFormats] = destFetch, // Format_ARGB8555_Premultiplied destFetch, // Format_RGB888 destFetch, // Format_RGB444 - destFetch // Format_ARGB4444_Premultiplied + destFetch, // Format_ARGB4444_Premultiplied + destFetch, // Format_RGBX8888 + destFetch, // Format_RGBA8888 + destFetch, // Format_RGBA8888_Premultiplied }; /* @@ -622,7 +661,10 @@ static DestStoreProc destStoreProc[QImage::NImageFormats] = destStore, // Format_ARGB8555_Premultiplied destStore, // Format_RGB888 destStore, // Format_RGB444 - destStore // Format_ARGB4444_Premultiplied + destStore, // Format_ARGB4444_Premultiplied + destStore, // Format_RGBX8888 + destStore, // Format_RGBA8888 + destStore // Format_RGBA8888_Premultiplied }; /* @@ -1766,7 +1808,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchUntransformed, // ARGB8555_Premultiplied fetchUntransformed, // RGB888 fetchUntransformed, // RGB444 - fetchUntransformed // ARGB4444_Premultiplied + fetchUntransformed, // ARGB4444_Premultiplied + fetchUntransformed, // RGBX8888 + fetchUntransformed, // RGBA8888 + fetchUntransformed // RGBA8888_Premultiplied }, // Tiled { @@ -1785,7 +1830,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchUntransformed, // ARGB8555_Premultiplied fetchUntransformed, // RGB888 fetchUntransformed, // RGB444 - fetchUntransformed // ARGB4444_Premultiplied + fetchUntransformed, // ARGB4444_Premultiplied + fetchUntransformed, // RGBX8888 + fetchUntransformed, // RGBA8888 + fetchUntransformed // RGBA8888_Premultiplied }, // Transformed { @@ -1805,6 +1853,9 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformed<BlendTransformed>, // RGB888 fetchTransformed<BlendTransformed>, // RGB444 fetchTransformed<BlendTransformed>, // ARGB4444_Premultiplied + fetchTransformed<BlendTransformed>, // RGBX8888 + fetchTransformed<BlendTransformed>, // RGBA8888 + fetchTransformed<BlendTransformed>, // RGBA8888_Premultiplied }, { 0, // TransformedTiled @@ -1823,6 +1874,9 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformed<BlendTransformedTiled>, // RGB888 fetchTransformed<BlendTransformedTiled>, // RGB444 fetchTransformed<BlendTransformedTiled>, // ARGB4444_Premultiplied + fetchTransformed<BlendTransformedTiled>, // RGBX8888 + fetchTransformed<BlendTransformedTiled>, // RGBA8888 + fetchTransformed<BlendTransformedTiled>, // RGBA8888_Premultiplied }, { 0, // Bilinear @@ -1840,7 +1894,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformedBilinear<BlendTransformedBilinear>, // ARGB8555_Premultiplied fetchTransformedBilinear<BlendTransformedBilinear>, // RGB888 fetchTransformedBilinear<BlendTransformedBilinear>, // RGB444 - fetchTransformedBilinear<BlendTransformedBilinear> // ARGB4444_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinear>, // ARGB4444_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinear>, // RGBX8888 + fetchTransformedBilinear<BlendTransformedBilinear>, // RGBA8888 + fetchTransformedBilinear<BlendTransformedBilinear> // RGBA8888_Premultiplied }, { 0, // BilinearTiled @@ -1858,7 +1915,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformedBilinear<BlendTransformedBilinearTiled>, // ARGB8555_Premultiplied fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGB888 fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGB444 - fetchTransformedBilinear<BlendTransformedBilinearTiled> // ARGB4444_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinearTiled>, // ARGB4444_Premultiplied + fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGBX8888 + fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGBA8888 + fetchTransformedBilinear<BlendTransformedBilinearTiled> // RGBA8888_Premultiplied }, }; @@ -5268,6 +5328,9 @@ 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, }, // Tiled { @@ -5287,6 +5350,9 @@ 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, }, // Transformed { @@ -5306,6 +5372,9 @@ 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, }, // TransformedTiled { @@ -5324,6 +5393,9 @@ 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 }, // Bilinear @@ -5344,6 +5416,9 @@ 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, }, // BilinearTiled { @@ -5363,6 +5438,9 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // RGB888 blend_src_generic, // RGB444 blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic, // RGBX8888 + blend_src_generic, // RGBA8888 + blend_src_generic, // RGBA8888_Premultiplied } }; @@ -5823,9 +5901,9 @@ static void qt_alphargbblit_quint32(QRasterBuffer *rasterBuffer, } } -static void qt_rectfill_quint32(QRasterBuffer *rasterBuffer, - int x, int y, int width, int height, - quint32 color) +static void qt_rectfill_argb32(QRasterBuffer *rasterBuffer, + int x, int y, int width, int height, + quint32 color) { qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), color, x, y, width, height, rasterBuffer->bytesPerLine()); @@ -5839,14 +5917,30 @@ static void qt_rectfill_quint16(QRasterBuffer *rasterBuffer, qConvertRgb32To16(color), x, y, width, height, rasterBuffer->bytesPerLine()); } -static void qt_rectfill_nonpremul_quint32(QRasterBuffer *rasterBuffer, - int x, int y, int width, int height, - quint32 color) +static void qt_rectfill_nonpremul_argb32(QRasterBuffer *rasterBuffer, + int x, int y, int width, int height, + quint32 color) { qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), INV_PREMUL(color), x, y, width, height, rasterBuffer->bytesPerLine()); } +static void qt_rectfill_rgba(QRasterBuffer *rasterBuffer, + int x, int y, int width, int height, + quint32 color) +{ + qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), + ARGB2RGBA(color), x, y, width, height, rasterBuffer->bytesPerLine()); +} + +static void qt_rectfill_nonpremul_rgba(QRasterBuffer *rasterBuffer, + int x, int y, int width, int height, + quint32 color) +{ + qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()), + ARGB2RGBA(INV_PREMUL(color)), x, y, width, height, rasterBuffer->bytesPerLine()); +} + // Map table for destination image format. Contains function pointers // for blends of various types unto the destination @@ -5880,7 +5974,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = qt_bitmapblit_quint32, qt_alphamapblit_quint32, qt_alphargbblit_quint32, - qt_rectfill_quint32 + qt_rectfill_argb32 }, // Format_ARGB32, { @@ -5889,7 +5983,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = qt_bitmapblit_quint32, qt_alphamapblit_quint32, qt_alphargbblit_quint32, - qt_rectfill_nonpremul_quint32 + qt_rectfill_nonpremul_argb32 }, // Format_ARGB32_Premultiplied { @@ -5898,7 +5992,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = qt_bitmapblit_quint32, qt_alphamapblit_quint32, qt_alphargbblit_quint32, - qt_rectfill_quint32 + qt_rectfill_argb32 }, // Format_RGB16 { @@ -5956,6 +6050,48 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = blend_color_generic, blend_src_generic, 0, 0, 0, 0 + }, + // Format_RGBX8888 + { + blend_color_generic, + qt_gradient_quint32, + qt_bitmapblit_quint32, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_alphamapblit_quint32, + qt_alphargbblit_quint32, +#else + 0, + 0, +#endif + qt_rectfill_rgba + }, + // Format_RGBA8888 + { + blend_color_generic, + qt_gradient_quint32, + qt_bitmapblit_quint32, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_alphamapblit_quint32, + qt_alphargbblit_quint32, +#else + 0, + 0, +#endif + qt_rectfill_nonpremul_rgba + }, + // Format_RGB8888_Premultiplied + { + blend_color_generic, + qt_gradient_quint32, + qt_bitmapblit_quint32, +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qt_alphamapblit_quint32, + qt_alphargbblit_quint32, +#else + 0, + 0, +#endif + qt_rectfill_rgba } }; @@ -6043,6 +6179,9 @@ void qInitDrawhelperAsm() qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_avx; qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_avx; qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_avx; + qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit32_avx; + qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit32_avx; + qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit32_avx; extern void qt_scale_image_argb32_on_argb32_avx(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, @@ -6052,6 +6191,10 @@ void qInitDrawhelperAsm() int const_alpha); qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_avx; qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_avx; +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_avx; + qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_avx; +#endif #endif #ifdef QT_COMPILER_SUPPORTS_SSE2 } else if (features & SSE2) { @@ -6061,6 +6204,9 @@ void qInitDrawhelperAsm() qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2; qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2; qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse2; + qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit32_sse2; + qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit32_sse2; + qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2; extern void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, @@ -6070,6 +6216,10 @@ void qInitDrawhelperAsm() int const_alpha); qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; + qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2; +#endif #endif } @@ -6088,6 +6238,12 @@ void qInitDrawhelperAsm() qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_sse2; + qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_sse2; + qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_sse2; + qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_sse2; +#endif extern const uint * QT_FASTCALL qt_fetch_radial_gradient_sse2(uint *buffer, const Operator *op, const QSpanData *data, int y, int x, int length); @@ -6104,6 +6260,10 @@ void qInitDrawhelperAsm() qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; + qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; +#endif } #endif // SSSE3 @@ -6122,6 +6282,12 @@ void qInitDrawhelperAsm() qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_avx; qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_avx; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_avx; +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_avx; + qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_avx; + qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_avx; + qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_avx; +#endif extern const uint * QT_FASTCALL qt_fetch_radial_gradient_avx(uint *buffer, const Operator *op, const QSpanData *data, int y, int x, int length); @@ -6163,7 +6329,7 @@ void qInitDrawhelperAsm() } #endif // IWMMXT -#if defined(QT_COMPILER_SUPPORTS_NEON) +#if defined(QT_COMPILER_SUPPORTS_NEON) && !defined(Q_OS_IOS) if (features & NEON) { 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; @@ -6172,6 +6338,12 @@ void qInitDrawhelperAsm() qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB16] = qt_blend_rgb16_on_argb32_neon; qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_neon; +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon; + qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon; + qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon; + qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon; +#endif qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16_neon; qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16_neon; diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 0b8a41c904..f4c29996b4 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -653,6 +653,30 @@ static Q_ALWAYS_INLINE uint PREMUL(uint x) { } #endif +#if Q_BYTE_ORDER == Q_BIG_ENDIAN +static Q_ALWAYS_INLINE quint32 RGBA2ARGB(quint32 x) { + quint32 rgb = x >> 8; + quint32 a = x << 24; + return a | rgb; +} + +static Q_ALWAYS_INLINE quint32 ARGB2RGBA(quint32 x) { + quint32 rgb = x << 8; + quint32 a = x >> 24; + return a | rgb; +} +#else +static Q_ALWAYS_INLINE quint32 RGBA2ARGB(quint32 x) { + // RGBA8888 is ABGR32 on little endian. + quint32 ag = x & 0xff00ff00; + quint32 rg = x & 0x00ff00ff; + return ag | (rg << 16) | (rg >> 16); +} + +static Q_ALWAYS_INLINE quint32 ARGB2RGBA(quint32 x) { + return RGBA2ARGB(x); +} +#endif static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16(uint x, uint a) { a += 1; diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp index 27cb08f353..89ccdd42f0 100644 --- a/src/gui/painting/qimagescale.cpp +++ b/src/gui/painting/qimagescale.cpp @@ -1017,7 +1017,7 @@ QImage qSmoothScaleImage(const QImage &src, int dw, int dh) return QImage(); } - if (src.format() == QImage::Format_ARGB32_Premultiplied) + if (src.format() == QImage::Format_ARGB32_Premultiplied || src.format() == QImage::Format_RGBA8888_Premultiplied) qt_qimageScaleArgb(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4); else diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp index 747881bbd1..087231df43 100644 --- a/src/gui/painting/qmemrotate.cpp +++ b/src/gui/painting/qmemrotate.cpp @@ -529,7 +529,10 @@ MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3] = { 0, 0, 0 }, // Format_ARGB8555_Premultiplied, { 0, 0, 0 }, // Format_RGB888, { 0, 0, 0 }, // Format_RGB444, - { 0, 0, 0 } // Format_ARGB4444_Premultiplied, + { 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_END_NAMESPACE diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index bb0c441b40..f855e9e32d 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -89,9 +89,9 @@ QTextItemIntCopy::QTextItemIntCopy(const QTextItem &item) QTextItemIntCopy::~QTextItemIntCopy() { - delete m_item.chars; - delete m_item.logClusters; - delete m_item.glyphs.data(); + delete [] m_item.chars; + delete [] m_item.logClusters; + delete [] m_item.glyphs.data(); if (!m_item.fontEngine->ref.deref()) delete m_item.fontEngine; } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index d1e9b81faa..7112380043 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -435,6 +435,8 @@ void QRasterPaintEngine::init() case QImage::Format_ARGB4444_Premultiplied: case QImage::Format_ARGB32_Premultiplied: case QImage::Format_ARGB32: + case QImage::Format_RGBA8888_Premultiplied: + case QImage::Format_RGBA8888: gccaps |= PorterDuff; break; case QImage::Format_RGB32: @@ -443,6 +445,7 @@ void QRasterPaintEngine::init() case QImage::Format_RGB666: case QImage::Format_RGB888: case QImage::Format_RGB16: + case QImage::Format_RGBX8888: break; default: break; @@ -2261,6 +2264,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe case QImage::Format_ARGB6666_Premultiplied: case QImage::Format_ARGB8555_Premultiplied: case QImage::Format_ARGB4444_Premultiplied: + case QImage::Format_RGBA8888_Premultiplied: // Combine premultiplied color with the opacity set on the painter. d->solid_color_filler.solid.color = ((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff) |