Commit 9c7afe0c authored by Neil Roberts's avatar Neil Roberts

[timeline] Remove the concept of frames from timelines

Timelines no longer work in terms of a frame rate and a number of
frames but instead just have a duration in milliseconds. This better
matches the working of the master clock where if any timelines are
running it will redraw as fast as possible rather than limiting to the
lowest rated timeline.

Most applications will just create animations and expect them to
finish in a certain amount of time without caring about how many
frames are drawn. If a frame is going to be drawn it might as well
update all of the animations to some fraction of the total animation
rather than rounding to the nearest whole frame.

The 'frame_num' parameter of the new-frame signal is now 'msecs' which
is a number of milliseconds progressed along the
timeline. Applications should use clutter_timeline_get_progress
instead of the frame number.

Markers can now only be attached at a time value. The position is
stored in milliseconds rather than at a frame number.

test-timeline-smoothness and test-timeline-dup-frames have been
removed because they no longer make sense.
parent c20886c5
......@@ -603,9 +603,7 @@ clutter_ease_out_quad (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble p = t / d;
gdouble p = clutter_timeline_get_progress (timeline);
return -1.0 * p * (p - 2);
}
......@@ -615,8 +613,8 @@ clutter_ease_in_out_quad (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / (d / 2);
if (p < 1)
......@@ -632,9 +630,7 @@ clutter_ease_in_cubic (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble p = t / d;
gdouble p = clutter_timeline_get_progress (timeline);
return p * p * p;
}
......@@ -644,8 +640,8 @@ clutter_ease_out_cubic (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / d - 1;
return p * p * p + 1;
......@@ -656,8 +652,8 @@ clutter_ease_in_out_cubic (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / (d / 2);
if (p < 1)
......@@ -673,9 +669,7 @@ clutter_ease_in_quart (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble p = t / d;
gdouble p = clutter_timeline_get_progress (timeline);
return p * p * p * p;
}
......@@ -685,8 +679,8 @@ clutter_ease_out_quart (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / d - 1;
return -1.0 * (p * p * p * p - 1);
......@@ -697,8 +691,8 @@ clutter_ease_in_out_quart (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / (d / 2);
if (p < 1)
......@@ -714,9 +708,7 @@ clutter_ease_in_quint (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble p = t / d;
gdouble p = clutter_timeline_get_progress (timeline);
return p * p * p * p * p;
}
......@@ -726,8 +718,8 @@ clutter_ease_out_quint (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / d - 1;
return p * p * p * p * p + 1;
......@@ -738,8 +730,8 @@ clutter_ease_in_out_quint (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / (d / 2);
if (p < 1)
......@@ -755,8 +747,8 @@ clutter_ease_in_sine (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
return -1.0 * cos (t / d * G_PI_2) + 1.0;
}
......@@ -766,8 +758,8 @@ clutter_ease_out_sine (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
return sin (t / d * G_PI_2);
}
......@@ -777,8 +769,8 @@ clutter_ease_in_out_sine (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
return -0.5 * (cos (G_PI * t / d) - 1);
}
......@@ -788,8 +780,8 @@ clutter_ease_in_expo (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
return (t == 0) ? 0.0 : pow (2, 10 * (t / d - 1));
}
......@@ -799,8 +791,8 @@ clutter_ease_out_expo (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
return (t == d) ? 1.0 : -pow (2, -10 * t / d) + 1;
}
......@@ -810,8 +802,8 @@ clutter_ease_in_out_expo (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p;
if (t == 0)
......@@ -835,9 +827,7 @@ clutter_ease_in_circ (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble p = t / d;
gdouble p = clutter_timeline_get_progress (timeline);
return -1.0 * (sqrt (1 - p * p) - 1);
}
......@@ -847,8 +837,8 @@ clutter_ease_out_circ (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / d - 1;
return sqrt (1 - p * p);
......@@ -859,8 +849,8 @@ clutter_ease_in_out_circ (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / (d / 2);
if (p < 1)
......@@ -876,8 +866,8 @@ clutter_ease_in_elastic (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = d * .3;
gdouble s = p / 4;
gdouble q = t / d;
......@@ -895,8 +885,8 @@ clutter_ease_out_elastic (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = d * .3;
gdouble s = p / 4;
gdouble q = t / d;
......@@ -912,8 +902,8 @@ clutter_ease_in_out_elastic (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = d * (.3 * 1.5);
gdouble s = p / 4;
gdouble q = t / (d / 2);
......@@ -942,9 +932,7 @@ clutter_ease_in_back (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble p = t / d;
gdouble p = clutter_timeline_get_progress (timeline);
return p * p * ((1.70158 + 1) * p - 1.70158);
}
......@@ -954,8 +942,8 @@ clutter_ease_out_back (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / d - 1;
return p * p * ((1.70158 + 1) * p + 1.70158) + 1;
......@@ -966,8 +954,8 @@ clutter_ease_in_out_back (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
gdouble p = t / (d / 2);
gdouble s = 1.70158 * 1.525;
......@@ -1019,8 +1007,8 @@ clutter_ease_in_bounce (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
return ease_in_bounce_internal (t, d);
}
......@@ -1030,8 +1018,8 @@ clutter_ease_out_bounce (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
return ease_out_bounce_internal (t, d);
}
......@@ -1041,8 +1029,8 @@ clutter_ease_in_out_bounce (ClutterAlpha *alpha,
gpointer dummy G_GNUC_UNUSED)
{
ClutterTimeline *timeline = alpha->priv->timeline;
gdouble t = clutter_timeline_get_current_frame (timeline);
gdouble d = clutter_timeline_get_n_frames (timeline);
gdouble t = clutter_timeline_get_elapsed_time (timeline);
gdouble d = clutter_timeline_get_duration (timeline);
if (t < d / 2)
return ease_in_bounce_internal (t * 2, d) * 0.5;
......
This diff is collapsed.
......@@ -112,17 +112,12 @@ struct _ClutterTimelineClass
GType clutter_timeline_get_type (void) G_GNUC_CONST;
ClutterTimeline *clutter_timeline_new (guint n_frames,
guint fps);
ClutterTimeline *clutter_timeline_new_for_duration (guint msecs);
ClutterTimeline *clutter_timeline_new (guint msecs);
ClutterTimeline *clutter_timeline_clone (ClutterTimeline *timeline);
guint clutter_timeline_get_duration (ClutterTimeline *timeline);
void clutter_timeline_set_duration (ClutterTimeline *timeline,
guint msecs);
guint clutter_timeline_get_speed (ClutterTimeline *timeline);
void clutter_timeline_set_speed (ClutterTimeline *timeline,
guint fps);
ClutterTimelineDirection clutter_timeline_get_direction (ClutterTimeline *timeline);
void clutter_timeline_set_direction (ClutterTimeline *timeline,
ClutterTimelineDirection direction);
......@@ -134,32 +129,25 @@ void clutter_timeline_set_loop (ClutterTimeline *timeli
gboolean clutter_timeline_get_loop (ClutterTimeline *timeline);
void clutter_timeline_rewind (ClutterTimeline *timeline);
void clutter_timeline_skip (ClutterTimeline *timeline,
guint n_frames);
guint msecs);
void clutter_timeline_advance (ClutterTimeline *timeline,
guint frame_num);
gint clutter_timeline_get_current_frame (ClutterTimeline *timeline);
guint msecs);
guint clutter_timeline_get_elapsed_time (ClutterTimeline *timeline);
gdouble clutter_timeline_get_progress (ClutterTimeline *timeline);
CoglFixed clutter_timeline_get_progressx (ClutterTimeline *timeline);
void clutter_timeline_set_n_frames (ClutterTimeline *timeline,
guint n_frames);
guint clutter_timeline_get_n_frames (ClutterTimeline *timeline);
gboolean clutter_timeline_is_playing (ClutterTimeline *timeline);
void clutter_timeline_set_delay (ClutterTimeline *timeline,
guint msecs);
guint clutter_timeline_get_delay (ClutterTimeline *timeline);
guint clutter_timeline_get_delta (ClutterTimeline *timeline,
guint *msecs);
guint clutter_timeline_get_delta (ClutterTimeline *timeline);
void clutter_timeline_add_marker_at_frame (ClutterTimeline *timeline,
const gchar *marker_name,
guint frame_num);
void clutter_timeline_add_marker_at_time (ClutterTimeline *timeline,
const gchar *marker_name,
guint msecs);
void clutter_timeline_remove_marker (ClutterTimeline *timeline,
const gchar *marker_name);
gchar ** clutter_timeline_list_markers (ClutterTimeline *timeline,
gint frame_num,
gint msecs,
gsize *n_markers) G_GNUC_MALLOC;
gboolean clutter_timeline_has_marker (ClutterTimeline *timeline,
const gchar *marker_name);
......
......@@ -542,18 +542,13 @@ clutter_stage_add
ClutterTimeline
ClutterTimelineClass
clutter_timeline_new
clutter_timeline_new_for_duration
clutter_timeline_clone
<SUBSECTION>
clutter_timeline_set_speed
clutter_timeline_get_speed
clutter_timeline_set_duration
clutter_timeline_get_duration
clutter_timeline_set_loop
clutter_timeline_get_loop
clutter_timeline_set_n_frames
clutter_timeline_get_n_frames
clutter_timeline_set_delay
clutter_timeline_get_delay
ClutterTimelineDirection
......@@ -567,14 +562,13 @@ clutter_timeline_stop
clutter_timeline_rewind
clutter_timeline_skip
clutter_timeline_advance
clutter_timeline_get_current_frame
clutter_timeline_get_elapsed_time
clutter_timeline_get_delta
clutter_timeline_get_progress
clutter_timeline_get_progressx
clutter_timeline_is_playing
<SUBSECTION>
clutter_timeline_add_marker_at_frame
clutter_timeline_add_marker_at_time
clutter_timeline_has_marker
clutter_timeline_list_markers
......
......@@ -7,10 +7,8 @@ test_conformance_SOURCES = \
test-conform-common.c \
test-conform-common.h \
\
test-timeline-dup-frames.c \
test-timeline-interpolate.c \
test-timeline-rewind.c \
test-timeline-smoothness.c \
test-timeline.c \
test-vertex-buffer-contiguous.c \
test-vertex-buffer-interleved.c \
......
......@@ -85,11 +85,8 @@ main (int argc, char **argv)
shared_state->argv_addr = &argv;
TEST_CONFORM_SIMPLE ("/timeline", test_timeline);
TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_dup_frames);
TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_dup_frames);
TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_interpolate);
TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_rewind);
TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_smoothness);
TEST_CONFORM_SIMPLE ("/picking", test_pick);
......
#include <stdlib.h>
#include <glib.h>
#include <clutter/clutter.h>
#include "test-conform-common.h"
/* We use a nice slow timeline for this test since we
* dont want the timeouts to interpolate the timeline
* forward multiple frames */
#define TEST_TIMELINE_FPS 10
#define TEST_TIMELINE_FRAME_COUNT 20
typedef struct _TestState
{
ClutterTimeline *timeline;
gint prev_frame;
gint completion_count;
gint passed;
guint source_id;
GTimeVal prev_tick;
gulong msecs_delta;
} TestState;
static void
new_frame_cb (ClutterTimeline *timeline,
gint frame_num,
TestState *state)
{
gint current_frame = clutter_timeline_get_current_frame (state->timeline);
if (state->prev_frame
!= clutter_timeline_get_current_frame (state->timeline))
{
g_test_message ("timeline previous frame=%-4i "
"actual frame=%-4i (OK)\n",
state->prev_frame,
current_frame);
}
else
{
g_test_message ("timeline previous frame=%-4i "
"actual frame=%-4i (FAILED)\n",
state->prev_frame,
current_frame);
state->passed = FALSE;
}
state->prev_frame = current_frame;
}
static void
completed_cb (ClutterTimeline *timeline,
TestState *state)
{
state->completion_count++;
if (state->completion_count == 2)
{
if (state->passed)
{
g_test_message ("Passed\n");
clutter_main_quit ();
}
else
{
g_test_message ("Failed\n");
exit (EXIT_FAILURE);
}
}
}
static gboolean
frame_tick (gpointer data)
{
TestState *state = data;
GTimeVal cur_tick = { 0, };
gulong msecs;
g_get_current_time (&cur_tick);
if (state->prev_tick.tv_sec == 0)
state->prev_tick = cur_tick;
msecs = (cur_tick.tv_sec - state->prev_tick.tv_sec) * 1000
+ (cur_tick.tv_usec - state->prev_tick.tv_usec) / 1000;
if (clutter_timeline_is_playing (state->timeline))
clutter_timeline_advance_delta (state->timeline, msecs);
state->msecs_delta = msecs;
state->prev_tick = cur_tick;
return TRUE;
}
void
test_timeline_dup_frames (TestConformSimpleFixture *fixture,
gconstpointer data)
{
TestState state;
state.timeline =
clutter_timeline_new (TEST_TIMELINE_FRAME_COUNT,
TEST_TIMELINE_FPS);
clutter_timeline_set_loop (state.timeline, TRUE);
g_signal_connect (G_OBJECT(state.timeline),
"new-frame",
G_CALLBACK(new_frame_cb),
&state);
g_signal_connect (G_OBJECT(state.timeline),
"completed",
G_CALLBACK(completed_cb),
&state);
state.prev_frame = -1;
state.completion_count = 0;
state.passed = TRUE;
state.prev_tick.tv_sec = 0;
state.prev_tick.tv_usec = 0;
state.msecs_delta = 0;
state.source_id =
clutter_threads_add_frame_source (60, frame_tick, &state);
clutter_timeline_start (state.timeline);
clutter_main();
g_source_remove (state.source_id);
g_object_unref (state.timeline);
}
......@@ -9,7 +9,7 @@
* will interpolate the number frames that should have
* passed between timeouts. */
#define TEST_TIMELINE_FPS 1000
#define TEST_TIMELINE_FRAME_COUNT 5000
#define TEST_TIMELINE_DURATION 5000
/* We are at the mercy of the system scheduler so this
* may not be a very reliable tolerance. */
......@@ -42,7 +42,7 @@ new_frame_cb (ClutterTimeline *timeline,
g_get_current_time (&current_time);
current_frame = clutter_timeline_get_current_frame (state->timeline);
current_frame = clutter_timeline_get_elapsed_time (state->timeline);
msec_diff = (current_time.tv_sec - state->start_time.tv_sec) * 1000;
msec_diff += (current_time.tv_usec - state->start_time.tv_usec)/1000;
......@@ -50,13 +50,13 @@ new_frame_cb (ClutterTimeline *timeline,
/* If we expect to have interpolated past the end of the timeline
* we keep track of the overflow so we can determine when
* the next timeout will happen. We then clip expected_frames
* to TEST_TIMELINE_FRAME_COUNT since clutter-timeline
* to TEST_TIMELINE_DURATION since clutter-timeline
* semantics guaranty this frame is always signaled before
* looping */
if (state->expected_frame > TEST_TIMELINE_FRAME_COUNT)
if (state->expected_frame > TEST_TIMELINE_DURATION)
{
loop_overflow = state->expected_frame - TEST_TIMELINE_FRAME_COUNT;
state->expected_frame = TEST_TIMELINE_FRAME_COUNT;
loop_overflow = state->expected_frame - TEST_TIMELINE_DURATION;
state->expected_frame = TEST_TIMELINE_DURATION;
}
if (current_frame >= (state->expected_frame-TEST_ERROR_TOLERANCE)
......@@ -99,10 +99,10 @@ new_frame_cb (ClutterTimeline *timeline,
g_usleep (1000000);
}
if (current_frame >= TEST_TIMELINE_FRAME_COUNT)
if (current_frame >= TEST_TIMELINE_DURATION)
{
state->expected_frame += loop_overflow;
state->expected_frame -= TEST_TIMELINE_FRAME_COUNT;
state->expected_frame -= TEST_TIMELINE_DURATION;
g_test_message ("End of timeline reached: "
"Wrapping expected frame too %i\n",
state->expected_frame);
......@@ -165,8 +165,7 @@ test_timeline_interpolate (TestConformSimpleFixture *fixture,
TestState state;
state.timeline =
clutter_timeline_new (TEST_TIMELINE_FRAME_COUNT,
TEST_TIMELINE_FPS);
clutter_timeline_new (TEST_TIMELINE_DURATION);
clutter_timeline_set_loop (state.timeline, TRUE);
g_signal_connect (G_OBJECT(state.timeline),
"new-frame",
......
......@@ -4,8 +4,7 @@
#include "test-conform-common.h"
#define TEST_TIMELINE_FPS 10
#define TEST_TIMELINE_FRAME_COUNT 5
#define TEST_TIMELINE_DURATION 500
#define TEST_WATCHDOG_KICK_IN_SECONDS 10
typedef struct _TestState
......@@ -42,9 +41,9 @@ new_frame_cb (ClutterTimeline *timeline,
gint frame_num,
TestState *state)
{
gint current_frame = clutter_timeline_get_current_frame (timeline);
gint elapsed_time = clutter_timeline_get_elapsed_time (timeline);
if (current_frame == TEST_TIMELINE_FRAME_COUNT)
if (elapsed_time == TEST_TIMELINE_DURATION)
{
g_test_message ("new-frame signal recieved (end of timeline)\n");
g_test_message ("Rewinding timeline\n");
......@@ -53,7 +52,7 @@ new_frame_cb (ClutterTimeline *timeline,
}
else
{
if (current_frame == 0)
if (elapsed_time == 0)
{
g_test_message ("new-frame signal recieved (start of timeline)\n");
}
......@@ -101,8 +100,7 @@ test_timeline_rewind (TestConformSimpleFixture *fixture,
TestState state;
state.timeline =
clutter_timeline_new (TEST_TIMELINE_FRAME_COUNT,
TEST_TIMELINE_FPS);
clutter_timeline_new (TEST_TIMELINE_DURATION);
g_signal_connect (G_OBJECT(state.timeline),
"new-frame",
G_CALLBACK(new_frame_cb),
......
#include <stdlib.h>
#include <glib.h>
#include <clutter/clutter.h>
#include "test-conform-common.h"
#define TEST_TIMELINE_FPS 10
#define TEST_TIMELINE_FRAME_COUNT 20
#define TEST_ERROR_TOLERANCE 5
typedef struct _TestState
{
ClutterTimeline *timeline;
GTimeVal start_time;
GTimeVal prev_frame_time;
guint frame;
gint completion_count;
gint passed;
guint source_id;
GTimeVal prev_tick;
gulong msecs_delta;
} TestState;
static void
new_frame_cb (ClutterTimeline *timeline,
gint frame_num,
TestState *state)
{
GTimeVal current_time;
glong total_elapsed_ms;
glong frame_elapsed_ms = 0;
gchar *bump = "";
g_get_current_time (&current_time);
total_elapsed_ms = (current_time.tv_sec - state->start_time.tv_sec) * 1000;
total_elapsed_ms += (current_time.tv_usec - state->start_time.tv_usec)/1000;
if (state->frame>0)
{
frame_elapsed_ms =
(current_time.tv_sec - state->prev_frame_time.tv_sec) * 1000;
frame_elapsed_ms +=
(current_time.tv_usec - state->prev_frame_time.tv_usec)/1000;
if (ABS(frame_elapsed_ms - (1000/TEST_TIMELINE_FPS))
> TEST_ERROR_TOLERANCE)
{
state->passed = FALSE;
bump = " (BUMP)";
}
}
g_test_message ("timeline frame=%-2d total elapsed=%-4li(ms) "
"since last frame=%-4li(ms)%s\n",
clutter_timeline_get_current_frame(state->timeline),
total_elapsed_ms,
frame_elapsed_ms,
bump);
state->prev_frame_time = current_time;
state->frame++;
}