summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-05-28 14:47:29 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-09 07:27:52 (GMT)
commit72e083c98c3adb07bb1578fb7f28f121fc3f34ac (patch)
treec47d1e0624752905bbfcf97af3778213a6d06200
parentfa256ad3758e0d8794136975f0e93ddfa91216f5 (diff)
downloadQt-72e083c98c3adb07bb1578fb7f28f121fc3f34ac.zip
Qt-72e083c98c3adb07bb1578fb7f28f121fc3f34ac.tar.gz
Qt-72e083c98c3adb07bb1578fb7f28f121fc3f34ac.tar.bz2
greatly speed up QTransform::mapRect() for projective transforms
The code so far was converting the rect to a painterpath, mapping that one and then taking the bounding rect. It is actually sufficient to simply map the four corners of the rectangle and take the bounding rect of these four points even in the projective case. Reviewed-by: Andreas
-rw-r--r--src/gui/painting/qtransform.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index c00012a..86e594c 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -1788,7 +1788,7 @@ QRect QTransform::mapRect(const QRect &rect) const
y -= h;
}
return QRect(x, y, w, h);
- } else if (t < TxProject) {
+ } else {
// see mapToPolygon for explanations of the algorithm.
qreal x = 0, y = 0;
MAP(rect.left(), rect.top(), x, y);
@@ -1812,10 +1812,6 @@ QRect QTransform::mapRect(const QRect &rect) const
xmax = qMax(xmax, x);
ymax = qMax(ymax, y);
return QRect(qRound(xmin), qRound(ymin), qRound(xmax)-qRound(xmin), qRound(ymax)-qRound(ymin));
- } else {
- QPainterPath path;
- path.addRect(rect);
- return map(path).boundingRect().toRect();
}
}
@@ -1858,7 +1854,7 @@ QRectF QTransform::mapRect(const QRectF &rect) const
y -= h;
}
return QRectF(x, y, w, h);
- } else if (t < TxProject) {
+ } else {
qreal x = 0, y = 0;
MAP(rect.x(), rect.y(), x, y);
qreal xmin = x;
@@ -1881,10 +1877,6 @@ QRectF QTransform::mapRect(const QRectF &rect) const
xmax = qMax(xmax, x);
ymax = qMax(ymax, y);
return QRectF(xmin, ymin, xmax-xmin, ymax - ymin);
- } else {
- QPainterPath path;
- path.addRect(rect);
- return map(path).boundingRect();
}
}