From dd5b829468b4818f00a3c3a7df7f104dfa869bd1 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 17 Nov 2017 13:23:30 +0100 Subject: Raster paint engine: optimize rect clipping More aggressively skip processing empty spans. Tested with the qpainter benchmark on armv7; yields small but measurable improvement. Change-Id: Ie0ed0f824a0be7bcc2de3a9aa98ebccb0e8accae Reviewed-by: Lars Knoll Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/gui/painting/qdrawhelper.cpp') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index ca3590e280..1f7ab5006c 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -4419,7 +4419,9 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData) if (mode == QPainter::CompositionMode_Source) { // inline for performance ushort c = data->solid.color.toRgb16(); - while (count--) { + for (; count--; spans++) { + if (!spans->len) + continue; ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; if (spans->coverage == 255) { QT_MEMFILL_USHORT(target, spans->len, c); @@ -4432,13 +4434,14 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData) ++target; } } - ++spans; } return; } if (mode == QPainter::CompositionMode_SourceOver) { - while (count--) { + for (; count--; spans++) { + if (!spans->len) + continue; uint color = BYTE_MUL(data->solid.color.toArgb32(), spans->coverage); int ialpha = qAlpha(~color); ushort c = qConvertRgb32To16(color); @@ -4470,7 +4473,6 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData) // one last pixel beyond a full word *target = c + BYTE_MUL_RGB16(*target, ialpha); } - ++spans; } return; } @@ -4487,6 +4489,11 @@ void handleSpans(int count, const QSpan *spans, const QSpanData *data, T &handle int coverage = 0; while (count) { + if (!spans->len) { + ++spans; + --count; + continue; + } int x = spans->x; const int y = spans->y; int right = x + spans->len; @@ -4639,7 +4646,9 @@ static void blend_untransformed_generic(int count, const QSpan *spans, void *use int xoff = -qRound(-data->dx); int yoff = -qRound(-data->dy); - while (count--) { + for (; count--; spans++) { + if (!spans->len) + continue; int x = spans->x; int length = spans->len; int sx = xoff + x; @@ -4667,7 +4676,6 @@ static void blend_untransformed_generic(int count, const QSpan *spans, void *use } } } - ++spans; } } @@ -4688,7 +4696,9 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi int xoff = -qRound(-data->dx); int yoff = -qRound(-data->dy); - while (count--) { + for (; count--; spans++) { + if (!spans->len) + continue; int x = spans->x; int length = spans->len; int sx = xoff + x; @@ -4716,7 +4726,6 @@ static void blend_untransformed_generic_rgb64(int count, const QSpan *spans, voi } } } - ++spans; } } @@ -4736,7 +4745,9 @@ static void blend_untransformed_argb(int count, const QSpan *spans, void *userDa int xoff = -qRound(-data->dx); int yoff = -qRound(-data->dy); - while (count--) { + for (; count--; spans++) { + if (!spans->len) + continue; int x = spans->x; int length = spans->len; int sx = xoff + x; @@ -4756,7 +4767,6 @@ static void blend_untransformed_argb(int count, const QSpan *spans, void *userDa op.func(dest, src, length, coverage); } } - ++spans; } } @@ -4829,7 +4839,12 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans, void *user int xoff = -qRound(-data->dx); int yoff = -qRound(-data->dy); - while (count--) { + const QSpan *end = spans + count; + while (spans < end) { + if (!spans->len) { + ++spans; + continue; + } const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; if (coverage == 0) { ++spans; -- cgit v1.2.3