summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbbackingstore.cpp
diff options
context:
space:
mode:
authorLouai Al-Khanji <louai.al-khanji@theqtcompany.com>2016-04-28 10:24:38 -0700
committerLouai Al-Khanji <louai.al-khanji@qt.io>2016-04-29 16:09:14 +0000
commita1fd5d02bd9d5efb4334dc6f9d393eaaaa377bab (patch)
tree0029c51880855b0e5e028eec53dd194f8b52d022 /src/plugins/platforms/xcb/qxcbbackingstore.cpp
parentcd1eff1e1ef3097e5dd1a01f88eb1052ee63022d (diff)
xcb: support nested paint operations in remote scenarios
Recent changes to the xcb platform plugin added logic to paint to a server-side X Pixmap when the MIT-SHM extension is unavailable. Those changes also added logic to keep track of the dirty areas that need to be flushed to the server from the backing store when the backing store is flushed to a window. Because a single QRegion was used to track those areas, nested paint operations no longer accurately tracked all the dirty areas. Consider: void Widget::paintEvent(QPaintEvent *) { QPainter p1(this); for (int i = 0; longRunningOperationInProgress(); i++) { QPixmap pixmap(size()); QPainter p2(&pixmap); p2.drawText(pixmap.rect(), i & 1 ? "Working." : "Working.."); p2.end(); QBackingStore *bs = backingStore(); bs->beginPaint(rect()); p1.drawPixmap(0, 0, pixmap); bs->endPaint(); bs->flush(rect(), windowHandle()); } p1.fillRect(rect(), Qt::red); p1.drawText(rect(), "Done!"); } While this code could be restructured, it is a common pattern in legacy Qt applications which cannot be easily changed. Change-Id: I3b919266abe41c96a584cb02f41cafac3f9d1d7c Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbbackingstore.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 51c6b198e5..a999fb0aa2 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -525,13 +525,13 @@ void QXcbBackingStore::beginPaint(const QRegion &region)
if (!m_image)
return;
- m_paintRegion = region;
- m_image->preparePaint(m_paintRegion);
+ m_paintRegions.push(region);
+ m_image->preparePaint(region);
if (m_image->hasAlpha()) {
QPainter p(paintDevice());
p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = m_paintRegion.rects();
+ const QVector<QRect> rects = region.rects();
const QColor blank = Qt::transparent;
for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
p.fillRect(*it, blank);
@@ -541,13 +541,21 @@ void QXcbBackingStore::beginPaint(const QRegion &region)
void QXcbBackingStore::endPaint()
{
+ if (Q_UNLIKELY(m_paintRegions.isEmpty())) {
+ qWarning("%s: paint regions empty!", Q_FUNC_INFO);
+ return;
+ }
+
+ const QRegion region = m_paintRegions.pop();
+ m_image->preparePaint(region);
+
QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window()->handle());
if (!platformWindow || !platformWindow->imageNeedsRgbSwap())
return;
// Slow path: the paint device was m_rgbImage. Now copy with swapping red
// and blue into m_image.
- const QVector<QRect> rects = m_paintRegion.rects();
+ const QVector<QRect> rects = region.rects();
if (rects.isEmpty())
return;
QPainter p(m_image->image());