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>bb10
parent
85d8975bc9
commit
0302697370
|
|
@ -3782,8 +3782,8 @@ void QClipData::initialize()
|
|||
}
|
||||
} else if (hasRegionClip) {
|
||||
|
||||
const QVector<QRect> rects = clipRegion.rects();
|
||||
const int numRects = rects.size();
|
||||
const auto rects = clipRegion.begin();
|
||||
const int numRects = clipRegion.rectCount();
|
||||
|
||||
{ // resize
|
||||
const int maxSpans = (ymax - ymin) * numRects;
|
||||
|
|
@ -3797,8 +3797,8 @@ void QClipData::initialize()
|
|||
int firstInBand = 0;
|
||||
count = 0;
|
||||
while (firstInBand < numRects) {
|
||||
const int currMinY = rects.at(firstInBand).y();
|
||||
const int currMaxY = currMinY + rects.at(firstInBand).height();
|
||||
const int currMinY = rects[firstInBand].y();
|
||||
const int currMaxY = currMinY + rects[firstInBand].height();
|
||||
|
||||
while (y < currMinY) {
|
||||
m_clipLines[y].spans = 0;
|
||||
|
|
@ -3807,7 +3807,7 @@ void QClipData::initialize()
|
|||
}
|
||||
|
||||
int lastInBand = firstInBand;
|
||||
while (lastInBand + 1 < numRects && rects.at(lastInBand+1).top() == y)
|
||||
while (lastInBand + 1 < numRects && rects[lastInBand+1].top() == y)
|
||||
++lastInBand;
|
||||
|
||||
while (y < currMaxY) {
|
||||
|
|
@ -3816,7 +3816,7 @@ void QClipData::initialize()
|
|||
m_clipLines[y].count = lastInBand - firstInBand + 1;
|
||||
|
||||
for (int r = firstInBand; r <= lastInBand; ++r) {
|
||||
const QRect &currRect = rects.at(r);
|
||||
const QRect &currRect = rects[r];
|
||||
QSpan *span = m_spans + count;
|
||||
span->x = currRect.x();
|
||||
span->len = currRect.width();
|
||||
|
|
|
|||
|
|
@ -619,18 +619,17 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op)
|
|||
|
||||
void QPaintEngineEx::clip(const QRegion ®ion, 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 ®ion, 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 ®ion, 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -447,19 +447,20 @@ QDebug operator<<(QDebug s, const QRegion &r)
|
|||
} else if (r.isEmpty()) {
|
||||
s << "empty";
|
||||
} else {
|
||||
const QVector<QRect> rects = r.rects();
|
||||
const int count = rects.size();
|
||||
const int count = r.rectCount();
|
||||
if (count > 1)
|
||||
s << "size=" << count << ", bounds=(";
|
||||
QtDebugUtils::formatQRect(s, r.boundingRect());
|
||||
if (count > 1) {
|
||||
s << ") - [";
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (i)
|
||||
bool first = true;
|
||||
for (const QRect &rect : r) {
|
||||
if (!first)
|
||||
s << ", ";
|
||||
s << '(';
|
||||
QtDebugUtils::formatQRect(s, rects.at(i));
|
||||
QtDebugUtils::formatQRect(s, rect);
|
||||
s << ')';
|
||||
first = false;
|
||||
}
|
||||
s << ']';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue