Simply the matrix calculation for zooming
In order to apply the zoom transformation to the output matrix, Weston was doing the following: • Create a temporary matrix to hold the translation • Invert the translation matrix using weston_matrix_invert into another temporary matrix • Scale that matrix by the scale factor • Multiply the current matrix with the temporary matrix Using weston_matrix_invert to invert a translation matrix is over the top. Instead we can just negate the values we pass to weston_matrix_translate. Matrix multiplication is associative so creating a temporary matrix to hold the scale and translation transform should be equivalent to just applying them directly to the output matrix.
This commit is contained in:
committed by
Kristian Høgsberg
parent
a69dc01a6e
commit
1e40a7ec7a
+4
-9
@@ -3188,8 +3188,6 @@ WL_EXPORT void
|
||||
weston_output_update_matrix(struct weston_output *output)
|
||||
{
|
||||
float magnification;
|
||||
struct weston_matrix camera;
|
||||
struct weston_matrix modelview;
|
||||
|
||||
weston_matrix_init(&output->matrix);
|
||||
weston_matrix_translate(&output->matrix,
|
||||
@@ -3204,14 +3202,11 @@ weston_output_update_matrix(struct weston_output *output)
|
||||
|
||||
if (output->zoom.active) {
|
||||
magnification = 1 / (1 - output->zoom.spring_z.current);
|
||||
weston_matrix_init(&camera);
|
||||
weston_matrix_init(&modelview);
|
||||
weston_output_update_zoom(output);
|
||||
weston_matrix_translate(&camera, output->zoom.trans_x,
|
||||
-output->zoom.trans_y, 0);
|
||||
weston_matrix_invert(&modelview, &camera);
|
||||
weston_matrix_scale(&modelview, magnification, magnification, 1.0);
|
||||
weston_matrix_multiply(&output->matrix, &modelview);
|
||||
weston_matrix_translate(&output->matrix, -output->zoom.trans_x,
|
||||
output->zoom.trans_y, 0);
|
||||
weston_matrix_scale(&output->matrix, magnification,
|
||||
magnification, 1.0);
|
||||
}
|
||||
|
||||
output->dirty = 0;
|
||||
|
||||
Reference in New Issue
Block a user