timeline: Use macros for subclassing boilerplate

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3387>
This commit is contained in:
Bilal Elmoussaoui 2023-11-12 11:58:03 +01:00
parent 5fb78dfbad
commit e9c1f1c642
3 changed files with 170 additions and 109 deletions

View File

@ -64,7 +64,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSwipeAction, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTapAction, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTapAction, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTextBuffer, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTextBuffer, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterText, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterText, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTimeline, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTransitionGroup, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTransitionGroup, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTransition, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterTransition, g_object_unref)

View File

@ -89,7 +89,7 @@
#include "clutter/clutter-private.h" #include "clutter/clutter-private.h"
#include "clutter/clutter-timeline-private.h" #include "clutter/clutter-timeline-private.h"
struct _ClutterTimelinePrivate typedef struct _ClutterTimelinePrivate
{ {
ClutterTimelineDirection direction; ClutterTimelineDirection direction;
@ -147,7 +147,7 @@ struct _ClutterTimelinePrivate
*/ */
guint waiting_first_tick : 1; guint waiting_first_tick : 1;
guint auto_reverse : 1; guint auto_reverse : 1;
}; } ClutterTimelinePrivate;
typedef struct { typedef struct {
gchar *name; gchar *name;
@ -254,7 +254,8 @@ static inline void
clutter_timeline_add_marker_internal (ClutterTimeline *timeline, clutter_timeline_add_marker_internal (ClutterTimeline *timeline,
TimelineMarker *marker) TimelineMarker *marker)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
TimelineMarker *old_marker; TimelineMarker *old_marker;
/* create the hash table that will hold the markers */ /* create the hash table that will hold the markers */
@ -287,7 +288,8 @@ static void
on_actor_destroyed (ClutterActor *actor, on_actor_destroyed (ClutterActor *actor,
ClutterTimeline *timeline) ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
g_clear_signal_handler (&priv->stage_stage_views_handler_id, priv->stage); g_clear_signal_handler (&priv->stage_stage_views_handler_id, priv->stage);
priv->actor = NULL; priv->actor = NULL;
@ -304,7 +306,8 @@ on_actor_destroyed (ClutterActor *actor,
ClutterActor * ClutterActor *
clutter_timeline_get_actor (ClutterTimeline *timeline) clutter_timeline_get_actor (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
return priv->actor; return priv->actor;
} }
@ -312,7 +315,8 @@ clutter_timeline_get_actor (ClutterTimeline *timeline)
static void static void
maybe_add_timeline (ClutterTimeline *timeline) maybe_add_timeline (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
if (!priv->frame_clock) if (!priv->frame_clock)
return; return;
@ -323,7 +327,8 @@ maybe_add_timeline (ClutterTimeline *timeline)
static void static void
maybe_remove_timeline (ClutterTimeline *timeline) maybe_remove_timeline (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
if (!priv->frame_clock) if (!priv->frame_clock)
return; return;
@ -335,7 +340,8 @@ static void
set_frame_clock_internal (ClutterTimeline *timeline, set_frame_clock_internal (ClutterTimeline *timeline,
ClutterFrameClock *frame_clock) ClutterFrameClock *frame_clock)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
if (priv->frame_clock == frame_clock) if (priv->frame_clock == frame_clock)
return; return;
@ -356,7 +362,8 @@ static void
on_stage_stage_views_changed (ClutterActor *stage, on_stage_stage_views_changed (ClutterActor *stage,
ClutterTimeline *timeline) ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
g_clear_signal_handler (&priv->stage_stage_views_handler_id, priv->stage); g_clear_signal_handler (&priv->stage_stage_views_handler_id, priv->stage);
priv->stage = NULL; priv->stage = NULL;
@ -374,7 +381,8 @@ on_frame_clock_actor_stage_views_changed (ClutterActor *frame_clock_actor,
static void static void
update_frame_clock (ClutterTimeline *timeline) update_frame_clock (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
ClutterFrameClock *frame_clock = NULL; ClutterFrameClock *frame_clock = NULL;
ClutterActor *stage; ClutterActor *stage;
ClutterActor *frame_clock_actor; ClutterActor *frame_clock_actor;
@ -444,7 +452,8 @@ void
clutter_timeline_set_actor (ClutterTimeline *timeline, clutter_timeline_set_actor (ClutterTimeline *timeline,
ClutterActor *actor) ClutterActor *actor)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
g_return_if_fail (!actor || (actor && !priv->custom_frame_clock)); g_return_if_fail (!actor || (actor && !priv->custom_frame_clock));
@ -477,7 +486,10 @@ clutter_timeline_set_actor (ClutterTimeline *timeline,
void void
clutter_timeline_cancel_delay (ClutterTimeline *timeline) clutter_timeline_cancel_delay (ClutterTimeline *timeline)
{ {
g_clear_handle_id (&timeline->priv->delay_id, g_source_remove); ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
g_clear_handle_id (&priv->delay_id, g_source_remove);
} }
/* Object */ /* Object */
@ -532,12 +544,13 @@ clutter_timeline_set_property (GObject *object,
static void static void
clutter_timeline_get_property (GObject *object, clutter_timeline_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterTimeline *timeline = CLUTTER_TIMELINE (object); ClutterTimeline *timeline = CLUTTER_TIMELINE (object);
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
switch (prop_id) switch (prop_id)
{ {
@ -583,7 +596,8 @@ static void
clutter_timeline_finalize (GObject *object) clutter_timeline_finalize (GObject *object)
{ {
ClutterTimeline *self = CLUTTER_TIMELINE (object); ClutterTimeline *self = CLUTTER_TIMELINE (object);
ClutterTimelinePrivate *priv = self->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (self);
if (priv->markers_by_name) if (priv->markers_by_name)
g_hash_table_destroy (priv->markers_by_name); g_hash_table_destroy (priv->markers_by_name);
@ -599,10 +613,9 @@ clutter_timeline_finalize (GObject *object)
static void static void
clutter_timeline_dispose (GObject *object) clutter_timeline_dispose (GObject *object)
{ {
ClutterTimeline *self = CLUTTER_TIMELINE(object); ClutterTimeline *self = CLUTTER_TIMELINE (object);
ClutterTimelinePrivate *priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (self);
priv = self->priv;
clutter_timeline_cancel_delay (self); clutter_timeline_cancel_delay (self);
@ -884,17 +897,18 @@ clutter_timeline_class_init (ClutterTimelineClass *klass)
static void static void
clutter_timeline_init (ClutterTimeline *self) clutter_timeline_init (ClutterTimeline *self)
{ {
self->priv = clutter_timeline_get_instance_private (self); ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (self);
self->priv->progress_mode = CLUTTER_LINEAR; priv->progress_mode = CLUTTER_LINEAR;
/* default steps() parameters are 1, end */ /* default steps() parameters are 1, end */
self->priv->n_steps = 1; priv->n_steps = 1;
self->priv->step_mode = CLUTTER_STEP_MODE_END; priv->step_mode = CLUTTER_STEP_MODE_END;
/* default cubic-bezier() paramereters are (0, 0, 1, 1) */ /* default cubic-bezier() paramereters are (0, 0, 1, 1) */
graphene_point_init (&self->priv->cb_1, 0, 0); graphene_point_init (&priv->cb_1, 0, 0);
graphene_point_init (&self->priv->cb_2, 1, 1); graphene_point_init (&priv->cb_2, 1, 1);
} }
struct CheckIfMarkerHitClosure struct CheckIfMarkerHitClosure
@ -969,9 +983,10 @@ check_if_marker_hit (const gchar *name,
static void static void
check_markers (ClutterTimeline *timeline, check_markers (ClutterTimeline *timeline,
gint delta) gint delta)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
struct CheckIfMarkerHitClosure data; struct CheckIfMarkerHitClosure data;
/* shortcircuit here if we don't have any marker installed */ /* shortcircuit here if we don't have any marker installed */
@ -994,7 +1009,8 @@ check_markers (ClutterTimeline *timeline,
static void static void
emit_frame_signal (ClutterTimeline *timeline) emit_frame_signal (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
COGL_TRACE_BEGIN_SCOPED (Emit, "Clutter::Timeline::emit_frame_signal()"); COGL_TRACE_BEGIN_SCOPED (Emit, "Clutter::Timeline::emit_frame_signal()");
@ -1009,7 +1025,8 @@ emit_frame_signal (ClutterTimeline *timeline)
static gboolean static gboolean
is_complete (ClutterTimeline *timeline) is_complete (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
return (priv->direction == CLUTTER_TIMELINE_FORWARD return (priv->direction == CLUTTER_TIMELINE_FORWARD
? priv->elapsed_time >= priv->duration ? priv->elapsed_time >= priv->duration
@ -1020,7 +1037,8 @@ static void
set_is_playing (ClutterTimeline *timeline, set_is_playing (ClutterTimeline *timeline,
gboolean is_playing) gboolean is_playing)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
is_playing = !!is_playing; is_playing = !!is_playing;
@ -1047,7 +1065,7 @@ clutter_timeline_do_frame (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv; ClutterTimelinePrivate *priv;
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
g_object_ref (timeline); g_object_ref (timeline);
@ -1094,7 +1112,7 @@ clutter_timeline_do_frame (ClutterTimeline *timeline)
} }
else if (priv->direction == CLUTTER_TIMELINE_BACKWARD) else if (priv->direction == CLUTTER_TIMELINE_BACKWARD)
{ {
elapsed_time_delta -= - priv->elapsed_time; elapsed_time_delta -= -priv->elapsed_time;
priv->elapsed_time = 0; priv->elapsed_time = 0;
} }
@ -1161,7 +1179,7 @@ clutter_timeline_do_frame (ClutterTimeline *timeline)
since these are considered equivalent */ since these are considered equivalent */
(priv->elapsed_time == 0 && end_msecs == priv->duration) || (priv->elapsed_time == 0 && end_msecs == priv->duration) ||
(priv->elapsed_time == priv->duration && end_msecs == 0) (priv->elapsed_time == priv->duration && end_msecs == 0)
)) ))
{ {
g_object_unref (timeline); g_object_unref (timeline);
return TRUE; return TRUE;
@ -1204,7 +1222,8 @@ static gboolean
delay_timeout_func (gpointer data) delay_timeout_func (gpointer data)
{ {
ClutterTimeline *timeline = data; ClutterTimeline *timeline = data;
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
priv->delay_id = 0; priv->delay_id = 0;
priv->msecs_delta = 0; priv->msecs_delta = 0;
@ -1228,7 +1247,7 @@ clutter_timeline_start (ClutterTimeline *timeline)
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->delay_id || priv->is_playing) if (priv->delay_id || priv->is_playing)
return; return;
@ -1265,7 +1284,7 @@ clutter_timeline_pause (ClutterTimeline *timeline)
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
clutter_timeline_cancel_delay (timeline); clutter_timeline_cancel_delay (timeline);
@ -1288,6 +1307,7 @@ void
clutter_timeline_stop (ClutterTimeline *timeline) clutter_timeline_stop (ClutterTimeline *timeline)
{ {
gboolean was_playing; gboolean was_playing;
ClutterTimelinePrivate *priv;
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
@ -1296,7 +1316,9 @@ clutter_timeline_stop (ClutterTimeline *timeline)
* stopped, and yet we still don't want to emit a ::stopped signal if * stopped, and yet we still don't want to emit a ::stopped signal if
* the timeline was not playing in the first place. * the timeline was not playing in the first place.
*/ */
was_playing = timeline->priv->is_playing;
priv = clutter_timeline_get_instance_private (timeline);
was_playing = priv->is_playing;
clutter_timeline_pause (timeline); clutter_timeline_pause (timeline);
clutter_timeline_rewind (timeline); clutter_timeline_rewind (timeline);
@ -1320,7 +1342,7 @@ clutter_timeline_rewind (ClutterTimeline *timeline)
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->direction == CLUTTER_TIMELINE_FORWARD) if (priv->direction == CLUTTER_TIMELINE_FORWARD)
clutter_timeline_advance (timeline, 0); clutter_timeline_advance (timeline, 0);
@ -1343,7 +1365,7 @@ clutter_timeline_skip (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->direction == CLUTTER_TIMELINE_FORWARD) if (priv->direction == CLUTTER_TIMELINE_FORWARD)
{ {
@ -1383,7 +1405,7 @@ clutter_timeline_advance (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
priv->elapsed_time = CLAMP (msecs, 0, priv->duration); priv->elapsed_time = CLAMP (msecs, 0, priv->duration);
} }
@ -1399,9 +1421,13 @@ clutter_timeline_advance (ClutterTimeline *timeline,
guint guint
clutter_timeline_get_elapsed_time (ClutterTimeline *timeline) clutter_timeline_get_elapsed_time (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
return timeline->priv->elapsed_time; priv = clutter_timeline_get_instance_private (timeline);
return priv->elapsed_time;
} }
/** /**
@ -1415,9 +1441,13 @@ clutter_timeline_get_elapsed_time (ClutterTimeline *timeline)
gboolean gboolean
clutter_timeline_is_playing (ClutterTimeline *timeline) clutter_timeline_is_playing (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE);
return timeline->priv->is_playing; priv = clutter_timeline_get_instance_private (timeline);
return priv->is_playing;
} }
/** /**
@ -1471,9 +1501,13 @@ clutter_timeline_new_for_frame_clock (ClutterFrameClock *frame_clock,
guint guint
clutter_timeline_get_delay (ClutterTimeline *timeline) clutter_timeline_get_delay (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
return timeline->priv->delay; priv = clutter_timeline_get_instance_private (timeline);
return priv->delay;
} }
/** /**
@ -1491,7 +1525,7 @@ clutter_timeline_set_delay (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->delay != msecs) if (priv->delay != msecs)
{ {
@ -1516,7 +1550,7 @@ clutter_timeline_get_duration (ClutterTimeline *timeline)
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
return priv->duration; return priv->duration;
} }
@ -1538,7 +1572,7 @@ clutter_timeline_set_duration (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
g_return_if_fail (msecs > 0); g_return_if_fail (msecs > 0);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->duration != msecs) if (priv->duration != msecs)
{ {
@ -1567,7 +1601,7 @@ clutter_timeline_get_progress (ClutterTimeline *timeline)
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0.0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0.0);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
/* short-circuit linear progress */ /* short-circuit linear progress */
if (priv->progress_func == NULL) if (priv->progress_func == NULL)
@ -1591,10 +1625,14 @@ clutter_timeline_get_progress (ClutterTimeline *timeline)
ClutterTimelineDirection ClutterTimelineDirection
clutter_timeline_get_direction (ClutterTimeline *timeline) clutter_timeline_get_direction (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline),
CLUTTER_TIMELINE_FORWARD); CLUTTER_TIMELINE_FORWARD);
return timeline->priv->direction; priv = clutter_timeline_get_instance_private (timeline);
return priv->direction;
} }
/** /**
@ -1613,7 +1651,7 @@ clutter_timeline_set_direction (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->direction != direction) if (priv->direction != direction)
{ {
@ -1643,19 +1681,23 @@ clutter_timeline_set_direction (ClutterTimeline *timeline,
guint guint
clutter_timeline_get_delta (ClutterTimeline *timeline) clutter_timeline_get_delta (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
priv = clutter_timeline_get_instance_private (timeline);
if (!clutter_timeline_is_playing (timeline)) if (!clutter_timeline_is_playing (timeline))
return 0; return 0;
return timeline->priv->msecs_delta; return priv->msecs_delta;
} }
void void
_clutter_timeline_advance (ClutterTimeline *timeline, _clutter_timeline_advance (ClutterTimeline *timeline,
gint64 tick_time) gint64 tick_time)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
g_object_ref (timeline); g_object_ref (timeline);
@ -1697,7 +1739,7 @@ _clutter_timeline_do_tick (ClutterTimeline *timeline,
COGL_TRACE_BEGIN_SCOPED (DoTick, "Clutter::Timeline::do_tick()"); COGL_TRACE_BEGIN_SCOPED (DoTick, "Clutter::Timeline::do_tick()");
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
CLUTTER_NOTE (SCHEDULER, CLUTTER_NOTE (SCHEDULER,
"Timeline [%p] ticked (elapsed_time: %ld, msecs_delta: %ld, " "Timeline [%p] ticked (elapsed_time: %ld, msecs_delta: %ld, "
@ -1869,7 +1911,7 @@ clutter_timeline_list_markers (ClutterTimeline *timeline,
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (G_UNLIKELY (priv->markers_by_name == NULL)) if (G_UNLIKELY (priv->markers_by_name == NULL))
{ {
@ -1936,7 +1978,7 @@ clutter_timeline_advance_to_marker (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
g_return_if_fail (marker_name != NULL); g_return_if_fail (marker_name != NULL);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (G_UNLIKELY (priv->markers_by_name == NULL)) if (G_UNLIKELY (priv->markers_by_name == NULL))
{ {
@ -1976,7 +2018,7 @@ clutter_timeline_remove_marker (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
g_return_if_fail (marker_name != NULL); g_return_if_fail (marker_name != NULL);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (G_UNLIKELY (priv->markers_by_name == NULL)) if (G_UNLIKELY (priv->markers_by_name == NULL))
{ {
@ -2008,13 +2050,16 @@ gboolean
clutter_timeline_has_marker (ClutterTimeline *timeline, clutter_timeline_has_marker (ClutterTimeline *timeline,
const gchar *marker_name) const gchar *marker_name)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE);
g_return_val_if_fail (marker_name != NULL, FALSE); g_return_val_if_fail (marker_name != NULL, FALSE);
if (G_UNLIKELY (timeline->priv->markers_by_name == NULL)) priv = clutter_timeline_get_instance_private (timeline);
if (G_UNLIKELY (priv->markers_by_name == NULL))
return FALSE; return FALSE;
return NULL != g_hash_table_lookup (timeline->priv->markers_by_name, return NULL != g_hash_table_lookup (priv->markers_by_name,
marker_name); marker_name);
} }
@ -2070,7 +2115,7 @@ clutter_timeline_set_auto_reverse (ClutterTimeline *timeline,
reverse = !!reverse; reverse = !!reverse;
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->auto_reverse != reverse) if (priv->auto_reverse != reverse)
{ {
@ -2093,9 +2138,13 @@ clutter_timeline_set_auto_reverse (ClutterTimeline *timeline,
gboolean gboolean
clutter_timeline_get_auto_reverse (ClutterTimeline *timeline) clutter_timeline_get_auto_reverse (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE);
return timeline->priv->auto_reverse; priv = clutter_timeline_get_instance_private (timeline);
return priv->auto_reverse;
} }
/** /**
@ -2119,7 +2168,7 @@ clutter_timeline_set_repeat_count (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
g_return_if_fail (count >= -1); g_return_if_fail (count >= -1);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->repeat_count != count) if (priv->repeat_count != count)
{ {
@ -2141,9 +2190,13 @@ clutter_timeline_set_repeat_count (ClutterTimeline *timeline,
gint gint
clutter_timeline_get_repeat_count (ClutterTimeline *timeline) clutter_timeline_get_repeat_count (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
return timeline->priv->repeat_count; priv = clutter_timeline_get_instance_private (timeline);
return priv->repeat_count;
} }
/** /**
@ -2175,7 +2228,7 @@ clutter_timeline_set_progress_func (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->progress_notify != NULL) if (priv->progress_notify != NULL)
priv->progress_notify (priv->progress_data); priv->progress_notify (priv->progress_data);
@ -2193,12 +2246,13 @@ clutter_timeline_set_progress_func (ClutterTimeline *timeline,
} }
static gdouble static gdouble
clutter_timeline_progress_func (ClutterTimeline *timeline, clutter_timeline_progress_func (ClutterTimeline *timeline,
gdouble elapsed, gdouble elapsed,
gdouble duration, gdouble duration,
gpointer user_data G_GNUC_UNUSED) gpointer user_data G_GNUC_UNUSED)
{ {
ClutterTimelinePrivate *priv = timeline->priv; ClutterTimelinePrivate *priv =
clutter_timeline_get_instance_private (timeline);
/* parametrized easing functions need to be handled separately */ /* parametrized easing functions need to be handled separately */
switch (priv->progress_mode) switch (priv->progress_mode)
@ -2265,7 +2319,7 @@ clutter_timeline_set_progress_mode (ClutterTimeline *timeline,
g_return_if_fail (mode < CLUTTER_ANIMATION_LAST); g_return_if_fail (mode < CLUTTER_ANIMATION_LAST);
g_return_if_fail (mode != CLUTTER_CUSTOM_MODE); g_return_if_fail (mode != CLUTTER_CUSTOM_MODE);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->progress_mode == mode) if (priv->progress_mode == mode)
return; return;
@ -2299,9 +2353,13 @@ clutter_timeline_set_progress_mode (ClutterTimeline *timeline,
ClutterAnimationMode ClutterAnimationMode
clutter_timeline_get_progress_mode (ClutterTimeline *timeline) clutter_timeline_get_progress_mode (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), CLUTTER_LINEAR); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), CLUTTER_LINEAR);
return timeline->priv->progress_mode; priv = clutter_timeline_get_instance_private (timeline);
return priv->progress_mode;
} }
/** /**
@ -2326,7 +2384,7 @@ clutter_timeline_get_duration_hint (ClutterTimeline *timeline)
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->repeat_count == 0) if (priv->repeat_count == 0)
return priv->duration; return priv->duration;
@ -2349,9 +2407,13 @@ clutter_timeline_get_duration_hint (ClutterTimeline *timeline)
gint gint
clutter_timeline_get_current_repeat (ClutterTimeline *timeline) clutter_timeline_get_current_repeat (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0);
return timeline->priv->current_repeat; priv = clutter_timeline_get_instance_private (timeline);
return priv->current_repeat;
} }
/** /**
@ -2374,7 +2436,7 @@ clutter_timeline_set_step_progress (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
g_return_if_fail (n_steps > 0); g_return_if_fail (n_steps > 0);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
if (priv->progress_mode == CLUTTER_STEPS && if (priv->progress_mode == CLUTTER_STEPS &&
priv->n_steps == n_steps && priv->n_steps == n_steps &&
@ -2403,18 +2465,22 @@ clutter_timeline_get_step_progress (ClutterTimeline *timeline,
gint *n_steps, gint *n_steps,
ClutterStepMode *step_mode) ClutterStepMode *step_mode)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE);
if (!(timeline->priv->progress_mode == CLUTTER_STEPS || priv = clutter_timeline_get_instance_private (timeline);
timeline->priv->progress_mode == CLUTTER_STEP_START ||
timeline->priv->progress_mode == CLUTTER_STEP_END)) if (!(priv->progress_mode == CLUTTER_STEPS ||
priv->progress_mode == CLUTTER_STEP_START ||
priv->progress_mode == CLUTTER_STEP_END))
return FALSE; return FALSE;
if (n_steps != NULL) if (n_steps != NULL)
*n_steps = timeline->priv->n_steps; *n_steps = priv->n_steps;
if (step_mode != NULL) if (step_mode != NULL)
*step_mode = timeline->priv->step_mode; *step_mode = priv->step_mode;
return TRUE; return TRUE;
} }
@ -2443,7 +2509,7 @@ clutter_timeline_set_cubic_bezier_progress (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
g_return_if_fail (c_1 != NULL && c_2 != NULL); g_return_if_fail (c_1 != NULL && c_2 != NULL);
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
priv->cb_1 = *c_1; priv->cb_1 = *c_1;
priv->cb_2 = *c_2; priv->cb_2 = *c_2;
@ -2473,20 +2539,23 @@ clutter_timeline_get_cubic_bezier_progress (ClutterTimeline *timeline,
graphene_point_t *c_1, graphene_point_t *c_1,
graphene_point_t *c_2) graphene_point_t *c_2)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE);
if (!(timeline->priv->progress_mode == CLUTTER_CUBIC_BEZIER || priv = clutter_timeline_get_instance_private (timeline);
timeline->priv->progress_mode == CLUTTER_EASE || if (!(priv->progress_mode == CLUTTER_CUBIC_BEZIER ||
timeline->priv->progress_mode == CLUTTER_EASE_IN || priv->progress_mode == CLUTTER_EASE ||
timeline->priv->progress_mode == CLUTTER_EASE_OUT || priv->progress_mode == CLUTTER_EASE_IN ||
timeline->priv->progress_mode == CLUTTER_EASE_IN_OUT)) priv->progress_mode == CLUTTER_EASE_OUT ||
priv->progress_mode == CLUTTER_EASE_IN_OUT))
return FALSE; return FALSE;
if (c_1 != NULL) if (c_1 != NULL)
*c_1 = timeline->priv->cb_1; *c_1 = priv->cb_1;
if (c_2 != NULL) if (c_2 != NULL)
*c_2 = timeline->priv->cb_2; *c_2 = priv->cb_2;
return TRUE; return TRUE;
} }
@ -2497,9 +2566,13 @@ clutter_timeline_get_cubic_bezier_progress (ClutterTimeline *timeline,
ClutterFrameClock * ClutterFrameClock *
clutter_timeline_get_frame_clock (ClutterTimeline *timeline) clutter_timeline_get_frame_clock (ClutterTimeline *timeline)
{ {
ClutterTimelinePrivate *priv;
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL); g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL);
return timeline->priv->frame_clock; priv = clutter_timeline_get_instance_private (timeline);
return priv->frame_clock;
} }
void void
@ -2510,7 +2583,7 @@ clutter_timeline_set_frame_clock (ClutterTimeline *timeline,
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline)); g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv; priv = clutter_timeline_get_instance_private (timeline);
g_assert (!frame_clock || (frame_clock && !priv->actor)); g_assert (!frame_clock || (frame_clock && !priv->actor));
g_return_if_fail (!frame_clock || (frame_clock && !priv->actor)); g_return_if_fail (!frame_clock || (frame_clock && !priv->actor));

View File

@ -32,14 +32,13 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define CLUTTER_TYPE_TIMELINE (clutter_timeline_get_type ()) #define CLUTTER_TYPE_TIMELINE (clutter_timeline_get_type ())
#define CLUTTER_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_TIMELINE, ClutterTimeline))
#define CLUTTER_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_TIMELINE, ClutterTimelineClass))
#define CLUTTER_IS_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_TIMELINE))
#define CLUTTER_IS_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_TIMELINE))
#define CLUTTER_TIMELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_TIMELINE, ClutterTimelineClass))
typedef struct _ClutterTimelineClass ClutterTimelineClass; CLUTTER_EXPORT
typedef struct _ClutterTimelinePrivate ClutterTimelinePrivate; G_DECLARE_DERIVABLE_TYPE (ClutterTimeline,
clutter_timeline,
CLUTTER,
TIMELINE,
GObject)
/** /**
* ClutterTimelineProgressFunc: * ClutterTimelineProgressFunc:
@ -57,13 +56,6 @@ typedef gdouble (* ClutterTimelineProgressFunc) (ClutterTimeline *timeline,
gdouble total, gdouble total,
gpointer user_data); gpointer user_data);
struct _ClutterTimeline
{
/*< private >*/
GObject parent_instance;
ClutterTimelinePrivate *priv;
};
/** /**
* ClutterTimelineClass: * ClutterTimelineClass:
@ -80,12 +72,12 @@ struct _ClutterTimelineClass
{ {
/*< private >*/ /*< private >*/
GObjectClass parent_class; GObjectClass parent_class;
/*< public >*/ /*< public >*/
void (*started) (ClutterTimeline *timeline); void (*started) (ClutterTimeline *timeline);
void (*completed) (ClutterTimeline *timeline); void (*completed) (ClutterTimeline *timeline);
void (*paused) (ClutterTimeline *timeline); void (*paused) (ClutterTimeline *timeline);
void (*new_frame) (ClutterTimeline *timeline, void (*new_frame) (ClutterTimeline *timeline,
gint msecs); gint msecs);
@ -96,9 +88,6 @@ struct _ClutterTimelineClass
gboolean is_finished); gboolean is_finished);
}; };
CLUTTER_EXPORT
GType clutter_timeline_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterTimeline * clutter_timeline_new_for_actor (ClutterActor *actor, ClutterTimeline * clutter_timeline_new_for_actor (ClutterActor *actor,
unsigned int duration_ms); unsigned int duration_ms);