summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Kling <andreas.kling@nokia.com>2010-11-04 12:14:47 (GMT)
committerAndreas Kling <andreas.kling@nokia.com>2010-11-04 12:41:42 (GMT)
commit6d6b27203a5d28d7ed546110e9103d62b9060814 (patch)
treea784de444b03b7771983cd1b16cccbbb18c87838
parente14868518a1c002af440e011a792650d1e723cd3 (diff)
downloadQt-6d6b27203a5d28d7ed546110e9103d62b9060814.zip
Qt-6d6b27203a5d28d7ed546110e9103d62b9060814.tar.gz
Qt-6d6b27203a5d28d7ed546110e9103d62b9060814.tar.bz2
Optimize and clean up QClipData::fixup()
WebKit was hitting this function pretty hard in SVG space invaders demo: http://croczilla.com/bits_and_pieces/svg/samples/invaders/invaders.svg This patch cuts time spent in QClipData::fixup() from 6% to 2%. Reviewed-by: Samuel Rødal
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index a2da94c..8088e63 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -4629,38 +4629,40 @@ void QClipData::fixup()
return;
}
-// qDebug("QClipData::fixup: count=%d",count);
int y = -1;
ymin = m_spans[0].y;
ymax = m_spans[count-1].y + 1;
xmin = INT_MAX;
xmax = 0;
+ const int firstLeft = m_spans[0].x;
+ const int firstRight = m_spans[0].x + m_spans[0].len;
bool isRect = true;
- int left = m_spans[0].x;
- int right = m_spans[0].x + m_spans[0].len;
for (int i = 0; i < count; ++i) {
- if (m_spans[i].y != y) {
- if (m_spans[i].y != y + 1 && y != -1) {
+ QT_FT_Span_& span = m_spans[i];
+
+ if (span.y != y) {
+ if (span.y != y + 1 && y != -1)
isRect = false;
- }
- y = m_spans[i].y;
- m_clipLines[y].spans = m_spans+i;
- m_clipLines[y].count = 0;
-// qDebug() << " new line: y=" << y;
- }
- ++m_clipLines[y].count;
- int sl = (int) m_spans[i].x;
- int sr = sl + m_spans[i].len;
+ y = span.y;
+ m_clipLines[y].spans = &span;
+ m_clipLines[y].count = 1;
+ } else
+ ++m_clipLines[y].count;
+
+ const int spanLeft = span.x;
+ const int spanRight = spanLeft + span.len;
+
+ if (spanLeft < xmin)
+ xmin = spanLeft;
- xmin = qMin(xmin, (int)m_spans[i].x);
- xmax = qMax(xmax, (int)m_spans[i].x + m_spans[i].len);
+ if (spanRight > xmax)
+ xmax = spanRight;
- if (sl != left || sr != right)
+ if (spanLeft != firstLeft || spanRight != firstRight)
isRect = false;
}
-// qDebug("xmin=%d,xmax=%d,ymin=%d,ymax=%d %s", xmin, xmax, ymin, ymax, isRect ? "rectangular" : "");
if (isRect) {
hasRectClip = true;