diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-12-06 10:40:35 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-12-06 18:31:28 +0000 |
commit | 8aacde593792125ba4b75964970f6b65a689915c (patch) | |
tree | cb27c894a76eb21847a8f3f7b86ba83a37539f78 /src | |
parent | a016bed95fbd410ac3c646a3dd0cf9ffe50d1285 (diff) |
QAlphaPaintEngine: port away from QRegion::rects()
Use begin()/end() instead.
The old code extracted the rects from the region, then checked for a 'complex'
region (by comparing the number of rectangles against 10), and replacing the
region with the bounding rect if it was too complex. It then went on to adjust
the rectangle list it had gotten from the original region to match the new.
Simply delay getting the rectangles until after we have modified the region.
Since there are many member function calls in-between, take a copy of the
region to iterate over later, rather than relying on the region to be left
untouched by all the code in-between.
Change-Id: I49ddf4d545520ab435ab6b89eec3d24cf371823e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/printsupport/kernel/qpaintengine_alpha.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index cae5c2f522..410051df2a 100644 --- a/src/printsupport/kernel/qpaintengine_alpha.cpp +++ b/src/printsupport/kernel/qpaintengine_alpha.cpp @@ -306,15 +306,12 @@ void QAlphaPaintEngine::flushAndInit(bool init) d->m_alphargn = d->m_alphargn.intersected(QRect(0, 0, d->m_pdev->width(), d->m_pdev->height())); // just use the bounding rect if it's a complex region.. - QVector<QRect> rects = d->m_alphargn.rects(); - if (rects.size() > 10) { + if (d->m_alphargn.rectCount() > 10) { QRect br = d->m_alphargn.boundingRect(); d->m_alphargn = QRegion(br); - rects.clear(); - rects.append(br); } - d->m_cliprgn = d->m_alphargn; + const auto oldAlphaRegion = d->m_cliprgn = d->m_alphargn; // now replay the QPicture ++d->m_pass; // we are now doing pass #2 @@ -336,7 +333,7 @@ void QAlphaPaintEngine::flushAndInit(bool init) d->resetState(painter()); // fill in the alpha images - for (const auto &rect : qAsConst(rects)) + for (const auto &rect : oldAlphaRegion) d->drawAlphaImage(rect); d->m_alphargn = QRegion(); |