summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSami Liedes <sami.liedes@iki.fi>2013-07-29 13:40:08 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-18 18:30:43 +0100
commit0e65cec6b4f5ca21f3964a18b4a3f35a32a6762f (patch)
treee8d3901b4ca4ebef77c4db24a095eafcb39e98e5 /src/gui
parent18c04d0ab6debceea406a77676913f826a093153 (diff)
Optimize blend_transformed_tiled_argb().
Profiling indicates that this function is one of two hot spots causing a noticeable latency when changing KDE virtual desktops. Instead of computing two modulos per pixel in the inner loop, it is possible to compute the modulos outside the loop and compute a modulo sum in the inner loop for a reasonable speedup. Change-Id: Ic4217b7686e031d7673b3e10aa977dae263096dc Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qdrawhelper.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 75e5f1eae3..7750d22a91 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -5116,13 +5116,13 @@ static void blend_transformed_tiled_argb(int count, const QSpan *spans, void *us
int l = qMin(length, buffer_size);
const uint *end = buffer + l;
uint *b = buffer;
+ int px16 = x % (image_width << 16);
+ int py16 = y % (image_height << 16);
+ int px_delta = fdx % (image_width << 16);
+ int py_delta = fdy % (image_height << 16);
while (b < end) {
- int px = x >> 16;
- int py = y >> 16;
- px %= image_width;
- py %= image_height;
- if (px < 0) px += image_width;
- if (py < 0) py += image_height;
+ int px = px16 >> 16;
+ int py = py16 >> 16;
int y_offset = py * scanline_offset;
Q_ASSERT(px >= 0 && px < image_width);
@@ -5131,6 +5131,14 @@ static void blend_transformed_tiled_argb(int count, const QSpan *spans, void *us
*b = image_bits[y_offset + px];
x += fdx;
y += fdy;
+ px16 += px_delta;
+ if (px16 >= image_width << 16)
+ px16 -= image_width << 16;
+ py16 += py_delta;
+ if (py16 >= image_height << 16)
+ py16 -= image_height << 16;
+ if (px16 < 0) px16 += image_width << 16;
+ if (py16 < 0) py16 += image_height << 16;
++b;
}
func(target, buffer, l, coverage);