diff options
author | Pekka Paalanen <ppaalanen@gmail.com> | 2012-01-12 15:00:57 +0200 |
---|---|---|
committer | Pekka Paalanen <ppaalanen@gmail.com> | 2012-01-27 10:44:22 +0200 |
commit | 061b7471f1cca72c98ebec53d0e89e8166ed30f3 (patch) | |
tree | 6e0caa27e3e00316e59b98b1bd1e5bdd0ac7f7b7 | |
parent | 668ca37b19926e57b414497f3881f3939e804c0d (diff) |
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 <ppaalanen@gmail.com>
-rw-r--r-- | src/compositor.c | 10 | ||||
-rw-r--r-- | src/compositor.h | 5 | ||||
-rw-r--r-- | src/matrix.c | 7 | ||||
-rw-r--r-- | src/matrix.h | 4 | ||||
-rw-r--r-- | src/util.c | 3 |
5 files changed, 18 insertions, 11 deletions
diff --git a/src/compositor.c b/src/compositor.c index 0a7dea3..69ad60e 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 bec45c4..5312665 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 c71471f..941e958 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 f149d87..2c3285a 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 */ @@ -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; |