<br><div class="gmail_quote">On Thu, Jun 7, 2012 at 3:13 PM, Kristian Høgsberg <span dir="ltr"><<a href="mailto:hoegsberg@gmail.com" target="_blank">hoegsberg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thu, Jun 07, 2012 at 09:12:29AM -0600, Scott Moreau wrote:<br>
> Here we introduce a pending animation_list to which animations are<br>
> added by weston_animation_run(). This fixes a timing issue when<br>
> an animation is started from a keybinding and makes it so frame<br>
> handlers are called only once per a single output's refresh.<br>
<br>
</div>Looks good, not much code after all. A few comments below.<br>
<br>
Kristian<br></blockquote><div><br>Hi Kristian, thanks for reviewing this set.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> ---<br>
> src/compositor.c | 47 +++++++++++++++++++++++++++++++++++++++++------<br>
> src/compositor.h | 11 ++++++++++-<br>
> src/util.c | 10 ++++------<br>
> 3 files changed, 55 insertions(+), 13 deletions(-)<br>
><br>
> diff --git a/src/compositor.c b/src/compositor.c<br>
> index 3039c3d..9110d4c 100644<br>
> --- a/src/compositor.c<br>
> +++ b/src/compositor.c<br>
> @@ -968,8 +968,7 @@ fade_frame(struct weston_animation *animation,<br>
> if (weston_spring_done(&compositor->fade.spring)) {<br>
> compositor->fade.spring.current =<br>
> compositor->fade.spring.target;<br>
> - wl_list_remove(&animation->link);<br>
> - wl_list_init(&animation->link);<br>
> + weston_animation_stop(animation);<br>
><br>
> if (compositor->fade.spring.current < 0.001) {<br>
> destroy_surface(&surface->surface.resource);<br>
> @@ -981,6 +980,30 @@ fade_frame(struct weston_animation *animation,<br>
> }<br>
> }<br>
><br>
> +WL_EXPORT void<br>
> +weston_animation_run(struct weston_compositor *compositor,<br>
> + struct weston_output *output,<br>
> + struct weston_animation *animation)<br>
> +{<br>
> + struct weston_output *o;<br>
> +<br>
> + if (output == NULL) {<br>
> + /* Select first output in list */<br>
> + wl_list_for_each(o, &compositor->output_list, link)<br>
> + break;<br>
> + } else<br>
> + o = output;<br>
<br>
</div></div>Hmm, if it's a weston_animation_* function it should take a<br>
weston_animation as its first argument. And the compositor argument<br>
is only there so we can get the first output from it if output is<br>
NULL... I think just<br>
<br>
weston_output_run_animation(output, animation) and<br>
<br>
and the couple of cases where we don't have a surface to provide the<br>
output we'll just have to use<br>
<br>
output = container_of(compositor->output_list.next,<br>
struct weston_output, link);<br></blockquote><div><br>Yep, that makes sense.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
> + wl_list_insert(o->animation_list.pending.prev, &animation->link);<br>
> +}<br>
> +<br>
> +WL_EXPORT void<br>
> +weston_animation_stop(struct weston_animation *animation)<br>
> +{<br>
> + wl_list_remove(&animation->link);<br>
> + wl_list_init(&animation->link);<br>
> +}<br>
> +<br>
> struct weston_frame_callback {<br>
> struct wl_resource resource;<br>
> struct wl_list link;<br>
> @@ -1064,8 +1087,19 @@ weston_output_repaint(struct weston_output *output, int msecs)<br>
> wl_resource_destroy(&cb->resource);<br>
> }<br>
><br>
> - wl_list_for_each_safe(animation, next, &ec->animation_list, link)<br>
> + wl_list_for_each_safe(animation, next,<br>
> + &output->animation_list.current, link)<br>
> animation->frame(animation, output, msecs);<br>
> +<br>
> + if (!wl_list_empty(&output->animation_list.pending)) {<br>
> + wl_list_for_each_safe(animation, next,<br>
> + &output->animation_list.pending, link) {<br>
> + wl_list_insert(output->animation_list.current.prev,<br>
<br>
</div>Use<br>
<br>
wl_list_insert_list(output->animation_list.prev,<br>
&output->pending_animation_list)<br>
<br>
to move the list elements in constant time.<br></blockquote><div><br>I didn't know about this before, will do.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
> + &animation->link);<br>
> + }<br>
> + wl_list_init(&output->animation_list.pending);<br>
> + weston_output_damage(output);<br>
<br>
</div>Use weston_compositor_schedule_repaint() here instead.<br>
weston_output_damage() makes us repaint the entire output. We don't<br>
want to actually have to repaint anything.<br></blockquote><div><br>ack.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> + }<br>
> }<br>
><br>
> static int<br>
> @@ -1171,8 +1205,8 @@ weston_compositor_fade(struct weston_compositor *compositor, float tint)<br>
><br>
> weston_surface_damage(compositor->fade.surface);<br>
> if (wl_list_empty(&compositor->fade.animation.link))<br>
> - wl_list_insert(compositor->animation_list.prev,<br>
> - &compositor->fade.animation.link);<br>
> + weston_animation_run(compositor, NULL,<br>
> + &compositor->fade.animation);<br>
> }<br>
><br>
> static void<br>
> @@ -2843,6 +2877,8 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,<br>
><br>
> wl_signal_init(&output->frame_signal);<br>
> wl_list_init(&output->frame_callback_list);<br>
> + wl_list_init(&output->animation_list.current);<br>
> + wl_list_init(&output->animation_list.pending);<br>
> wl_list_init(&output->resource_list);<br>
><br>
> output->id = ffs(~output->compositor->output_id_pool) - 1;<br>
> @@ -2967,7 +3003,6 @@ weston_compositor_init(struct weston_compositor *ec,<br>
> wl_list_init(&ec->key_binding_list);<br>
> wl_list_init(&ec->button_binding_list);<br>
> wl_list_init(&ec->axis_binding_list);<br>
> - wl_list_init(&ec->animation_list);<br>
> weston_spring_init(&ec->fade.spring, 30.0, 1.0, 1.0);<br>
> ec->fade.animation.frame = fade_frame;<br>
> wl_list_init(&ec->fade.animation.link);<br>
> diff --git a/src/compositor.h b/src/compositor.h<br>
> index 2d52048..30cb7bb 100644<br>
> --- a/src/compositor.h<br>
> +++ b/src/compositor.h<br>
> @@ -131,6 +131,10 @@ struct weston_output {<br>
> struct weston_compositor *compositor;<br>
> struct weston_matrix matrix;<br>
> struct wl_list frame_callback_list;<br>
> + struct {<br>
> + struct wl_list current;<br>
> + struct wl_list pending;<br>
> + } animation_list;<br>
<br>
</div></div>Can we just call them animation_list and pending_animation_list? I<br>
don't think these nested struct always makes things clearer.<br></blockquote><div><br>Sure, no problem.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> int32_t x, y, mm_width, mm_height;<br>
> struct weston_border border;<br>
> pixman_region32_t region;<br>
> @@ -287,7 +291,6 @@ struct weston_compositor {<br>
> struct wl_list key_binding_list;<br>
> struct wl_list button_binding_list;<br>
> struct wl_list axis_binding_list;<br>
> - struct wl_list animation_list;<br>
> struct {<br>
> struct weston_spring spring;<br>
> struct weston_animation animation;<br>
> @@ -531,6 +534,12 @@ weston_compositor_activity(struct weston_compositor *compositor);<br>
> void<br>
> weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);<br>
><br>
> +void<br>
> +weston_animation_run(struct weston_compositor *compositor,<br>
> + struct weston_output *output,<br>
> + struct weston_animation *animation);<br>
> +void<br>
> +weston_animation_stop(struct weston_animation *animation);<br>
><br>
> struct weston_binding;<br>
> typedef void (*weston_key_binding_handler_t)(struct wl_seat *seat,<br>
> diff --git a/src/util.c b/src/util.c<br>
> index 3d28f8f..23cf222 100644<br>
> --- a/src/util.c<br>
> +++ b/src/util.c<br>
> @@ -108,7 +108,7 @@ struct weston_fade {<br>
> static void<br>
> weston_zoom_destroy(struct weston_zoom *zoom)<br>
> {<br>
> - wl_list_remove(&zoom->animation.link);<br>
> + weston_animation_stop(&zoom->animation);<br>
> wl_list_remove(&zoom->listener.link);<br>
> wl_list_remove(&zoom->transform.link);<br>
> zoom->surface->geometry.dirty = 1;<br>
> @@ -188,8 +188,7 @@ weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,<br>
> wl_signal_add(&surface->surface.resource.destroy_signal,<br>
> &zoom->listener);<br>
><br>
> - wl_list_insert(&surface->compositor->animation_list,<br>
> - &zoom->animation.link);<br>
> + weston_animation_run(surface->compositor, NULL, &zoom->animation);<br>
<br>
</div></div>Should be running out surface->output, not the default output.<br></blockquote><div><br>Yes, completely overlooked this.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Also, you should remove the timestamp = weston_compositor_get_time()<br>
initializations (here and other animations) now that we solved that<br>
problem.<br></blockquote><div><br>I'm not really clear what you want to happen here. The timestamp should now be set in weston_output_repaint() when adding the pending animations to the animations list? or where?<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
><br>
> return zoom;<br>
> }<br>
> @@ -443,7 +442,7 @@ weston_environment_get_fd(const char *env)<br>
> static void<br>
> weston_fade_destroy(struct weston_fade *fade)<br>
> {<br>
> - wl_list_remove(&fade->animation.link);<br>
> + weston_animation_stop(&fade->animation);<br>
> wl_list_remove(&fade->listener.link);<br>
> fade->surface->geometry.dirty = 1;<br>
> if (fade->done)<br>
> @@ -510,8 +509,7 @@ weston_fade_run(struct weston_surface *surface,<br>
> wl_signal_add(&surface->surface.resource.destroy_signal,<br>
> &fade->listener);<br>
><br>
> - wl_list_insert(&surface->compositor->animation_list,<br>
> - &fade->animation.link);<br>
> + weston_animation_run(surface->compositor, NULL, &fade->animation);<br>
<br>
</div>Same here, run on surface->output.<br></blockquote><div><br>Indeed.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> return fade;<br>
> }<br>
<span class="HOEnZb"><font color="#888888">> --<br>
> 1.7.7.6<br>
><br>
> _______________________________________________<br>
> wayland-devel mailing list<br>
> <a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br>