mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-14 08:22:25 -04:00
util/matrix: Drop wlr_ prefix
This commit is contained in:
parent
7775f55e3a
commit
97b01d9b9b
4 changed files with 19 additions and 20 deletions
|
|
@ -7,22 +7,21 @@ struct wlr_box;
|
|||
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 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. 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);
|
||||
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).
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
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);
|
||||
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,
|
||||
const struct wlr_fbox *box) {
|
||||
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
|
||||
// differently if we are rotating
|
||||
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 {
|
||||
wlr_matrix_transform(tex_matrix, trans);
|
||||
matrix_transform(tex_matrix, trans);
|
||||
}
|
||||
|
||||
glUniformMatrix3fv(loc, 1, GL_FALSE, tex_matrix);
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ static void render_pass_add_rect(struct wlr_render_pass *wlr_pass,
|
|||
switch (options->blend_mode) {
|
||||
case WLR_RENDER_BLEND_MODE_PREMULTIPLIED:;
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, &box);
|
||||
matrix_project_box(matrix, &box);
|
||||
matrix_projection(matrix,
|
||||
pass->render_buffer->wlr_buffer->width,
|
||||
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 matrix[9];
|
||||
wlr_matrix_project_box(matrix, &dst_box);
|
||||
wlr_matrix_transform(matrix, options->transform);
|
||||
matrix_project_box(matrix, &dst_box);
|
||||
matrix_transform(matrix, options->transform);
|
||||
matrix_projection(matrix,
|
||||
pass->render_buffer->wlr_buffer->width,
|
||||
pass->render_buffer->wlr_buffer->height);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <wlr/util/box.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]) {
|
||||
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) {
|
||||
wlr_matrix_multiply(mat, mat, transforms[transform]);
|
||||
matrix_multiply(mat, mat, transforms[transform]);
|
||||
}
|
||||
|
||||
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];
|
||||
wlr_matrix_project_fbox(trans, &fbox);
|
||||
wlr_matrix_multiply(mat, trans, mat);
|
||||
matrix_project_fbox(trans, &fbox);
|
||||
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[1] = 0.0f;
|
||||
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;
|
||||
}
|
||||
|
||||
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 = {
|
||||
.x = box->x,
|
||||
.y = box->y,
|
||||
|
|
@ -105,5 +105,5 @@ void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box) {
|
|||
.height = box->height,
|
||||
};
|
||||
|
||||
wlr_matrix_project_fbox(mat, &fbox);
|
||||
matrix_project_fbox(mat, &fbox);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue