summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengineex.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-11-30 09:43:44 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-12-06 18:30:55 +0000
commit03026973700f1fcdff602dffa3d94b04912acd44 (patch)
treeab3c22ea63e11e01573605f9a879edeffb160930 /src/gui/painting/qpaintengineex.cpp
parent85d8975bc999d65d04db9027f66c030574a5caf0 (diff)
QtGui: port away from QRegion::rects()
Use begin()/end()/rectCount() instead, which don't require QRegionPrivate ::vectorize() calls. In QPaintEngineEx::clip(), the rectCount() == 1 case called clip(QRect), but forgot to return, causing another clip(QVectorPath) call with the same arguments. Fixed. Change-Id: Ife33112fc8006ed4bdff6409e2b8465ce7acb9d1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/painting/qpaintengineex.cpp')
-rw-r--r--src/gui/painting/qpaintengineex.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 812cb8c02d..0643a7cbb6 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -619,18 +619,17 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op)
void QPaintEngineEx::clip(const QRegion &region, Qt::ClipOperation op)
{
- if (region.rectCount() == 1)
- clip(region.boundingRect(), op);
-
- QVector<QRect> rects = region.rects();
- if (rects.size() <= 32) {
+ const auto rectsInRegion = region.rectCount();
+ if (rectsInRegion == 1) {
+ clip(*region.begin(), op);
+ } else if (rectsInRegion <= 32) {
qreal pts[2*32*4];
int pos = 0;
- for (QVector<QRect>::const_iterator i = rects.constBegin(); i != rects.constEnd(); ++i) {
- qreal x1 = i->x();
- qreal y1 = i->y();
- qreal x2 = i->x() + i->width();
- qreal y2 = i->y() + i->height();
+ for (QRect r : region) {
+ qreal x1 = r.x();
+ qreal y1 = r.y();
+ qreal x2 = r.x() + r.width();
+ qreal y2 = r.y() + r.height();
pts[pos++] = x1;
pts[pos++] = y1;
@@ -644,19 +643,19 @@ void QPaintEngineEx::clip(const QRegion &region, Qt::ClipOperation op)
pts[pos++] = x1;
pts[pos++] = y2;
}
- QVectorPath vp(pts, rects.size() * 4, qpaintengineex_rect4_types_32);
+ QVectorPath vp(pts, rectsInRegion * 4, qpaintengineex_rect4_types_32);
clip(vp, op);
} else {
- QVarLengthArray<qreal> pts(rects.size() * 2 * 4);
- QVarLengthArray<QPainterPath::ElementType> types(rects.size() * 4);
+ QVarLengthArray<qreal> pts(rectsInRegion * 2 * 4);
+ QVarLengthArray<QPainterPath::ElementType> types(rectsInRegion * 4);
int ppos = 0;
int tpos = 0;
- for (QVector<QRect>::const_iterator i = rects.constBegin(); i != rects.constEnd(); ++i) {
- qreal x1 = i->x();
- qreal y1 = i->y();
- qreal x2 = i->x() + i->width();
- qreal y2 = i->y() + i->height();
+ for (QRect r : region) {
+ qreal x1 = r.x();
+ qreal y1 = r.y();
+ qreal x2 = r.x() + r.width();
+ qreal y2 = r.y() + r.height();
pts[ppos++] = x1;
pts[ppos++] = y1;
@@ -676,7 +675,7 @@ void QPaintEngineEx::clip(const QRegion &region, Qt::ClipOperation op)
types[tpos++] = QPainterPath::LineToElement;
}
- QVectorPath vp(pts.data(), rects.size() * 4, types.data());
+ QVectorPath vp(pts.data(), rectsInRegion * 4, types.data());
clip(vp, op);
}