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>
dev
Pekka Paalanen 13 years ago
parent 668ca37b19
commit 061b7471f1
  1. 10
      src/compositor.c
  2. 5
      src/compositor.h
  3. 7
      src/matrix.c
  4. 4
      src/matrix.h
  5. 3
      src/util.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

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

@ -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 */
}

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

Loading…
Cancel
Save