util/matrix: Drop wlr_ prefix

This commit is contained in:
Alexander Orzechowski 2025-01-27 14:26:40 -05:00
parent 7775f55e3a
commit 97b01d9b9b
4 changed files with 19 additions and 20 deletions

View file

@ -7,22 +7,21 @@ struct wlr_box;
struct wlr_fbox; struct wlr_fbox;
/** mat ← a × b */ /** 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]); const float b[static 9]);
/** Writes a transformation matrix which applies the specified /** Writes a transformation matrix which applies the specified
* wl_output_transform to mat */ * wl_output_transform to mat */
void wlr_matrix_transform(float mat[static 9], void matrix_transform(float mat[static 9], enum wl_output_transform transform);
enum wl_output_transform transform);
/** Shortcut for the various matrix operations involved in projecting the /** Shortcut for the various matrix operations involved in projecting the
* specified wlr_box onto a given orthographic projection. The result is * 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 * written to mat, which can be applied to each coordinate of the box to get a
* new coordinate from [-1,1]. * new coordinate from [-1,1].
*/ */
void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box); void 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); void matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box);
/** /**
* Writes a 2D orthographic projection matrix to mat of (width, height). * Writes a 2D orthographic projection matrix to mat of (width, height).

View file

@ -126,7 +126,7 @@ static void render(const struct wlr_box *box, const pixman_region32_t *clip, GLi
static void set_proj_matrix(GLint loc, struct wlr_gles2_buffer *buffer, const struct wlr_box *box) { static void set_proj_matrix(GLint loc, struct wlr_gles2_buffer *buffer, const struct wlr_box *box) {
float gl_matrix[9]; float gl_matrix[9];
wlr_matrix_project_box(gl_matrix, box); matrix_project_box(gl_matrix, box);
matrix_projection(gl_matrix, buffer->buffer->width, buffer->buffer->height); matrix_projection(gl_matrix, buffer->buffer->width, buffer->buffer->height);
glUniformMatrix3fv(loc, 1, GL_FALSE, gl_matrix); glUniformMatrix3fv(loc, 1, GL_FALSE, gl_matrix);
} }
@ -134,14 +134,14 @@ static void set_proj_matrix(GLint loc, struct wlr_gles2_buffer *buffer, const st
static void set_tex_matrix(GLint loc, enum wl_output_transform trans, static void set_tex_matrix(GLint loc, enum wl_output_transform trans,
const struct wlr_fbox *box) { const struct wlr_fbox *box) {
float tex_matrix[9]; float tex_matrix[9];
wlr_matrix_project_fbox(tex_matrix, box); matrix_project_fbox(tex_matrix, box);
// since textures have a different origin point we have to transform // since textures have a different origin point we have to transform
// differently if we are rotating // differently if we are rotating
if (trans & WL_OUTPUT_TRANSFORM_90) { if (trans & WL_OUTPUT_TRANSFORM_90) {
wlr_matrix_transform(tex_matrix, wlr_output_transform_invert(trans)); matrix_transform(tex_matrix, wlr_output_transform_invert(trans));
} else { } else {
wlr_matrix_transform(tex_matrix, trans); matrix_transform(tex_matrix, trans);
} }
glUniformMatrix3fv(loc, 1, GL_FALSE, tex_matrix); glUniformMatrix3fv(loc, 1, GL_FALSE, tex_matrix);

View file

@ -619,7 +619,7 @@ static void render_pass_add_rect(struct wlr_render_pass *wlr_pass,
switch (options->blend_mode) { switch (options->blend_mode) {
case WLR_RENDER_BLEND_MODE_PREMULTIPLIED:; case WLR_RENDER_BLEND_MODE_PREMULTIPLIED:;
float matrix[9]; float matrix[9];
wlr_matrix_project_box(matrix, &box); matrix_project_box(matrix, &box);
matrix_projection(matrix, matrix_projection(matrix,
pass->render_buffer->wlr_buffer->width, pass->render_buffer->wlr_buffer->width,
pass->render_buffer->wlr_buffer->height); pass->render_buffer->wlr_buffer->height);
@ -711,8 +711,8 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
float alpha = wlr_render_texture_options_get_alpha(options); float alpha = wlr_render_texture_options_get_alpha(options);
float matrix[9]; float matrix[9];
wlr_matrix_project_box(matrix, &dst_box); matrix_project_box(matrix, &dst_box);
wlr_matrix_transform(matrix, options->transform); matrix_transform(matrix, options->transform);
matrix_projection(matrix, matrix_projection(matrix,
pass->render_buffer->wlr_buffer->width, pass->render_buffer->wlr_buffer->width,
pass->render_buffer->wlr_buffer->height); pass->render_buffer->wlr_buffer->height);

View file

@ -3,7 +3,7 @@
#include <wlr/util/box.h> #include <wlr/util/box.h>
#include "util/matrix.h" #include "util/matrix.h"
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]) { const float b[static 9]) {
float product[9]; float product[9];
@ -65,9 +65,9 @@ static const float transforms[][9] = {
}, },
}; };
void wlr_matrix_transform(float mat[static 9], void matrix_transform(float mat[static 9],
enum wl_output_transform transform) { enum wl_output_transform transform) {
wlr_matrix_multiply(mat, mat, transforms[transform]); matrix_multiply(mat, mat, transforms[transform]);
} }
void matrix_projection(float mat[static 9], int width, int height) { void matrix_projection(float mat[static 9], int width, int height) {
@ -79,11 +79,11 @@ void matrix_projection(float mat[static 9], int width, int height) {
}; };
float trans[9]; float trans[9];
wlr_matrix_project_fbox(trans, &fbox); matrix_project_fbox(trans, &fbox);
wlr_matrix_multiply(mat, trans, mat); matrix_multiply(mat, trans, mat);
} }
void wlr_matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box) { void matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box) {
mat[0] = box->width; mat[0] = box->width;
mat[1] = 0.0f; mat[1] = 0.0f;
mat[2] = box->x; mat[2] = box->x;
@ -97,7 +97,7 @@ void wlr_matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box) {
mat[8] = 1.0f; mat[8] = 1.0f;
} }
void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box) { void matrix_project_box(float mat[static 9], const struct wlr_box *box) {
struct wlr_fbox fbox = { struct wlr_fbox fbox = {
.x = box->x, .x = box->x,
.y = box->y, .y = box->y,
@ -105,5 +105,5 @@ void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box) {
.height = box->height, .height = box->height,
}; };
wlr_matrix_project_fbox(mat, &fbox); matrix_project_fbox(mat, &fbox);
} }