[mutter] clutter/actor: Add API to pick frame clock
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/actor: Add API to pick frame clock
- Date: Thu, 2 Jul 2020 20:53:14 +0000 (UTC)
commit f9eb140e62a4c56f12b8d205f220719f2d0ae3b5
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri May 22 23:04:31 2020 +0200
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
clutter/clutter/clutter-actor.c | 35 +++++++++++++++++++++++++++++++++++
clutter/clutter/clutter-actor.h | 3 +++
2 files changed, 38 insertions(+)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 821eddf11f..095e80ed5f 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 128acac1a3..e5fa72baed 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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]