From b55620a74ed21f0ef497deeaad9f011078b5ce39 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Wed, 2 May 2012 15:30:06 +0200 Subject: [PATCH] Fix case where we get a new damage event too soon MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As in when we get a damage event between when updatePaintNode calls updateTexture, and WaylandSurfaceNode::preprocess is called. Change-Id: Ib953ea6ff6c5e1c0239b734940dcf6fc39d3bb27 Reviewed-by: Samuel Rødal --- src/compositor/compositor_api/waylandsurfaceitem.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/compositor/compositor_api/waylandsurfaceitem.cpp b/src/compositor/compositor_api/waylandsurfaceitem.cpp index 6316bca..71bfd61 100644 --- a/src/compositor/compositor_api/waylandsurfaceitem.cpp +++ b/src/compositor/compositor_api/waylandsurfaceitem.cpp @@ -60,7 +60,9 @@ class WaylandSurfaceNode : public QSGSimpleTextureNode { public: - WaylandSurfaceNode(WaylandSurfaceItem *item) : m_item(item) { + WaylandSurfaceNode(WaylandSurfaceItem *item) + : m_item(item), m_textureUpdated(false) + { if (m_item) m_item->m_node = this; setFlag(UsePreprocess,true); @@ -72,10 +74,14 @@ public: } void preprocess() { QMutexLocker locker(WaylandSurfaceItem::mutex); - if (m_item && m_item->m_damaged) { + + //Update if the item is dirty and we haven't done an updateTexture for this frame + if (m_item && m_item->m_damaged && !m_textureUpdated) { m_item->updateTexture(); updateTexture(); } + //Reset value for next frame: we have not done updatePaintNode yet + m_textureUpdated = false; } void updateTexture() { @@ -87,6 +93,7 @@ public: } WaylandSurfaceItem *m_item; + bool m_textureUpdated; }; class WaylandSurfaceTextureProvider : public QSGTextureProvider @@ -414,6 +421,7 @@ QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa node->setRect(0, 0, width(), height()); } + node->m_textureUpdated = true; return node; } -- 2.7.4