<br><div class="gmail_quote">On Thu, Jun 7, 2012 at 3:13 PM, Kristian Høgsberg <span dir="ltr">&lt;<a href="mailto:hoegsberg@gmail.com" target="_blank">hoegsberg@gmail.com</a>&gt;</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>
&gt; Here we introduce a pending animation_list to which animations are<br>
&gt; added by weston_animation_run(). This fixes a timing issue when<br>
&gt; an animation is started from a keybinding and makes it so frame<br>
&gt; handlers are called only once per a single output&#39;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>
&gt; ---<br>
&gt;  src/compositor.c |   47 +++++++++++++++++++++++++++++++++++++++++------<br>
&gt;  src/compositor.h |   11 ++++++++++-<br>
&gt;  src/util.c       |   10 ++++------<br>
&gt;  3 files changed, 55 insertions(+), 13 deletions(-)<br>
&gt;<br>
&gt; diff --git a/src/compositor.c b/src/compositor.c<br>
&gt; index 3039c3d..9110d4c 100644<br>
&gt; --- a/src/compositor.c<br>
&gt; +++ b/src/compositor.c<br>
&gt; @@ -968,8 +968,7 @@ fade_frame(struct weston_animation *animation,<br>
&gt;       if (weston_spring_done(&amp;compositor-&gt;fade.spring)) {<br>
&gt;               compositor-&gt;fade.spring.current =<br>
&gt;                       compositor-&gt;fade.spring.target;<br>
&gt; -             wl_list_remove(&amp;animation-&gt;link);<br>
&gt; -             wl_list_init(&amp;animation-&gt;link);<br>
&gt; +             weston_animation_stop(animation);<br>
&gt;<br>
&gt;               if (compositor-&gt;fade.spring.current &lt; 0.001) {<br>
&gt;                       destroy_surface(&amp;surface-&gt;surface.resource);<br>
&gt; @@ -981,6 +980,30 @@ fade_frame(struct weston_animation *animation,<br>
&gt;       }<br>
&gt;  }<br>
&gt;<br>
&gt; +WL_EXPORT void<br>
&gt; +weston_animation_run(struct weston_compositor *compositor,<br>
&gt; +                     struct weston_output *output,<br>
&gt; +                     struct weston_animation *animation)<br>
&gt; +{<br>
&gt; +     struct weston_output *o;<br>
&gt; +<br>
&gt; +     if (output == NULL) {<br>
&gt; +             /* Select first output in list */<br>
&gt; +             wl_list_for_each(o, &amp;compositor-&gt;output_list, link)<br>
&gt; +                     break;<br>
&gt; +     } else<br>
&gt; +             o = output;<br>
<br>
</div></div>Hmm, if it&#39;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&#39;t have a surface to provide the<br>
output we&#39;ll just have to use<br>
<br>
        output = container_of(compositor-&gt;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>
&gt; +     wl_list_insert(o-&gt;animation_list.pending.prev, &amp;animation-&gt;link);<br>
&gt; +}<br>
&gt; +<br>
&gt; +WL_EXPORT void<br>
&gt; +weston_animation_stop(struct weston_animation *animation)<br>
&gt; +{<br>
&gt; +     wl_list_remove(&amp;animation-&gt;link);<br>
&gt; +     wl_list_init(&amp;animation-&gt;link);<br>
&gt; +}<br>
&gt; +<br>
&gt;  struct weston_frame_callback {<br>
&gt;       struct wl_resource resource;<br>
&gt;       struct wl_list link;<br>
&gt; @@ -1064,8 +1087,19 @@ weston_output_repaint(struct weston_output *output, int msecs)<br>
&gt;               wl_resource_destroy(&amp;cb-&gt;resource);<br>
&gt;       }<br>
&gt;<br>
&gt; -     wl_list_for_each_safe(animation, next, &amp;ec-&gt;animation_list, link)<br>
&gt; +     wl_list_for_each_safe(animation, next,<br>
&gt; +                             &amp;output-&gt;animation_list.current, link)<br>
&gt;               animation-&gt;frame(animation, output, msecs);<br>
&gt; +<br>
&gt; +     if (!wl_list_empty(&amp;output-&gt;animation_list.pending)) {<br>
&gt; +             wl_list_for_each_safe(animation, next,<br>
&gt; +                                     &amp;output-&gt;animation_list.pending, link) {<br>
&gt; +                     wl_list_insert(output-&gt;animation_list.current.prev,<br>
<br>
</div>Use<br>
<br>
        wl_list_insert_list(output-&gt;animation_list.prev,<br>
                            &amp;output-&gt;pending_animation_list)<br>
<br>
to move the list elements in constant time.<br></blockquote><div><br>I didn&#39;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>
&gt; +                                                     &amp;animation-&gt;link);<br>
&gt; +             }<br>
&gt; +             wl_list_init(&amp;output-&gt;animation_list.pending);<br>
&gt; +             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&#39;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>
&gt; +     }<br>
&gt;  }<br>
&gt;<br>
&gt;  static int<br>
&gt; @@ -1171,8 +1205,8 @@ weston_compositor_fade(struct weston_compositor *compositor, float tint)<br>
&gt;<br>
&gt;       weston_surface_damage(compositor-&gt;fade.surface);<br>
&gt;       if (wl_list_empty(&amp;compositor-&gt;fade.animation.link))<br>
&gt; -             wl_list_insert(compositor-&gt;animation_list.prev,<br>
&gt; -                            &amp;compositor-&gt;fade.animation.link);<br>
&gt; +             weston_animation_run(compositor, NULL,<br>
&gt; +                                     &amp;compositor-&gt;fade.animation);<br>
&gt;  }<br>
&gt;<br>
&gt;  static void<br>
&gt; @@ -2843,6 +2877,8 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,<br>
&gt;<br>
&gt;       wl_signal_init(&amp;output-&gt;frame_signal);<br>
&gt;       wl_list_init(&amp;output-&gt;frame_callback_list);<br>
&gt; +     wl_list_init(&amp;output-&gt;animation_list.current);<br>
&gt; +     wl_list_init(&amp;output-&gt;animation_list.pending);<br>
&gt;       wl_list_init(&amp;output-&gt;resource_list);<br>
&gt;<br>
&gt;       output-&gt;id = ffs(~output-&gt;compositor-&gt;output_id_pool) - 1;<br>
&gt; @@ -2967,7 +3003,6 @@ weston_compositor_init(struct weston_compositor *ec,<br>
&gt;       wl_list_init(&amp;ec-&gt;key_binding_list);<br>
&gt;       wl_list_init(&amp;ec-&gt;button_binding_list);<br>
&gt;       wl_list_init(&amp;ec-&gt;axis_binding_list);<br>
&gt; -     wl_list_init(&amp;ec-&gt;animation_list);<br>
&gt;       weston_spring_init(&amp;ec-&gt;fade.spring, 30.0, 1.0, 1.0);<br>
&gt;       ec-&gt;fade.animation.frame = fade_frame;<br>
&gt;       wl_list_init(&amp;ec-&gt;fade.animation.link);<br>
&gt; diff --git a/src/compositor.h b/src/compositor.h<br>
&gt; index 2d52048..30cb7bb 100644<br>
&gt; --- a/src/compositor.h<br>
&gt; +++ b/src/compositor.h<br>
&gt; @@ -131,6 +131,10 @@ struct weston_output {<br>
&gt;       struct weston_compositor *compositor;<br>
&gt;       struct weston_matrix matrix;<br>
&gt;       struct wl_list frame_callback_list;<br>
&gt; +     struct {<br>
&gt; +             struct wl_list current;<br>
&gt; +             struct wl_list pending;<br>
&gt; +     } animation_list;<br>
<br>
</div></div>Can we just call them animation_list and pending_animation_list?  I<br>
don&#39;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>
&gt;       int32_t x, y, mm_width, mm_height;<br>
&gt;       struct weston_border border;<br>
&gt;       pixman_region32_t region;<br>
&gt; @@ -287,7 +291,6 @@ struct weston_compositor {<br>
&gt;       struct wl_list key_binding_list;<br>
&gt;       struct wl_list button_binding_list;<br>
&gt;       struct wl_list axis_binding_list;<br>
&gt; -     struct wl_list animation_list;<br>
&gt;       struct {<br>
&gt;               struct weston_spring spring;<br>
&gt;               struct weston_animation animation;<br>
&gt; @@ -531,6 +534,12 @@ weston_compositor_activity(struct weston_compositor *compositor);<br>
&gt;  void<br>
&gt;  weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);<br>
&gt;<br>
&gt; +void<br>
&gt; +weston_animation_run(struct weston_compositor *compositor,<br>
&gt; +                             struct weston_output *output,<br>
&gt; +                             struct weston_animation *animation);<br>
&gt; +void<br>
&gt; +weston_animation_stop(struct weston_animation *animation);<br>
&gt;<br>
&gt;  struct weston_binding;<br>
&gt;  typedef void (*weston_key_binding_handler_t)(struct wl_seat *seat,<br>
&gt; diff --git a/src/util.c b/src/util.c<br>
&gt; index 3d28f8f..23cf222 100644<br>
&gt; --- a/src/util.c<br>
&gt; +++ b/src/util.c<br>
&gt; @@ -108,7 +108,7 @@ struct weston_fade {<br>
&gt;  static void<br>
&gt;  weston_zoom_destroy(struct weston_zoom *zoom)<br>
&gt;  {<br>
&gt; -     wl_list_remove(&amp;zoom-&gt;animation.link);<br>
&gt; +     weston_animation_stop(&amp;zoom-&gt;animation);<br>
&gt;       wl_list_remove(&amp;zoom-&gt;listener.link);<br>
&gt;       wl_list_remove(&amp;zoom-&gt;transform.link);<br>
&gt;       zoom-&gt;surface-&gt;geometry.dirty = 1;<br>
&gt; @@ -188,8 +188,7 @@ weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,<br>
&gt;       wl_signal_add(&amp;surface-&gt;surface.resource.destroy_signal,<br>
&gt;                     &amp;zoom-&gt;listener);<br>
&gt;<br>
&gt; -     wl_list_insert(&amp;surface-&gt;compositor-&gt;animation_list,<br>
&gt; -                    &amp;zoom-&gt;animation.link);<br>
&gt; +     weston_animation_run(surface-&gt;compositor, NULL, &amp;zoom-&gt;animation);<br>
<br>
</div></div>Should be running out surface-&gt;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&#39;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>
&gt;<br>
&gt;       return zoom;<br>
&gt;  }<br>
&gt; @@ -443,7 +442,7 @@ weston_environment_get_fd(const char *env)<br>
&gt;  static void<br>
&gt;  weston_fade_destroy(struct weston_fade *fade)<br>
&gt;  {<br>
&gt; -     wl_list_remove(&amp;fade-&gt;animation.link);<br>
&gt; +     weston_animation_stop(&amp;fade-&gt;animation);<br>
&gt;       wl_list_remove(&amp;fade-&gt;listener.link);<br>
&gt;       fade-&gt;surface-&gt;geometry.dirty = 1;<br>
&gt;       if (fade-&gt;done)<br>
&gt; @@ -510,8 +509,7 @@ weston_fade_run(struct weston_surface *surface,<br>
&gt;       wl_signal_add(&amp;surface-&gt;surface.resource.destroy_signal,<br>
&gt;                     &amp;fade-&gt;listener);<br>
&gt;<br>
&gt; -     wl_list_insert(&amp;surface-&gt;compositor-&gt;animation_list,<br>
&gt; -                    &amp;fade-&gt;animation.link);<br>
&gt; +     weston_animation_run(surface-&gt;compositor, NULL, &amp;fade-&gt;animation);<br>
<br>
</div>Same here, run on surface-&gt;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>
&gt;       return fade;<br>
&gt;  }<br>
<span class="HOEnZb"><font color="#888888">&gt; --<br>
&gt; 1.7.7.6<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; wayland-devel mailing list<br>
&gt; <a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
&gt; <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>