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>
This commit is contained in:
parent
20ac791f4b
commit
3c8bfc1482
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user