[mutter/gbsneto/effects-paint-nodes: 5/11] clutter/paint-node: Walk up paint node tree to find framebuffer




commit 3c8bfc14820addcccb080ae735fe788c437abe94
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jul 8 14:06:11 2020 -0300

    clutter/paint-node: Walk up paint node tree to find framebuffer
    
    The idea of having a paint node tree is that we don't really need
    to retrieve the framebuffer from ClutterPaintContext. For example,
    ClutterLayerNode draws into an offscreen framebuffer; if any child
    of a layer node needs to retrieve a framebuffer to draw, the layer
    node's offscreen framebuffer should be used.
    
    However, clutter_paint_node_get_framebuffer() goes straight to the
    root node of the tree, skipping any potential paint nodes with a
    custom framebuffer.
    
    Modify clutter_paint_node_get_framebuffer() to walk up the paint
    node tree until a node with a custom framebuffer appears. In many
    cases, this will end up either in dummy or layer node's custom
    framebuffer implementations.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>

 clutter/clutter/clutter-paint-node.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/clutter/clutter/clutter-paint-node.c b/clutter/clutter/clutter-paint-node.c
index c91182bd06..734c624118 100644
--- a/clutter/clutter/clutter-paint-node.c
+++ b/clutter/clutter/clutter-paint-node.c
@@ -1149,24 +1149,14 @@ _clutter_paint_node_create (GType gtype)
   return (gpointer) g_type_create_instance (gtype);
 }
 
-static ClutterPaintNode *
-clutter_paint_node_get_root (ClutterPaintNode *node)
-{
-  ClutterPaintNode *iter;
-
-  iter = node;
-  while (iter != NULL && iter->parent != NULL)
-    iter = iter->parent;
-
-  return iter;
-}
-
 /**
  * clutter_paint_node_get_framebuffer:
  * @node: a #ClutterPaintNode
  *
  * Retrieves the #CoglFramebuffer that @node will draw
- * into, if it the root node has a custom framebuffer set.
+ * into. If @node doesn't specify a custom framebuffer,
+ * the first ancestor with a custom framebuffer will be
+ * used.
  *
  * Returns: (transfer none): a #CoglFramebuffer or %NULL if no custom one is
  * set.
@@ -1174,12 +1164,17 @@ clutter_paint_node_get_root (ClutterPaintNode *node)
 CoglFramebuffer *
 clutter_paint_node_get_framebuffer (ClutterPaintNode *node)
 {
-  ClutterPaintNode *root = clutter_paint_node_get_root (node);
   ClutterPaintNodeClass *klass;
 
-  klass = CLUTTER_PAINT_NODE_GET_CLASS (root);
-  if (klass->get_framebuffer != NULL)
-    return klass->get_framebuffer (root);
-  else
-    return NULL;
+  while (node)
+    {
+      klass = CLUTTER_PAINT_NODE_GET_CLASS (node);
+
+      if (klass->get_framebuffer != NULL)
+        return klass->get_framebuffer (node);
+
+      node = node->parent;
+    }
+
+  return NULL;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]