diff --git a/include/util/matrix.h b/include/util/matrix.h index 5c9db1634..7ad326823 100644 --- a/include/util/matrix.h +++ b/include/util/matrix.h @@ -4,6 +4,7 @@ #include struct wlr_box; +struct wlr_fbox; /** Writes the identity matrix into mat */ void wlr_matrix_identity(float mat[static 9]); @@ -30,6 +31,8 @@ void wlr_matrix_transform(float mat[static 9], */ void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box); +void wlr_matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box); + /** * Writes a 2D orthographic projection matrix to mat of (width, height). * diff --git a/render/gles2/pass.c b/render/gles2/pass.c index f8ece60df..0b5c1ab0d 100644 --- a/render/gles2/pass.c +++ b/render/gles2/pass.c @@ -134,9 +134,7 @@ static void set_proj_matrix(GLint loc, float proj[9], const struct wlr_box *box) static void set_tex_matrix(GLint loc, enum wl_output_transform trans, const struct wlr_fbox *box) { float tex_matrix[9]; - wlr_matrix_identity(tex_matrix); - wlr_matrix_translate(tex_matrix, box->x, box->y); - wlr_matrix_scale(tex_matrix, box->width, box->height); + wlr_matrix_project_fbox(tex_matrix, box); // since textures have a different origin point we have to transform // differently if we are rotating diff --git a/util/matrix.c b/util/matrix.c index d111926df..d93eacdd8 100644 --- a/util/matrix.c +++ b/util/matrix.c @@ -111,14 +111,19 @@ void matrix_projection(float mat[static 9], int width, int height) { mat[8] = 1.0f; } -void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box) { - int x = box->x; - int y = box->y; - int width = box->width; - int height = box->height; - +void wlr_matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box) { wlr_matrix_identity(mat); - wlr_matrix_translate(mat, x, y); - - wlr_matrix_scale(mat, width, height); + wlr_matrix_translate(mat, box->x, box->y); + wlr_matrix_scale(mat, box->width, box->height); +} + +void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box) { + struct wlr_fbox fbox = { + .x = box->x, + .y = box->y, + .width = box->width, + .height = box->height, + }; + + wlr_matrix_project_fbox(mat, &fbox); }