From 3c072f46b17a195daf1901d0c9f9410b4007b0a7 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 19 Jun 2018 14:51:08 +0200 Subject: Don't commit same buffer multiple times In Qt we call flush() when we think the window might need to be updated. It is also possible to trigger a flush while painting. Two fixes: 1) If there are attempted flushes between beginPaint() and endPaint, queue them up, and do them in endPaint(). 2) Make sure we only commit the buffer once: after that the compositor owns the buffer, and it can repaint on its own. Change-Id: Ibf61068fa95760eb67dbc0b1d0534854114ea528 Reviewed-by: Johan Helsing --- src/client/qwaylandwindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/client/qwaylandwindow.cpp') diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 5d658f675..b88541ad8 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -75,6 +75,8 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { +Q_LOGGING_CATEGORY(lcWaylandBackingstore, "qt.qpa.wayland.backingstore") + QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr; QWaylandWindow::QWaylandWindow(QWindow *window) @@ -556,6 +558,7 @@ void QWaylandWindow::handleScreenRemoved(QScreen *qScreen) void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y) { + Q_ASSERT(!buffer->committed()); if (mFrameCallback) { wl_callback_destroy(mFrameCallback); mFrameCallback = nullptr; @@ -586,12 +589,18 @@ void QWaylandWindow::damage(const QRect &rect) void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage) { + if (buffer->committed()) { + qCDebug(lcWaylandBackingstore) << "Buffer already committed, ignoring."; + return; + } if (!isInitialized()) return; attachOffset(buffer); for (const QRect &rect: damage) wl_surface::damage(rect.x(), rect.y(), rect.width(), rect.height()); + Q_ASSERT(!buffer->committed()); + buffer->setCommitted(); wl_surface::commit(); } -- cgit v1.2.3