From cfbe4818385b22128755e13cd8ab3c75182853c2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Mar 2020 12:23:22 +0100 Subject: QDrawHelper cleanups We don't need to handle solid SourceOver logic directly, this was already handled by getOperator and changed composition to Source. Also removes some dead code and changes an assert in unreachable code to Q_UNREACHABLE. Change-Id: I66a6c1248bd34e31096023f1acb20385099932c9 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/gui/painting/qdrawhelper.cpp') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 2d4045fe29..4b0cc2547c 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -4482,9 +4482,8 @@ static void blend_color_generic(int count, const QSpan *spans, void *userData) uint buffer[BufferSize]; Operator op = getOperator(data, nullptr, 0); const uint color = data->solidColor.toArgb32(); - bool solidFill = data->rasterBuffer->compositionMode == QPainter::CompositionMode_Source - || (data->rasterBuffer->compositionMode == QPainter::CompositionMode_SourceOver && qAlpha(color) == 255); - QPixelLayout::BPP bpp = qPixelLayouts[data->rasterBuffer->format].bpp; + const bool solidFill = op.mode == QPainter::CompositionMode_Source; + const QPixelLayout::BPP bpp = qPixelLayouts[data->rasterBuffer->format].bpp; while (count--) { int x = spans->x; @@ -4552,9 +4551,8 @@ void blend_color_generic_rgb64(int count, const QSpan *spans, void *userData) alignas(8) QRgba64 buffer[BufferSize]; const QRgba64 color = data->solidColor; - bool solidFill = data->rasterBuffer->compositionMode == QPainter::CompositionMode_Source - || (data->rasterBuffer->compositionMode == QPainter::CompositionMode_SourceOver && color.isOpaque()); - QPixelLayout::BPP bpp = qPixelLayouts[data->rasterBuffer->format].bpp; + const bool solidFill = op.mode == QPainter::CompositionMode_Source; + const QPixelLayout::BPP bpp = qPixelLayouts[data->rasterBuffer->format].bpp; while (count--) { int x = spans->x; -- cgit v1.2.3 From aa5855847c158524ceaa99f2e99fb2eba5b118af Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Mar 2020 12:19:37 +0100 Subject: Add SSE2 optimized solid source composition Very similar to source-over, but have traditionally been inlined. Change-Id: I211f0b1c91c1a00c4769fbbfe2e3d0c7b22d7048 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gui/painting/qdrawhelper.cpp') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 4b0cc2547c..39de1baa17 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -4521,6 +4521,10 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData) uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; if (spans->coverage == 255) { qt_memfill(target, color, spans->len); +#ifdef __SSE2__ + } else if (spans->len > 16) { + op.funcSolid(target, spans->len, color, spans->coverage); +#endif } else { uint c = BYTE_MUL(color, spans->coverage); int ialpha = 255 - spans->coverage; @@ -6764,10 +6768,12 @@ static void qInitDrawhelperFunctions() extern void QT_FASTCALL comp_func_SourceOver_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); extern void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha); extern void QT_FASTCALL comp_func_Source_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); + extern void QT_FASTCALL comp_func_solid_Source_sse2(uint *destPixels, int length, uint color, uint const_alpha); extern void QT_FASTCALL comp_func_Plus_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha); qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_sse2; qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_sse2; qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_sse2; + qt_functionForModeSolid_C[QPainter::CompositionMode_Source] = comp_func_solid_Source_sse2; qt_functionForMode_C[QPainter::CompositionMode_Plus] = comp_func_Plus_sse2; #ifdef QT_COMPILER_SUPPORTS_SSSE3 -- cgit v1.2.3 From 5e1e4b9d52987c7c12a935e0ed5ef89f1ca8244c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Mar 2020 12:22:11 +0100 Subject: Extend tiled optimization in 64-bit painting to 64-bit sources Change-Id: I74b88781d631ee68822cd08f9cb0aca03f7b688e Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/gui/painting/qdrawhelper.cpp') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 39de1baa17..f153557077 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5139,7 +5139,8 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD yoff += image_height; bool isBpp32 = qPixelLayouts[data->rasterBuffer->format].bpp == QPixelLayout::BPP32; - if (op.destFetch64 == destFetch64Undefined && image_width <= BufferSize && isBpp32) { + bool isBpp64 = qPixelLayouts[data->rasterBuffer->format].bpp == QPixelLayout::BPP64; + if (op.destFetch64 == destFetch64Undefined && image_width <= BufferSize && (isBpp32 || isBpp64)) { // If destination isn't blended into the result, we can do the tiling directly on destination pixels. while (count--) { int x = spans->x; @@ -5173,9 +5174,14 @@ static void blend_tiled_generic_rgb64(int count, const QSpan *spans, void *userD if (sx >= image_width) sx = 0; } - uint *dest = (uint*)data->rasterBuffer->scanLine(y) + x - image_width; - for (int i = image_width; i < length; ++i) { - dest[i] = dest[i - image_width]; + if (isBpp32) { + uint *dest = reinterpret_cast(data->rasterBuffer->scanLine(y)) + x - image_width; + for (int i = image_width; i < length; ++i) + dest[i] = dest[i - image_width]; + } else { + quint64 *dest = reinterpret_cast(data->rasterBuffer->scanLine(y)) + x - image_width; + for (int i = image_width; i < length; ++i) + dest[i] = dest[i - image_width]; } ++spans; } -- cgit v1.2.3