aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/gles2/renderer.c2
-rw-r--r--render/matrix.c49
2 files changed, 50 insertions, 1 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 89cc4ffb..30247af0 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -177,7 +177,7 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *_renderer,
static void wlr_gles2_render_quad(struct wlr_renderer *renderer,
const float (*color)[4], const float (*matrix)[16]) {
GL_CALL(glUseProgram(shaders.quad));
- GL_CALL(glUniformMatrix4fv(0, 1, GL_TRUE, *matrix));
+ GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
GL_CALL(glUniform4f(1, (*color)[0], (*color)[1], (*color)[2], (*color)[3]));
draw_quad();
}
diff --git a/render/matrix.c b/render/matrix.c
index 54dba4cc..9a1b2bb4 100644
--- a/render/matrix.c
+++ b/render/matrix.c
@@ -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,50 @@ 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;
+
+ float translate_center[16];
+ wlr_matrix_translate(&translate_center,
+ (int)x + width / 2, (int)y + 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);
+
+ float scale[16];
+ wlr_matrix_scale(&scale, width, height, 1);
+
+ wlr_matrix_mul(&translate_center, &rotate, mat);
+ wlr_matrix_mul(mat, &translate_origin, mat);
+ 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,
+ wlr_output_transform_invert(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);
+}