diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 821eddf11..095e80ed5 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -652,6 +652,7 @@ #include "clutter-scriptable.h" #include "clutter-script-private.h" #include "clutter-stage-private.h" +#include "clutter-stage-view-private.h" #include "clutter-timeline.h" #include "clutter-transition.h" #include "clutter-units.h" @@ -16250,6 +16251,40 @@ clutter_actor_peek_stage_views (ClutterActor *self) return self->priv->stage_views; } +/** + * clutter_actor_pick_frame_clock: + * @self: a #ClutterActor + * + * Pick the most suitable frame clock for driving animations for this actor. + * + * Returns: (transfer none): a #ClutterFrameClock + */ +ClutterFrameClock * +clutter_actor_pick_frame_clock (ClutterActor *self) +{ + float max_refresh_rate = 0.0; + ClutterStageView *best_view = NULL; + GList *l; + + for (l = self->priv->stage_views; l; l = l->next) + { + ClutterStageView *view = l->data; + float refresh_rate; + + refresh_rate = clutter_stage_view_get_refresh_rate (view); + if (refresh_rate > max_refresh_rate) + { + best_view = view; + max_refresh_rate = refresh_rate; + } + } + + if (best_view) + return clutter_stage_view_get_frame_clock (best_view); + else + return NULL; +} + /** * clutter_actor_has_overlaps: * @self: A #ClutterActor diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h index 128acac1a..e5fa72bae 100644 --- a/clutter/clutter/clutter-actor.h +++ b/clutter/clutter/clutter-actor.h @@ -924,6 +924,9 @@ GList * clutter_actor_peek_stage_views (ClutterActor *self); CLUTTER_EXPORT void clutter_actor_invalidate_transform (ClutterActor *self); +CLUTTER_EXPORT +ClutterFrameClock * clutter_actor_pick_frame_clock (ClutterActor *self); + G_END_DECLS #endif /* __CLUTTER_ACTOR_H__ */