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>
This commit is contained in:
parent
a016bed95f
commit
8aacde5937
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user