From bc0b7e7756fe3dec91ca9f3ab3148ca527a669a9 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 24 Jan 2012 09:53:37 +0200 Subject: [PATCH] compositor: restructure weston_surface::transform Separate mutable data and cached immutable data in struct weston_surface. Signed-off-by: Pekka Paalanen --- src/compositor.c | 12 ++++++------ src/compositor.h | 19 ++++++++++++++++--- src/shell.c | 7 ++++--- src/util.c | 7 ++++--- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 3950ad7a..3330ffba 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -205,8 +205,8 @@ weston_surface_create(struct weston_compositor *compositor, surface->buffer_destroy_listener.func = surface_handle_buffer_destroy; - wl_list_init(&surface->transform.list); - surface->transform.dirty = 1; + wl_list_init(&surface->geometry.transformation_list); + surface->geometry.dirty = 1; return surface; } @@ -234,12 +234,12 @@ weston_surface_update_transform(struct weston_surface *surface) struct weston_matrix *inverse = &surface->transform.inverse; struct weston_transform *tform; - if (!surface->transform.dirty) + if (!surface->geometry.dirty) return; - surface->transform.dirty = 0; + surface->geometry.dirty = 0; - if (wl_list_empty(&surface->transform.list)) { + if (wl_list_empty(&surface->geometry.transformation_list)) { surface->transform.enabled = 0; return; } @@ -247,7 +247,7 @@ weston_surface_update_transform(struct weston_surface *surface) surface->transform.enabled = 1; weston_matrix_init(matrix); - wl_list_for_each(tform, &surface->transform.list, link) + wl_list_for_each(tform, &surface->geometry.transformation_list, link) weston_matrix_multiply(matrix, &tform->matrix); if (weston_matrix_invert(inverse, matrix) < 0) { diff --git a/src/compositor.h b/src/compositor.h index 580800db..7555e852 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -224,14 +224,27 @@ struct weston_surface { uint32_t visual; int overlapped; + /* Surface geometry state, mutable. + * If you change anything, set dirty = 1. + * That includes the transformations referenced from the list. + */ struct { - struct wl_list list; + /* struct weston_transform */ + struct wl_list transformation_list; + int dirty; + } geometry; - /* derived state, set up by weston_surface_update_transform */ + /* State derived from geometry state, read-only. + * This is updated by weston_surface_update_transform(). + */ + struct { + /* matrix and inverse are used only if enabled = 1. + * If enabled = 0, use x, y, width, height directly. + */ + int enabled; struct weston_matrix matrix; struct weston_matrix inverse; - int enabled; } transform; /* diff --git a/src/shell.c b/src/shell.c index 49b0b109..d6e0205d 100644 --- a/src/shell.c +++ b/src/shell.c @@ -979,7 +979,7 @@ rotate_grab_motion(struct wl_grab *grab, r = sqrtf(dx * dx + dy * dy); wl_list_remove(&surface->rotation.transform.link); - surface->surface->transform.dirty = 1; + surface->surface->geometry.dirty = 1; if (r > 20.0f) { struct weston_matrix roto; @@ -999,8 +999,9 @@ rotate_grab_motion(struct wl_grab *grab, weston_matrix_translate(matrix, rotate->center.x, rotate->center.y, 0.0f); - wl_list_insert(surface->surface->transform.list.prev, - &surface->rotation.transform.link); + wl_list_insert( + surface->surface->geometry.transformation_list.prev, + &surface->rotation.transform.link); } else { wl_list_init(&surface->rotation.transform.link); } diff --git a/src/util.c b/src/util.c index 6b8477a4..c749f29d 100644 --- a/src/util.c +++ b/src/util.c @@ -99,7 +99,7 @@ weston_zoom_destroy(struct weston_zoom *zoom) wl_list_remove(&zoom->animation.link); wl_list_remove(&zoom->listener.link); wl_list_remove(&zoom->transform.link); - zoom->surface->transform.dirty = 1; + zoom->surface->geometry.dirty = 1; if (zoom->done) zoom->done(zoom, zoom->data); free(zoom); @@ -146,7 +146,7 @@ weston_zoom_frame(struct weston_animation *animation, if (es->alpha > 255) es->alpha = 255; - zoom->surface->transform.dirty = 1; + zoom->surface->geometry.dirty = 1; weston_compositor_damage_all(es->compositor); } @@ -166,7 +166,8 @@ weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop, zoom->data = data; zoom->start = start; zoom->stop = stop; - wl_list_insert(&surface->transform.list, &zoom->transform.link); + wl_list_insert(&surface->geometry.transformation_list, + &zoom->transform.link); weston_spring_init(&zoom->spring, 200.0, 0.0, 1.0); zoom->spring.friction = 700; zoom->spring.timestamp = weston_compositor_get_time();