Fixed WaylandSurfaceItem for when paint enabled is false.
authorSamuel Rødal <samuel.rodal@nokia.com>
Mon, 5 Mar 2012 12:34:50 +0000 (13:34 +0100)
committerPaul Olav Tvete <paul.tvete@nokia.com>
Mon, 5 Mar 2012 13:06:35 +0000 (14:06 +0100)
This broke in change c5163c53337b72e0c28ae. Even when paint enabled is
false meaning we don't create a paint node, we want to update the
QSGTexture and the texture provider, so that the WaylandSurfaceItem can
function as a shader effect source.

Change-Id: I8d40c774f8a28240902d2d9919aee8645db9dbe7
Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
src/compositor/compositor_api/waylandsurfaceitem.cpp
src/compositor/compositor_api/waylandsurfaceitem.h

index aff24cd..7a19244 100644 (file)
@@ -311,15 +311,17 @@ public:
         setFlag(UsePreprocess,true);
     }
     void preprocess() {
-        if (m_item->m_damaged)
+        if (m_item->m_damaged) {
+            m_item->updateTexture();
             m_item->updateNodeTexture(this);
+        }
     }
 private:
     WaylandSurfaceItem *m_item;
 };
 
 
-void WaylandSurfaceItem::updateNodeTexture(WaylandSurfaceNode *node)
+void WaylandSurfaceItem::updateTexture()
 {
     if (m_damaged) {
         QSGTexture *oldTexture = m_texture;
@@ -342,15 +344,23 @@ void WaylandSurfaceItem::updateNodeTexture(WaylandSurfaceNode *node)
         m_provider->t = m_texture;
         m_provider->smooth = smooth();
     }
+}
 
+void WaylandSurfaceItem::updateNodeTexture(WaylandSurfaceNode *node)
+{
     node->setTexture(m_texture);
     node->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest);
 }
 
-
 QSGNode *WaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
 {
-    if (!m_surface || !m_paintEnabled) {
+    if (!m_surface) {
+        delete oldNode;
+        return 0;
+    }
+
+    updateTexture();
+    if (!m_texture || !m_paintEnabled) {
         delete oldNode;
         return 0;
     }
index b59ce8e..da07b00 100644 (file)
@@ -124,6 +124,7 @@ protected:
 
 private:
     friend class WaylandSurfaceNode;
+    void updateTexture();
     void updateNodeTexture(WaylandSurfaceNode *newNode);
     QPoint toSurface(const QPointF &pos) const;
     void init(WaylandSurface *);