summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainterpath_p.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2010-01-12 14:24:18 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2010-01-12 14:25:55 (GMT)
commit2a4a76767849b1325927db17383679a46c16d38d (patch)
treeac2731be3385909a82dc65052ba9a3faf92c1e34 /src/gui/painting/qpainterpath_p.h
parentd4e81805ff47a266890f9638cf29647889d5c730 (diff)
downloadQt-2a4a76767849b1325927db17383679a46c16d38d.zip
Qt-2a4a76767849b1325927db17383679a46c16d38d.tar.gz
Qt-2a4a76767849b1325927db17383679a46c16d38d.tar.bz2
Put LinesHint into QVectorPath hints to enable further optimizations
Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting/qpainterpath_p.h')
-rw-r--r--src/gui/painting/qpainterpath_p.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index 54b9392..4cd8a1a 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -97,6 +97,7 @@ public:
flags(0)
{
int ptsPos = 0;
+ bool isLines = true;
for (int i=0; i<path.size(); ++i) {
const QPainterPath::Element &e = path.at(i);
elements[i] = e.type;
@@ -104,6 +105,11 @@ public:
points[ptsPos++] = e.y;
if (e.type == QPainterPath::CurveToElement)
flags |= QVectorPath::CurvedShapeMask;
+
+ // This is to check if the path contains only alternating lineTo/moveTo,
+ // in which case we can set the LinesHint in the path. MoveTo is 0 and
+ // LineTo is 1 so the i%2 gets us what we want cheaply.
+ isLines = isLines && e.type == (QPainterPath::ElementType) (i%2);
}
if (fillRule == Qt::WindingFill)
@@ -111,8 +117,14 @@ public:
else
flags |= QVectorPath::OddEvenFill;
- if (!convex)
- flags |= QVectorPath::NonConvexShapeMask;
+ if (isLines)
+ flags |= QVectorPath::LinesShapeMask;
+ else {
+ flags |= QVectorPath::AreaShapeMask;
+ if (!convex)
+ flags |= QVectorPath::NonConvexShapeMask;
+ }
+
}
QVarLengthArray<QPainterPath::ElementType> elements;
QVarLengthArray<qreal> points;