Commit 8aacde59 authored by Marc Mutz's avatar Marc Mutz
Browse files

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: default avatarLars Knoll <>
parent a016bed9
......@@ -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);
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)
// fill in the alpha images
for (const auto &rect : qAsConst(rects))
for (const auto &rect : oldAlphaRegion)
d->m_alphargn = QRegion();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment