util/matrix: Rework matrix_projection to compute transform on-demand

This commit is contained in:
Alexander Orzechowski 2025-01-27 14:30:13 -05:00
parent 99b6084fcd
commit 7775f55e3a
5 changed files with 19 additions and 22 deletions

View file

@ -71,17 +71,16 @@ void wlr_matrix_transform(float mat[static 9],
}
void matrix_projection(float mat[static 9], int width, int height) {
memset(mat, 0, sizeof(*mat) * 9);
struct wlr_fbox fbox = {
.x = -1.0f,
.y = -1.0f,
.width = 2.0f / width,
.height = 2.0f / height,
};
mat[0] = 2.0f / width;
mat[4] = 2.0f / height;
// Translation
mat[2] = -copysign(1.0f, mat[0] + mat[1]);
mat[5] = -copysign(1.0f, mat[3] + mat[4]);
// Identity
mat[8] = 1.0f;
float trans[9];
wlr_matrix_project_fbox(trans, &fbox);
wlr_matrix_multiply(mat, trans, mat);
}
void wlr_matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box) {