compositor: restructure weston_surface::transform

Separate mutable data and cached immutable data in struct
weston_surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
dev
Pekka Paalanen 13 years ago
parent 7ae02130bd
commit bc0b7e7756
  1. 12
      src/compositor.c
  2. 19
      src/compositor.h
  3. 7
      src/shell.c
  4. 7
      src/util.c

@ -205,8 +205,8 @@ weston_surface_create(struct weston_compositor *compositor,
surface->buffer_destroy_listener.func = surface_handle_buffer_destroy; surface->buffer_destroy_listener.func = surface_handle_buffer_destroy;
wl_list_init(&surface->transform.list); wl_list_init(&surface->geometry.transformation_list);
surface->transform.dirty = 1; surface->geometry.dirty = 1;
return surface; return surface;
} }
@ -234,12 +234,12 @@ weston_surface_update_transform(struct weston_surface *surface)
struct weston_matrix *inverse = &surface->transform.inverse; struct weston_matrix *inverse = &surface->transform.inverse;
struct weston_transform *tform; struct weston_transform *tform;
if (!surface->transform.dirty) if (!surface->geometry.dirty)
return; 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; surface->transform.enabled = 0;
return; return;
} }
@ -247,7 +247,7 @@ weston_surface_update_transform(struct weston_surface *surface)
surface->transform.enabled = 1; surface->transform.enabled = 1;
weston_matrix_init(matrix); 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); weston_matrix_multiply(matrix, &tform->matrix);
if (weston_matrix_invert(inverse, matrix) < 0) { if (weston_matrix_invert(inverse, matrix) < 0) {

@ -224,14 +224,27 @@ struct weston_surface {
uint32_t visual; uint32_t visual;
int overlapped; int overlapped;
/* Surface geometry state, mutable.
* If you change anything, set dirty = 1.
* That includes the transformations referenced from the list.
*/
struct { struct {
struct wl_list list; /* struct weston_transform */
struct wl_list transformation_list;
int dirty; 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 matrix;
struct weston_matrix inverse; struct weston_matrix inverse;
int enabled;
} transform; } transform;
/* /*

@ -979,7 +979,7 @@ rotate_grab_motion(struct wl_grab *grab,
r = sqrtf(dx * dx + dy * dy); r = sqrtf(dx * dx + dy * dy);
wl_list_remove(&surface->rotation.transform.link); wl_list_remove(&surface->rotation.transform.link);
surface->surface->transform.dirty = 1; surface->surface->geometry.dirty = 1;
if (r > 20.0f) { if (r > 20.0f) {
struct weston_matrix roto; struct weston_matrix roto;
@ -999,8 +999,9 @@ rotate_grab_motion(struct wl_grab *grab,
weston_matrix_translate(matrix, rotate->center.x, weston_matrix_translate(matrix, rotate->center.x,
rotate->center.y, 0.0f); rotate->center.y, 0.0f);
wl_list_insert(surface->surface->transform.list.prev, wl_list_insert(
&surface->rotation.transform.link); surface->surface->geometry.transformation_list.prev,
&surface->rotation.transform.link);
} else { } else {
wl_list_init(&surface->rotation.transform.link); wl_list_init(&surface->rotation.transform.link);
} }

@ -99,7 +99,7 @@ weston_zoom_destroy(struct weston_zoom *zoom)
wl_list_remove(&zoom->animation.link); wl_list_remove(&zoom->animation.link);
wl_list_remove(&zoom->listener.link); wl_list_remove(&zoom->listener.link);
wl_list_remove(&zoom->transform.link); wl_list_remove(&zoom->transform.link);
zoom->surface->transform.dirty = 1; zoom->surface->geometry.dirty = 1;
if (zoom->done) if (zoom->done)
zoom->done(zoom, zoom->data); zoom->done(zoom, zoom->data);
free(zoom); free(zoom);
@ -146,7 +146,7 @@ weston_zoom_frame(struct weston_animation *animation,
if (es->alpha > 255) if (es->alpha > 255)
es->alpha = 255; es->alpha = 255;
zoom->surface->transform.dirty = 1; zoom->surface->geometry.dirty = 1;
weston_compositor_damage_all(es->compositor); 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->data = data;
zoom->start = start; zoom->start = start;
zoom->stop = stop; 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); weston_spring_init(&zoom->spring, 200.0, 0.0, 1.0);
zoom->spring.friction = 700; zoom->spring.friction = 700;
zoom->spring.timestamp = weston_compositor_get_time(); zoom->spring.timestamp = weston_compositor_get_time();

Loading…
Cancel
Save