Merge branch 'gles2-simplify-matrix' into 'master'

util/matrix: Simplify the interface

See merge request wlroots/wlroots!4975
This commit is contained in:
Alexander Orzechowski 2025-06-17 12:37:57 -04:00
commit 0bdcb22f66
6 changed files with 70 additions and 123 deletions

View file

@ -4,40 +4,31 @@
#include <wayland-server-protocol.h>
struct wlr_box;
/** Writes the identity matrix into mat */
void wlr_matrix_identity(float mat[static 9]);
struct wlr_fbox;
/** mat ← a × b */
void wlr_matrix_multiply(float mat[static 9], const float a[static 9],
void matrix_multiply(float mat[static 9], const float a[static 9],
const float b[static 9]);
/** Writes a 2D translation matrix to mat of magnitude (x, y) */
void wlr_matrix_translate(float mat[static 9], float x, float y);
/** Writes a 2D scale matrix to mat of magnitude (x, y) */
void wlr_matrix_scale(float mat[static 9], float x, float y);
/** Writes a transformation matrix which applies the specified
* wl_output_transform to mat */
void wlr_matrix_transform(float mat[static 9],
enum wl_output_transform transform);
void matrix_transform(float mat[static 9], enum wl_output_transform transform);
/** Shortcut for the various matrix operations involved in projecting the
* specified wlr_box onto a given orthographic projection with a given
* rotation. The result is written to mat, which can be applied to each
* coordinate of the box to get a new coordinate from [-1,1]. */
void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box,
enum wl_output_transform transform, const float projection[static 9]);
* specified wlr_box onto a given orthographic projection. The result is
* written to mat, which can be applied to each coordinate of the box to get a
* new coordinate from [-1,1].
*/
void matrix_project_box(float mat[static 9], const struct wlr_box *box);
void matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box);
/**
* Writes a 2D orthographic projection matrix to mat of (width, height) with a
* specified wl_output_transform.
* Writes a 2D orthographic projection matrix to mat of (width, height).
*
* Equivalent to glOrtho(0, width, 0, height, 1, -1) with the transform applied.
*/
void matrix_projection(float mat[static 9], int width, int height,
enum wl_output_transform transform);
void matrix_projection(float mat[static 9], int width, int height);
/**
* Compute the inverse of a matrix.