diff --git a/clutter/clutter/clutter-paint-node.c b/clutter/clutter/clutter-paint-node.c index c91182bd0..734c62411 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; }