From a9a61d7e0b45fae3595a94e6107ca04899cfb8f4 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 3 Aug 2016 13:27:38 +0200 Subject: [PATCH] Fix grayscale painting regression in 64-bit raster engine A new define for better vectorized compositioning had a mistake that caused some sources to be converted to grayscale when composited. Added two 10 bit per channel formats to the lancelot test to catch regressions in the future. Change-Id: I1c468e6b93d68185e517fc0d44c6c927f9f7135f Reviewed-by: Erik Verbruggen --- src/gui/painting/qcompositionfunctions.cpp | 8 ++++-- tests/auto/other/lancelot/paintcommands.cpp | 11 +++++++- tests/auto/other/lancelot/tst_lancelot.cpp | 28 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp index 8d4ea58c39..6d2cb9aadb 100644 --- a/src/gui/painting/qcompositionfunctions.cpp +++ b/src/gui/painting/qcompositionfunctions.cpp @@ -89,11 +89,15 @@ QT_BEGIN_NAMESPACE #if defined __SSE2__ # define LOAD(ptr) _mm_loadl_epi64(reinterpret_cast(ptr)) -# define CONVERT(value) _mm_shufflelo_epi16(_mm_cvtsi32_si128(value), _MM_SHUFFLE(0, 0, 0, 0)) +#ifdef Q_PROCESSOR_X86_64 +# define CONVERT(value) _mm_cvtsi64_si128(value) +#else +# define CONVERT(value) LOAD(&value) +#endif # define STORE(ptr, value) _mm_storel_epi64(reinterpret_cast<__m128i *>(ptr), value) # define ADD(p, q) _mm_add_epi32(p, q) # define ALPHA(c) _mm_shufflelo_epi16(c, _MM_SHUFFLE(3, 3, 3, 3)) -# define CONST(n) CONVERT(n) +# define CONST(n) _mm_shufflelo_epi16(_mm_cvtsi32_si128(n), _MM_SHUFFLE(0, 0, 0, 0)) # define INVALPHA(c) _mm_sub_epi32(CONST(65535), ALPHA(c)) #elif defined __ARM_NEON__ # define LOAD(ptr) vreinterpret_u16_u64(vld1_u64(reinterpret_cast(ptr))) diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 0b1471c4b1..8d6886a6c6 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -165,7 +165,16 @@ const char *PaintCommands::imageFormatTable[] = { "Format_ARGB8555_Premultiplied", "Format_RGB888", "Format_RGB444", - "Format_ARGB4444_Premultiplied" + "Format_ARGB4444_Premultiplied", + "Format_RGBX8888", + "Format_RGBA8888", + "Format_RGBA8888_Premultiplied", + "Format_BGR30", + "Format_A2BGR30_Premultiplied", + "Format_RGB30", + "Format_A2RGB30_Premultiplied", + "Alpha8", + "Grayscale8", }; int PaintCommands::translateEnum(const char *table[], const QString &pattern, int limit) diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp index 3f35712489..eb575a88ea 100644 --- a/tests/auto/other/lancelot/tst_lancelot.cpp +++ b/tests/auto/other/lancelot/tst_lancelot.cpp @@ -71,6 +71,10 @@ private slots: void testRasterRGB32(); void testRasterRGB16_data(); void testRasterRGB16(); + void testRasterA2RGB30PM_data(); + void testRasterA2RGB30PM(); + void testRasterBGR30_data(); + void testRasterBGR30(); #ifndef QT_NO_OPENGL void testOpenGL_data(); @@ -150,6 +154,30 @@ void tst_Lancelot::testRasterRGB16() } +void tst_Lancelot::testRasterA2RGB30PM_data() +{ + setupTestSuite(); +} + + +void tst_Lancelot::testRasterA2RGB30PM() +{ + runTestSuite(Raster, QImage::Format_A2RGB30_Premultiplied); +} + + +void tst_Lancelot::testRasterBGR30_data() +{ + setupTestSuite(); +} + + +void tst_Lancelot::testRasterBGR30() +{ + runTestSuite(Raster, QImage::Format_BGR30); +} + + #ifndef QT_NO_OPENGL bool tst_Lancelot::checkSystemGLSupport() {