Apocalypse 5

Back to Clutter/Apocalypses

Apocalypse

or Alpha Schm-alpha.

The Timeline should have a progress function to process the value returned when accessing the :progress property.

All API involving ClutterAlpha should be deprecated.

Exegesis

ClutterAlpha is a class that harks back to a different time, when ClutterTimelines were expensive, and where animations were controlled by behaviours that needed to be synchronized but required different easing modes.

Since the introduction of the new animation framework, both ClutterAlpha and ClutterTimeline are mostly used as internal types; Timeline is still exposed so that application code can control the animation without duplicating the same API in ClutterAnimation, ClutterAnimator, and ClutterState. ClutterAlpha, on the other hand, is a purely internal type, which is only manipulated through an easing mode enumeration property.

ClutterAlpha is also pretty inefficient: it requires calling a function during the ClutterTimeline::new-frame signal, or using an expensive notification of the :alpha property. The easing function also has to fetch the elapsed time and the duration from the timeline of the ClutterAlpha. this means many type checks and closures in a fairly performance critical path.

If we move the easing mode computation to ClutterTimeline we can achieve a more compact API, as well as a better performance profile; a timeline would pass the elapsed and total time to a progress function, and return the interpolated value, thus avoiding marshalling and asking the timeline through public API.

Sadly, we cannot deprecate ClutterAlpha:

  • the Alpha type is still exposed in parts of the API that we cannot deprecate, such as virtual functions;
  • we cannot reimplement ClutterAlpha in terms of the ClutterTimeline progress mode because of the ability to have multiple Alpha instances tied to the same Timeline;

  • we still allow globally registered progress functions to be used to extend the easing modes provided by Clutter.

We can, though, hint at its removal inside the documentation, and deprecating all public API that still uses ClutterAlpha.

Complete removal of ClutterAlpha is a 2.0 target.

Synopsis

ClutterTimeline progress mode

 void clutter_timeline_set_progress_mode (ClutterTimeline *timeline, ClutterAnimationMode mode);
 ClutterAnimationMode clutter_timeline_get_progress_mode (ClutterTimeline *timeline);

ClutterTimeline progress function

 /**
  * ClutterTimelineProgressFunc:
  * @timeline: a #ClutterTimeline
  * @elapsed: the time elapsed, in milliseconds
  * @duration: the duration of the timeline
  * @data: user data passed to the function
  *
  * Returns: a value in the closed interval [ -1, 2 ]
  */
 typedef double (* ClutterTimelineProgressFunc) (ClutterTimeline *timeline,
                                                 double           elapsed,
                                                 double           duration,
                                                 gpointer         user_data);

 void clutter_timeline_set_progress_func (ClutterTimeline             *timeline,
                                          ClutterTimelineProgressFunc  func,
                                          gpointer                     data,
                                          GDestroyNotify               notify);

Attic/Clutter/Apocalypses/Apocalypse5 (last edited 2024-04-11 15:39:34 by EmmanueleBassi)