[PATCH 2/3] Add frame_counter to weston_animation.

Scott Moreau oreaus at gmail.com
Fri Jun 8 18:40:54 PDT 2012


---
 src/compositor.c |    8 ++++++--
 src/compositor.h |    1 +
 src/util.c       |    2 ++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index d706b41..3f54450 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1060,8 +1060,10 @@ weston_output_repaint(struct weston_output *output, int msecs)
 		wl_resource_destroy(&cb->resource);
 	}
 
-	wl_list_for_each_safe(animation, next, &output->animation_list, link)
+	wl_list_for_each_safe(animation, next, &output->animation_list, link) {
 		animation->frame(animation, output, msecs);
+		animation->frame_counter++;
+	}
 }
 
 static int
@@ -1170,9 +1172,11 @@ weston_compositor_fade(struct weston_compositor *compositor, float tint)
 	}
 
 	weston_surface_damage(compositor->fade.surface);
-	if (wl_list_empty(&compositor->fade.animation.link))
+	if (wl_list_empty(&compositor->fade.animation.link)) {
+		compositor->fade.animation.frame_counter = 0;
 		wl_list_insert(output->animation_list.prev,
 			       &compositor->fade.animation.link);
+	}
 }
 
 static void
diff --git a/src/compositor.h b/src/compositor.h
index e353070..e8e8ecf 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -231,6 +231,7 @@ struct weston_shader {
 struct weston_animation {
 	void (*frame)(struct weston_animation *animation,
 		      struct weston_output *output, uint32_t msecs);
+	int frame_counter;
 	struct wl_list link;
 };
 
diff --git a/src/util.c b/src/util.c
index 97058fe..bc013ca 100644
--- a/src/util.c
+++ b/src/util.c
@@ -180,6 +180,7 @@ weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
 		       &zoom->transform.link);
 	weston_spring_init(&zoom->spring, 200.0, 0.0, 1.0);
 	zoom->spring.friction = 700;
+	zoom->animation.frame_counter = 0;
 	zoom->spring.timestamp = weston_compositor_get_time();
 	zoom->animation.frame = weston_zoom_frame;
 	weston_zoom_frame(&zoom->animation, NULL, zoom->spring.timestamp);
@@ -502,6 +503,7 @@ weston_fade_run(struct weston_surface *surface,
 	fade->data = data;
 	weston_spring_init(&fade->spring, 200.0, 0, 1.0);
 	fade->spring.friction = 700;
+	fade->animation.frame_counter = 0;
 	fade->spring.timestamp = weston_compositor_get_time();
 	fade->animation.frame = weston_fade_frame;
 	weston_fade_frame(&fade->animation, NULL, fade->spring.timestamp);
-- 
1.7.7.6



More information about the wayland-devel mailing list