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.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340
This commit is contained in:
Georges Basile Stavracas Neto 2020-07-08 14:06:11 -03:00 committed by Robert Mader
parent 11ca27c6ff
commit a510339970

View File

@ -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 parent node with a custom framebuffer will
* be used.
*
* Returns: (transfer none): a #CoglFramebuffer or %NULL if no custom one is
* set.
@ -1174,12 +1164,19 @@ 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;
ClutterPaintNode *iter;
iter = node;
while (iter != NULL && iter->parent != NULL)
{
klass = CLUTTER_PAINT_NODE_GET_CLASS (iter);
klass = CLUTTER_PAINT_NODE_GET_CLASS (root);
if (klass->get_framebuffer != NULL)
return klass->get_framebuffer (root);
else
return klass->get_framebuffer (iter);
iter = iter->parent;
}
return NULL;
}