mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-07 13:29:49 -05:00
Merge remote-tracking branch 'upstream/master' into output-damage
This commit is contained in:
commit
6281deb90f
15 changed files with 328 additions and 76 deletions
|
|
@ -1,6 +1,8 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <wayland-server-protocol.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/render/matrix.h>
|
||||
|
||||
/* Obtains the index for the given row/column */
|
||||
|
|
@ -158,3 +160,51 @@ void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
|
|||
mat[10] = 1.0f;
|
||||
mat[15] = 1.0f;
|
||||
}
|
||||
|
||||
void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
|
||||
enum wl_output_transform transform, float rotation,
|
||||
float (*projection)[16]) {
|
||||
int x = box->x;
|
||||
int y = box->y;
|
||||
int width = box->width;
|
||||
int height = box->height;
|
||||
|
||||
wlr_matrix_translate(mat, x, y, 0);
|
||||
|
||||
if (rotation != 0) {
|
||||
float translate_center[16];
|
||||
wlr_matrix_translate(&translate_center, width/2, height/2, 0);
|
||||
|
||||
float rotate[16];
|
||||
wlr_matrix_rotate(&rotate, rotation);
|
||||
|
||||
float translate_origin[16];
|
||||
wlr_matrix_translate(&translate_origin, -width/2, -height/2, 0);
|
||||
|
||||
wlr_matrix_mul(mat, &translate_center, mat);
|
||||
wlr_matrix_mul(mat, &rotate, mat);
|
||||
wlr_matrix_mul(mat, &translate_origin, mat);
|
||||
}
|
||||
|
||||
float scale[16];
|
||||
wlr_matrix_scale(&scale, width, height, 1);
|
||||
|
||||
wlr_matrix_mul(mat, &scale, mat);
|
||||
|
||||
if (transform != WL_OUTPUT_TRANSFORM_NORMAL) {
|
||||
float surface_translate_center[16];
|
||||
wlr_matrix_translate(&surface_translate_center, 0.5, 0.5, 0);
|
||||
|
||||
float surface_transform[16];
|
||||
wlr_matrix_transform(surface_transform, transform);
|
||||
|
||||
float surface_translate_origin[16];
|
||||
wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0);
|
||||
|
||||
wlr_matrix_mul(mat, &surface_translate_center, mat);
|
||||
wlr_matrix_mul(mat, &surface_transform, mat);
|
||||
wlr_matrix_mul(mat, &surface_translate_origin, mat);
|
||||
}
|
||||
|
||||
wlr_matrix_mul(projection, mat, mat);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue