[PATCH weston 2/8] animation: Make fade more controllable
Ander Conselvan de Oliveira
ander.conselvan.de.oliveira at intel.com
Thu Feb 21 08:35:17 PST 2013
Add parameters to weston_fade_run() for setting the initial and target
values for the fade, as well as a parameter to set the spring constant
used for the animation.
Also add the weston_fade_update() function, that allows the animation
to be changed while it is still running.
This will be used to move the fade animation from core Weston into the
shell. These changes are needed to be able to fade out as well as in,
and to be able to reverse the fade in case of user input.
---
src/animation.c | 17 ++++++++++++++++-
src/compositor.h | 5 +++++
src/shell.c | 2 +-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/animation.c b/src/animation.c
index d141b37..147a5c0 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -239,10 +239,25 @@ fade_frame(struct weston_surface_animation *animation)
WL_EXPORT struct weston_surface_animation *
weston_fade_run(struct weston_surface *surface,
+ float start, float end, float k,
weston_surface_animation_done_func_t done, void *data)
{
- return weston_surface_animation_run(surface, 0, 0,
+ struct weston_surface_animation *fade;
+
+ fade = weston_surface_animation_run(surface, 0, 0,
fade_frame, done, data);
+
+ weston_spring_init(&fade->spring, k, start, end);
+ surface->alpha = start;
+
+ return fade;
+}
+
+WL_EXPORT void
+weston_fade_update(struct weston_surface_animation *fade,
+ float start, float end, float k)
+{
+ weston_spring_init(&fade->spring, k, start, end);
}
static void
diff --git a/src/compositor.h b/src/compositor.h
index a45fdf6..7cd6a6b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -820,7 +820,12 @@ weston_zoom_run(struct weston_surface *surface, float start, float stop,
struct weston_surface_animation *
weston_fade_run(struct weston_surface *surface,
+ float start, float end, float k,
weston_surface_animation_done_func_t done, void *data);
+void
+weston_fade_update(struct weston_surface_animation *fade,
+ float start, float end, float k);
+
struct weston_surface_animation *
weston_slide_run(struct weston_surface *surface, float start, float stop,
weston_surface_animation_done_func_t done, void *data);
diff --git a/src/shell.c b/src/shell.c
index a4511fd..da17cfb 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -3026,7 +3026,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
{
switch (shell->win_animation_type) {
case ANIMATION_FADE:
- weston_fade_run(surface, NULL, NULL);
+ weston_fade_run(surface, 0.0, 1.0, 200.0, NULL, NULL);
break;
case ANIMATION_ZOOM:
weston_zoom_run(surface, 0.8, 1.0, NULL, NULL);
--
1.7.10.4
More information about the wayland-devel
mailing list