From 9c1d3bc253abd4418f3050d19ec5f05bef3ada97 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 27 Feb 2016 14:34:46 +0100 Subject: QtOpenGL/plugins/platformsupport: use new QRegion::begin()/end() instead of rect() Saves e.g. ~900b and ~2900b in text size in QtOpenGL and XcbQpa libs, resp., on optimized GCC 5.3 Linux AMD64 builds. Change-Id: Id904689164ca32df41118a23747c70048d8e6604 Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/plugins/platforms/xcb/qxcbbackingstore.cpp') diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index e57b089878..3d22c9f4dd 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -335,11 +335,9 @@ void QXcbBackingStore::beginPaint(const QRegion ®ion) if (m_image->hasAlpha()) { QPainter p(paintDevice()); p.setCompositionMode(QPainter::CompositionMode_Source); - const QVector rects = m_paintRegion.rects(); const QColor blank = Qt::transparent; - for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { - p.fillRect(*it, blank); - } + for (const QRect &rect : m_paintRegion) + p.fillRect(rect, blank); } } @@ -351,11 +349,12 @@ void QXcbBackingStore::endPaint() // Slow path: the paint device was m_rgbImage. Now copy with swapping red // and blue into m_image. - const QVector rects = m_paintRegion.rects(); - if (rects.isEmpty()) + auto it = m_paintRegion.begin(); + const auto end = m_paintRegion.end(); + if (it == end) return; QPainter p(m_image->image()); - for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { + while (it != end) { const QRect rect = *it; p.drawImage(rect.topLeft(), m_rgbImage.copy(rect).rgbSwapped()); } @@ -397,9 +396,8 @@ void QXcbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoin return; } - QVector rects = clipped.rects(); - for (int i = 0; i < rects.size(); ++i) { - QRect rect = QRect(rects.at(i).topLeft(), rects.at(i).size()); + for (const QRect &r : clipped) { + QRect rect = QRect(r.topLeft(), r.size()); m_image->put(platformWindow->xcb_window(), rect.topLeft(), rect.translated(offset)); } @@ -463,9 +461,8 @@ bool QXcbBackingStore::scroll(const QRegion &area, int dx, int dy) m_image->preparePaint(area); QPoint delta(dx, dy); - const QVector rects = area.rects(); - for (int i = 0; i < rects.size(); ++i) - qt_scrollRectInImage(*m_image->image(), rects.at(i), delta); + for (const QRect &rect : area) + qt_scrollRectInImage(*m_image->image(), rect, delta); return true; } -- cgit v1.2.3