clutter/actor: Add API to pick frame clock

The frame clock wouldn't be useable yet, but none the less, add API to
get the frame clock best suited for driving the actor. Currently this
translates to the fastest one, but that might change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
Jonas Ådahl 2020-05-22 23:04:31 +02:00
parent 3aff755048
commit f9eb140e62
2 changed files with 38 additions and 0 deletions

View File

@ -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

View File

@ -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__ */