[PATCH weston 07/11] Animate views instead of surfaces
Jason Ekstrand
jason at jlekstrand.net
Fri Sep 13 19:44:57 PDT 2013
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/animation.c | 120 +++++++++++++++++++++++++++---------------------------
src/compositor.h | 24 +++++------
src/spring-tool.c | 4 +-
3 files changed, 74 insertions(+), 74 deletions(-)
diff --git a/src/animation.c b/src/animation.c
index 0b2fa95..c4df5cf 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -34,7 +34,7 @@
WL_EXPORT void
weston_spring_init(struct weston_spring *spring,
- double k, double current, double target)
+ double k, double current, double target)
{
spring->k = k;
spring->friction = 400.0;
@@ -114,49 +114,49 @@ weston_spring_done(struct weston_spring *spring)
fabs(spring->current - spring->target) < 0.002;
}
-typedef void (*weston_surface_animation_frame_func_t)(struct weston_surface_animation *animation);
+typedef void (*weston_view_animation_frame_func_t)(struct weston_view_animation *animation);
-struct weston_surface_animation {
- struct weston_surface *surface;
+struct weston_view_animation {
+ struct weston_view *view;
struct weston_animation animation;
struct weston_spring spring;
struct weston_transform transform;
struct wl_listener listener;
float start, stop;
- weston_surface_animation_frame_func_t frame;
- weston_surface_animation_done_func_t done;
+ weston_view_animation_frame_func_t frame;
+ weston_view_animation_done_func_t done;
void *data;
};
static void
-weston_surface_animation_destroy(struct weston_surface_animation *animation)
+weston_view_animation_destroy(struct weston_view_animation *animation)
{
wl_list_remove(&animation->animation.link);
wl_list_remove(&animation->listener.link);
wl_list_remove(&animation->transform.link);
- weston_surface_geometry_dirty(animation->surface);
+ weston_view_geometry_dirty(animation->view);
if (animation->done)
animation->done(animation, animation->data);
free(animation);
}
static void
-handle_animation_surface_destroy(struct wl_listener *listener, void *data)
+handle_animation_view_destroy(struct wl_listener *listener, void *data)
{
- struct weston_surface_animation *animation =
+ struct weston_view_animation *animation =
container_of(listener,
- struct weston_surface_animation, listener);
+ struct weston_view_animation, listener);
- weston_surface_animation_destroy(animation);
+ weston_view_animation_destroy(animation);
}
static void
-weston_surface_animation_frame(struct weston_animation *base,
- struct weston_output *output, uint32_t msecs)
+weston_view_animation_frame(struct weston_animation *base,
+ struct weston_output *output, uint32_t msecs)
{
- struct weston_surface_animation *animation =
+ struct weston_view_animation *animation =
container_of(base,
- struct weston_surface_animation, animation);
+ struct weston_view_animation, animation);
if (base->frame_counter <= 1)
animation->spring.timestamp = msecs;
@@ -164,58 +164,58 @@ weston_surface_animation_frame(struct weston_animation *base,
weston_spring_update(&animation->spring, msecs);
if (weston_spring_done(&animation->spring)) {
- weston_surface_animation_destroy(animation);
+ weston_view_animation_destroy(animation);
return;
}
if (animation->frame)
animation->frame(animation);
- weston_surface_geometry_dirty(animation->surface);
- weston_compositor_schedule_repaint(animation->surface->compositor);
+ weston_view_geometry_dirty(animation->view);
+ weston_view_schedule_repaint(animation->view);
}
-static struct weston_surface_animation *
-weston_surface_animation_run(struct weston_surface *surface,
- float start, float stop,
- weston_surface_animation_frame_func_t frame,
- weston_surface_animation_done_func_t done,
- void *data)
+static struct weston_view_animation *
+weston_view_animation_run(struct weston_view *view,
+ float start, float stop,
+ weston_view_animation_frame_func_t frame,
+ weston_view_animation_done_func_t done,
+ void *data)
{
- struct weston_surface_animation *animation;
+ struct weston_view_animation *animation;
animation = malloc(sizeof *animation);
if (!animation)
return NULL;
- animation->surface = surface;
+ animation->view = view;
animation->frame = frame;
animation->done = done;
animation->data = data;
animation->start = start;
animation->stop = stop;
weston_matrix_init(&animation->transform.matrix);
- wl_list_insert(&surface->geometry.transformation_list,
+ wl_list_insert(&view->geometry.transformation_list,
&animation->transform.link);
weston_spring_init(&animation->spring, 200.0, 0.0, 1.0);
animation->spring.friction = 700;
animation->animation.frame_counter = 0;
- animation->animation.frame = weston_surface_animation_frame;
- weston_surface_animation_frame(&animation->animation, NULL, 0);
+ animation->animation.frame = weston_view_animation_frame;
+ weston_view_animation_frame(&animation->animation, NULL, 0);
- animation->listener.notify = handle_animation_surface_destroy;
- wl_signal_add(&surface->destroy_signal, &animation->listener);
+ animation->listener.notify = handle_animation_view_destroy;
+ wl_signal_add(&view->destroy_signal, &animation->listener);
- wl_list_insert(&surface->output->animation_list,
+ wl_list_insert(&view->output->animation_list,
&animation->animation.link);
return animation;
}
static void
-zoom_frame(struct weston_surface_animation *animation)
+zoom_frame(struct weston_view_animation *animation)
{
- struct weston_surface *es = animation->surface;
+ struct weston_view *es = animation->view;
float scale;
scale = animation->start +
@@ -235,14 +235,14 @@ zoom_frame(struct weston_surface_animation *animation)
es->alpha = 1.0;
}
-WL_EXPORT struct weston_surface_animation *
-weston_zoom_run(struct weston_surface *surface, float start, float stop,
- weston_surface_animation_done_func_t done, void *data)
+WL_EXPORT struct weston_view_animation *
+weston_zoom_run(struct weston_view *view, float start, float stop,
+ weston_view_animation_done_func_t done, void *data)
{
- struct weston_surface_animation *zoom;
+ struct weston_view_animation *zoom;
- zoom = weston_surface_animation_run(surface, start, stop,
- zoom_frame, done, data);
+ zoom = weston_view_animation_run(view, start, stop,
+ zoom_frame, done, data);
weston_spring_init(&zoom->spring, 300.0, start, stop);
zoom->spring.friction = 1400;
@@ -252,44 +252,44 @@ weston_zoom_run(struct weston_surface *surface, float start, float stop,
}
static void
-fade_frame(struct weston_surface_animation *animation)
+fade_frame(struct weston_view_animation *animation)
{
if (animation->spring.current > 0.999)
- animation->surface->alpha = 1;
+ animation->view->alpha = 1;
else if (animation->spring.current < 0.001 )
- animation->surface->alpha = 0;
+ animation->view->alpha = 0;
else
- animation->surface->alpha = animation->spring.current;
+ animation->view->alpha = animation->spring.current;
}
-WL_EXPORT struct weston_surface_animation *
-weston_fade_run(struct weston_surface *surface,
+WL_EXPORT struct weston_view_animation *
+weston_fade_run(struct weston_view *view,
float start, float end, float k,
- weston_surface_animation_done_func_t done, void *data)
+ weston_view_animation_done_func_t done, void *data)
{
- struct weston_surface_animation *fade;
+ struct weston_view_animation *fade;
- fade = weston_surface_animation_run(surface, 0, 0,
- fade_frame, done, data);
+ fade = weston_view_animation_run(view, 0, 0,
+ fade_frame, done, data);
weston_spring_init(&fade->spring, k, start, end);
fade->spring.friction = 1400;
fade->spring.previous = -(end - start) * 0.03;
- surface->alpha = start;
+ view->alpha = start;
return fade;
}
WL_EXPORT void
-weston_fade_update(struct weston_surface_animation *fade, float target)
+weston_fade_update(struct weston_view_animation *fade, float target)
{
fade->spring.target = target;
}
static void
-slide_frame(struct weston_surface_animation *animation)
+slide_frame(struct weston_view_animation *animation)
{
float scale;
@@ -300,14 +300,14 @@ slide_frame(struct weston_surface_animation *animation)
weston_matrix_translate(&animation->transform.matrix, 0, scale, 0);
}
-WL_EXPORT struct weston_surface_animation *
-weston_slide_run(struct weston_surface *surface, float start, float stop,
- weston_surface_animation_done_func_t done, void *data)
+WL_EXPORT struct weston_view_animation *
+weston_slide_run(struct weston_view *view, float start, float stop,
+ weston_view_animation_done_func_t done, void *data)
{
- struct weston_surface_animation *animation;
+ struct weston_view_animation *animation;
- animation = weston_surface_animation_run(surface, start, stop,
- slide_frame, done, data);
+ animation = weston_view_animation_run(view, start, stop,
+ slide_frame, done, data);
if (!animation)
return NULL;
diff --git a/src/compositor.h b/src/compositor.h
index 8bc7d7d..e87eb04 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1231,23 +1231,23 @@ weston_client_launch(struct weston_compositor *compositor,
void
weston_watch_process(struct weston_process *process);
-struct weston_surface_animation;
-typedef void (*weston_surface_animation_done_func_t)(struct weston_surface_animation *animation, void *data);
+struct weston_view_animation;
+typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data);
-struct weston_surface_animation *
-weston_zoom_run(struct weston_surface *surface, float start, float stop,
- weston_surface_animation_done_func_t done, void *data);
+struct weston_view_animation *
+weston_zoom_run(struct weston_view *view, float start, float stop,
+ weston_view_animation_done_func_t done, void *data);
-struct weston_surface_animation *
-weston_fade_run(struct weston_surface *surface,
+struct weston_view_animation *
+weston_fade_run(struct weston_view *view,
float start, float end, float k,
- weston_surface_animation_done_func_t done, void *data);
+ weston_view_animation_done_func_t done, void *data);
void
-weston_fade_update(struct weston_surface_animation *fade, float target);
+weston_fade_update(struct weston_view_animation *fade, float target);
-struct weston_surface_animation *
-weston_slide_run(struct weston_surface *surface, float start, float stop,
- weston_surface_animation_done_func_t done, void *data);
+struct weston_view_animation *
+weston_slide_run(struct weston_view *view, float start, float stop,
+ weston_view_animation_done_func_t done, void *data);
void
weston_surface_set_color(struct weston_surface *surface,
diff --git a/src/spring-tool.c b/src/spring-tool.c
index 935acc4..41cc52c 100644
--- a/src/spring-tool.c
+++ b/src/spring-tool.c
@@ -25,7 +25,7 @@
#include "compositor.h"
WL_EXPORT void
-weston_surface_geometry_dirty(struct weston_surface *surface)
+weston_view_geometry_dirty(struct weston_view *view)
{
}
@@ -36,7 +36,7 @@ weston_log(const char *fmt, ...)
}
WL_EXPORT void
-weston_compositor_schedule_repaint(struct weston_compositor *compositor)
+weston_view_schedule_repaint(struct weston_view *view)
{
}
--
1.8.3.1
More information about the wayland-devel
mailing list