From 061b7471f1cca72c98ebec53d0e89e8166ed30f3 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 12 Jan 2012 15:00:57 +0200 Subject: [PATCH] compositor: drop inverse matrix from weston_transform Remove the inverse matrix member from struct weston_transform. It is easier (and probably faster, too) to create and store only forward transformation matrices in a list, multiply them once, and then invert the final matrix, rather than creating both forward and inverse matrices, and multiplying both. Add a stub for the 4x4 matrix inversion function. Signed-off-by: Pekka Paalanen --- src/compositor.c | 10 ++++------ src/compositor.h | 5 +++-- src/matrix.c | 7 +++++++ src/matrix.h | 4 ++++ src/util.c | 3 --- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 0a7dea3e..69ad60e4 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -505,7 +505,7 @@ transform_vertex(struct weston_surface *surface, t.f[2] = 0.0; t.f[3] = 1.0; - weston_matrix_transform(&surface->transform.cached.matrix, &t); + weston_matrix_transform(&surface->transform.matrix, &t); /* XXX: assumes last row of matrix is [0 0 * 1] */ @@ -544,8 +544,8 @@ texture_transformed_surface(struct weston_surface *es) static void weston_surface_update_transform(struct weston_surface *surface) { - struct weston_matrix *matrix = &surface->transform.cached.matrix; - struct weston_matrix *inverse = &surface->transform.cached.inverse; + struct weston_matrix *matrix = &surface->transform.matrix; + struct weston_matrix *inverse = &surface->transform.inverse; struct weston_transform *tform; if (!surface->transform.dirty) @@ -564,9 +564,7 @@ weston_surface_update_transform(struct weston_surface *surface) wl_list_for_each(tform, &surface->transform.list, link) weston_matrix_multiply(matrix, &tform->matrix); - weston_matrix_init(inverse); - wl_list_for_each_reverse(tform, &surface->transform.list, link) - weston_matrix_multiply(inverse, &tform->inverse); + weston_matrix_invert(inverse, matrix); } WL_EXPORT void diff --git a/src/compositor.h b/src/compositor.h index bec45c46..53126651 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -36,7 +36,6 @@ struct weston_transform { struct weston_matrix matrix; - struct weston_matrix inverse; struct wl_list link; }; @@ -229,7 +228,9 @@ struct weston_surface { struct wl_list list; int dirty; - struct weston_transform cached; + /* derived state, set up by weston_surface_update_transform */ + struct weston_matrix matrix; + struct weston_matrix inverse; int enabled; } transform; diff --git a/src/matrix.c b/src/matrix.c index c71471f1..941e9584 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -100,3 +100,10 @@ weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v) *v = t; } + +WL_EXPORT int +weston_matrix_invert(struct weston_matrix *inverse, + const struct weston_matrix *matrix) +{ + return -1; /* fail */ +} diff --git a/src/matrix.h b/src/matrix.h index f149d876..2c3285a6 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -43,4 +43,8 @@ weston_matrix_translate(struct weston_matrix *matrix, void weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v); +int +weston_matrix_invert(struct weston_matrix *inverse, + const struct weston_matrix *matrix); + #endif /* WESTON_MATRIX_H */ diff --git a/src/util.c b/src/util.c index c8037161..6b8477a4 100644 --- a/src/util.c +++ b/src/util.c @@ -145,9 +145,6 @@ weston_zoom_frame(struct weston_animation *animation, es->alpha = zoom->spring.current * 255; if (es->alpha > 255) es->alpha = 255; - scale = 1.0 / zoom->spring.current; - weston_matrix_init(&zoom->transform.inverse); - weston_matrix_scale(&zoom->transform.inverse, scale, scale, scale); zoom->surface->transform.dirty = 1;