summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-04-29 15:33:10 (GMT)
committerBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-04-29 15:56:11 (GMT)
commit5969625334270892e39b6b43f4da735b830abdbe (patch)
tree65a3873020f512051753768d9d96756402a672e0 /src/gui/painting
parent5a9623cb54c598aa4226883076fb413ef88215e5 (diff)
downloadQt-5969625334270892e39b6b43f4da735b830abdbe.zip
Qt-5969625334270892e39b6b43f4da735b830abdbe.tar.gz
Qt-5969625334270892e39b6b43f4da735b830abdbe.tar.bz2
Speed-up QPainter::clipRegion().
We can speed up the calculation by using rect intersections if possible, i.e. QRegion &= QRect instead of QRegion &= QRegion. Then we'll get rid of one QRegion construction and the intersection itself is slightly faster. Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qpainter.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 65d87fa..759bd7e 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -2398,7 +2398,6 @@ QRegion QPainter::clipRegion() const
// ### Falcon: Use QPainterPath
for (int i=0; i<d->state->clipInfo.size(); ++i) {
const QPainterClipInfo &info = d->state->clipInfo.at(i);
- QRegion other;
switch (info.clipType) {
case QPainterClipInfo::RegionClip: {
@@ -2451,15 +2450,20 @@ QRegion QPainter::clipRegion() const
lastWasNothing = false;
continue;
}
- if (info.operation == Qt::IntersectClip)
- region &= QRegion(info.rect) * matrix;
- else if (info.operation == Qt::UniteClip)
+ if (info.operation == Qt::IntersectClip) {
+ // Use rect intersection if possible.
+ if (matrix.type() <= QTransform::TxScale)
+ region &= matrix.mapRect(info.rect);
+ else
+ region &= matrix.map(QRegion(info.rect));
+ } else if (info.operation == Qt::UniteClip) {
region |= QRegion(info.rect) * matrix;
- else if (info.operation == Qt::NoClip) {
+ } else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
- } else
+ } else {
region = QRegion(info.rect) * matrix;
+ }
break;
}
@@ -2470,15 +2474,20 @@ QRegion QPainter::clipRegion() const
lastWasNothing = false;
continue;
}
- if (info.operation == Qt::IntersectClip)
- region &= QRegion(info.rectf.toRect()) * matrix;
- else if (info.operation == Qt::UniteClip)
+ if (info.operation == Qt::IntersectClip) {
+ // Use rect intersection if possible.
+ if (matrix.type() <= QTransform::TxScale)
+ region &= matrix.mapRect(info.rectf.toRect());
+ else
+ region &= matrix.map(QRegion(info.rectf.toRect()));
+ } else if (info.operation == Qt::UniteClip) {
region |= QRegion(info.rectf.toRect()) * matrix;
- else if (info.operation == Qt::NoClip) {
+ } else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
- } else
+ } else {
region = QRegion(info.rectf.toRect()) * matrix;
+ }
break;
}
}