mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-17 06:46:39 -04:00
util/matrix: Simplify matrix_projection
The transform argument is always passed WL_OUTPUT_TRANSFORM_FLIPPED_180
This commit is contained in:
parent
b6fec1b101
commit
51c07a662a
4 changed files with 7 additions and 20 deletions
|
|
@ -31,12 +31,10 @@ void wlr_matrix_transform(float mat[static 9],
|
|||
void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -327,8 +327,7 @@ struct wlr_gles2_render_pass *begin_gles2_buffer_pass(struct wlr_gles2_buffer *b
|
|||
pass->signal_point = signal_point;
|
||||
}
|
||||
|
||||
matrix_projection(pass->projection_matrix, wlr_buffer->width, wlr_buffer->height,
|
||||
WL_OUTPUT_TRANSFORM_FLIPPED_180);
|
||||
matrix_projection(pass->projection_matrix, wlr_buffer->width, wlr_buffer->height);
|
||||
|
||||
push_gles2_debug(renderer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
|
|
|||
|
|
@ -1131,9 +1131,7 @@ struct wlr_vk_render_pass *vulkan_begin_render_pass(struct wlr_vk_renderer *rend
|
|||
.maxDepth = 1,
|
||||
});
|
||||
|
||||
// matrix_projection() assumes a GL coordinate system so we need
|
||||
// to pass WL_OUTPUT_TRANSFORM_FLIPPED_180 to adjust it for vulkan.
|
||||
matrix_projection(pass->projection, width, height, WL_OUTPUT_TRANSFORM_FLIPPED_180);
|
||||
matrix_projection(pass->projection, width, height);
|
||||
|
||||
wlr_buffer_lock(buffer->wlr_buffer);
|
||||
pass->render_buffer = buffer;
|
||||
|
|
|
|||
|
|
@ -97,19 +97,11 @@ void wlr_matrix_transform(float mat[static 9],
|
|||
wlr_matrix_multiply(mat, mat, transforms[transform]);
|
||||
}
|
||||
|
||||
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) {
|
||||
memset(mat, 0, sizeof(*mat) * 9);
|
||||
|
||||
const float *t = transforms[transform];
|
||||
float x = 2.0f / width;
|
||||
float y = 2.0f / height;
|
||||
|
||||
// Rotation + reflection
|
||||
mat[0] = x * t[0];
|
||||
mat[1] = x * t[1];
|
||||
mat[3] = y * -t[3];
|
||||
mat[4] = y * -t[4];
|
||||
mat[0] = 2.0f / width;
|
||||
mat[4] = 2.0f / height;
|
||||
|
||||
// Translation
|
||||
mat[2] = -copysign(1.0f, mat[0] + mat[1]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue