compositor: restructure weston_surface::transform

Separate mutable data and cached immutable data in struct
weston_surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
Pekka Paalanen 2012-01-24 09:53:37 +02:00
parent 7ae02130bd
commit bc0b7e7756
4 changed files with 31 additions and 16 deletions

View file

@ -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) {

View file

@ -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;
int dirty;
/* struct weston_transform */
struct wl_list transformation_list;
/* derived state, set up by weston_surface_update_transform */
int dirty;
} geometry;
/* 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;
/*

View file

@ -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);
}

View file

@ -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();