compositor: make position a surface transformation

Put the surface translation (absolute position) into the surface
transformations list. This allows to set additional transformations
before and after the global translation.

Having the translation cached, changing the surface x,y now requires to
set the geometry.dirty flag.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
dev
Pekka Paalanen 13 years ago
parent 0e151bb487
commit cd40362bba
  1. 22
      src/compositor.c
  2. 2
      src/compositor.h

@ -206,6 +206,9 @@ weston_surface_create(struct weston_compositor *compositor,
surface->buffer_destroy_listener.func = surface_handle_buffer_destroy;
wl_list_init(&surface->geometry.transformation_list);
wl_list_insert(&surface->geometry.transformation_list,
&surface->transform.position.link);
weston_matrix_init(&surface->transform.position.matrix);
surface->geometry.dirty = 1;
return surface;
@ -239,13 +242,20 @@ weston_surface_update_transform(struct weston_surface *surface)
surface->geometry.dirty = 0;
if (wl_list_empty(&surface->geometry.transformation_list)) {
/* transform.position is always in transformation_list */
if (surface->geometry.transformation_list.next ==
&surface->transform.position.link &&
surface->geometry.transformation_list.prev ==
&surface->transform.position.link) {
surface->transform.enabled = 0;
return;
}
surface->transform.enabled = 1;
surface->transform.position.matrix.d[12] = surface->x;
surface->transform.position.matrix.d[13] = surface->y;
weston_matrix_init(matrix);
wl_list_for_each(tform, &surface->geometry.transformation_list, link)
weston_matrix_multiply(matrix, &tform->matrix);
@ -267,9 +277,6 @@ weston_surface_to_global(struct weston_surface *surface,
if (surface->transform.enabled) {
struct weston_vector v = { { sx, sy, 0.0f, 1.0f } };
v.f[0] += surface->x;
v.f[1] += surface->y;
weston_matrix_transform(&surface->transform.matrix, &v);
if (fabsf(v.f[3]) < 1e-6) {
@ -307,8 +314,8 @@ surface_from_global_float(struct weston_surface *surface,
return;
}
*sx = v.f[0] / v.f[3] - surface->x;
*sy = v.f[1] / v.f[3] - surface->y;
*sx = v.f[0] / v.f[3];
*sy = v.f[1] / v.f[3];
} else {
*sx = x - surface->x;
*sy = y - surface->y;
@ -394,6 +401,7 @@ weston_surface_configure(struct weston_surface *surface,
surface->y = y;
surface->width = width;
surface->height = height;
surface->geometry.dirty = 1;
weston_surface_assign_output(surface);
weston_surface_damage(surface);
@ -1231,6 +1239,7 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
wd->sprite->x = device->x - wd->hotspot_x;
wd->sprite->y = device->y - wd->hotspot_y;
wd->sprite->geometry.dirty = 1;
weston_surface_damage(wd->sprite);
}
@ -1585,6 +1594,7 @@ input_device_attach(struct wl_client *client,
device->sprite->height = buffer->height;
device->sprite->x = device->input_device.x - device->hotspot_x;
device->sprite->y = device->input_device.y - device->hotspot_y;
device->sprite->geometry.dirty = 1;
weston_surface_damage(device->sprite);
}

@ -245,6 +245,8 @@ struct weston_surface {
int enabled;
struct weston_matrix matrix;
struct weston_matrix inverse;
struct weston_transform position; /* matrix from x, y */
} transform;
/*

Loading…
Cancel
Save