From 8aacde593792125ba4b75964970f6b65a689915c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 6 Dec 2017 10:40:35 +0100 Subject: [PATCH] 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 --- src/printsupport/kernel/qpaintengine_alpha.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index cae5c2f5221..410051df2ad 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 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();