platform plugins: port away from QRegion::rects()

Use begin()/end()/rectCount() instead.

Change-Id: I5c642c4a2c64da65d3f37159396c86073818ca95
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Marc Mutz 2017-11-30 21:34:13 +01:00
parent 1d47df8d52
commit 634344411e
6 changed files with 17 additions and 20 deletions

View File

@ -104,9 +104,8 @@ void QFbBackingStore::beginPaint(const QRegion &region)
if (mImage.hasAlphaChannel()) {
QPainter p(&mImage);
p.setCompositionMode(QPainter::CompositionMode_Source);
const QVector<QRect> rects = region.rects();
for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it)
p.fillRect(*it, Qt::transparent);
for (const QRect &r : region)
p.fillRect(r, Qt::transparent);
}
}

View File

@ -210,10 +210,9 @@ QRegion QFbScreen::doRedraw()
if (!mPainter)
mPainter = new QPainter(&mScreenImage);
const QVector<QRect> rects = mRepaintRegion.rects();
const QRect screenRect = mGeometry.translated(-screenOffset);
for (int rectIndex = 0; rectIndex < mRepaintRegion.rectCount(); rectIndex++) {
const QRect rect = rects[rectIndex].intersected(screenRect);
for (QRect rect : mRepaintRegion) {
rect = rect.intersected(screenRect);
if (rect.isEmpty())
continue;

View File

@ -247,8 +247,7 @@ QRegion QBsdFbScreen::doRedraw()
if (!m_blitter)
m_blitter.reset(new QPainter(&m_onscreenImage));
const auto rects = touched.rects();
for (const QRect &rect : rects)
for (const QRect &rect : touched)
m_blitter->drawImage(rect, mScreenImage, rect);
return touched;
}

View File

@ -204,15 +204,14 @@ QRegion QIntegrityFbScreen::doRedraw()
if (!mBlitter)
mBlitter = new QPainter(&mFbScreenImage);
QVector<QRect> rects = touched.rects();
for (int i = 0; i < rects.size(); i++) {
for (QRect rect : touched) {
FBRect fbrect = {
(uint32_t)rects[i].left(),
(uint32_t)rects[i].top(),
(uint32_t)rects[i].width(),
(uint32_t)rects[i].height()
(uint32_t)rect.left(),
(uint32_t)rect.top(),
(uint32_t)rect.width(),
(uint32_t)rect.height()
};
mBlitter->drawImage(rects[i], mScreenImage, rects[i]);
mBlitter->drawImage(rect, mScreenImage, rect);
gh_FB_expose(mFbh, &fbrect, NULL);
}
return touched;

View File

@ -476,7 +476,8 @@ void QRfbRawEncoder::write()
// rgn &= QRect(0, 0, server->screen()->geometry().width(),
// server->screen()->geometry().height());
// }
const QVector<QRect> rects = rgn.rects();
const auto rectsInRegion = rgn.rectCount();
{
const char tmp[2] = { 0, 0 }; // msg type, padding
@ -484,16 +485,16 @@ void QRfbRawEncoder::write()
}
{
const quint16 count = htons(rects.size());
const quint16 count = htons(rectsInRegion);
socket->write((char *)&count, sizeof(count));
}
if (rects.size() <= 0)
if (rectsInRegion <= 0)
return;
const QImage screenImage = client->server()->screenImage();
for (const QRect &tileRect: rects) {
for (const QRect &tileRect: rgn) {
const QRfbRect rect(tileRect.x(), tileRect.y(),
tileRect.width(), tileRect.height());
rect.write(socket);

View File

@ -105,7 +105,7 @@ void qt_xcb_native_x11_info_init(QXcbConnection *conn)
QVector<XRectangle> qt_region_to_xrectangles(const QRegion &r)
{
const int numRects = r.rectCount();
const QVector<QRect> input = r.rects();
const auto input = r.begin();
QVector<XRectangle> output(numRects);
for (int i = 0; i < numRects; ++i) {
const QRect &in = input[i];