From d13114520acef63f9293ff313b8a549bc81be30c Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 21 Jan 2018 15:53:29 -0500 Subject: move matrix model code to matrix.h --- include/wlr/render/matrix.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/wlr/render/matrix.h') diff --git a/include/wlr/render/matrix.h b/include/wlr/render/matrix.h index 0b35aad3..dbd06c8d 100644 --- a/include/wlr/render/matrix.h +++ b/include/wlr/render/matrix.h @@ -2,6 +2,7 @@ #define WLR_RENDER_MATRIX_H #include +#include void wlr_matrix_identity(float (*output)[16]); void wlr_matrix_translate(float (*output)[16], float x, float y, float z); @@ -14,5 +15,7 @@ void wlr_matrix_transform(float mat[static 16], enum wl_output_transform transform); void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height, enum wl_output_transform transform); +void wlr_matrix_box_model(float (*mat)[16], struct wlr_box *box, + enum wl_output_transform transform, float rotation); #endif -- cgit v1.2.3 From 85a6939cf2753fd6a7fa84c9fcd370a4fb1f4095 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 21 Jan 2018 19:03:10 -0500 Subject: rename matrix model box to project box --- include/wlr/render/matrix.h | 5 +++-- render/matrix.c | 7 +++++-- rootston/output.c | 14 ++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'include/wlr/render/matrix.h') diff --git a/include/wlr/render/matrix.h b/include/wlr/render/matrix.h index dbd06c8d..a333bf0f 100644 --- a/include/wlr/render/matrix.h +++ b/include/wlr/render/matrix.h @@ -15,7 +15,8 @@ void wlr_matrix_transform(float mat[static 16], enum wl_output_transform transform); void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height, enum wl_output_transform transform); -void wlr_matrix_box_model(float (*mat)[16], struct wlr_box *box, - enum wl_output_transform transform, float rotation); +void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box, + enum wl_output_transform transform, float rotation, float + (*projection)[16]); #endif diff --git a/render/matrix.c b/render/matrix.c index a64a8f9b..9a1b2bb4 100644 --- a/render/matrix.c +++ b/render/matrix.c @@ -161,8 +161,9 @@ void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height, mat[15] = 1.0f; } -void wlr_matrix_box_model(float (*mat)[16], struct wlr_box *box, - enum wl_output_transform transform, float rotation) { +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; @@ -203,4 +204,6 @@ void wlr_matrix_box_model(float (*mat)[16], struct wlr_box *box, wlr_matrix_mul(mat, &surface_translate_origin, mat); } + + wlr_matrix_mul(projection, mat, mat); } diff --git a/rootston/output.c b/rootston/output.c index 0e568a14..689956ad 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -52,16 +52,15 @@ static void render_surface(struct wlr_surface *surface, .width = render_width, .height = render_height, }; if (wlr_output_layout_intersects(desktop->layout, wlr_output, &render_box)) { - struct wlr_box model_box = { + struct wlr_box project_box = { .x = ox, .y = oy, .width = render_width, .height = render_height, }; float matrix[16]; - wlr_matrix_box_model(&matrix, &model_box, surface->current->transform, - rotation); - wlr_matrix_mul(&wlr_output->transform_matrix, &matrix, &matrix); + wlr_matrix_project_box(&matrix, &project_box, surface->current->transform, + rotation, &wlr_output->transform_matrix); wlr_render_with_matrix(desktop->server->renderer, surface->texture, &matrix); @@ -170,7 +169,7 @@ static void render_decorations(struct roots_view *view, ox *= output->scale; oy *= output->scale; - struct wlr_box model_box = { + struct wlr_box project_box = { .x = ox, .y = oy, .width = deco_box.width, @@ -178,9 +177,8 @@ static void render_decorations(struct roots_view *view, }; float matrix[16]; - wlr_matrix_box_model(&matrix, &model_box, WL_OUTPUT_TRANSFORM_NORMAL, - view->rotation); - wlr_matrix_mul(&output->transform_matrix, &matrix, &matrix); + wlr_matrix_project_box(&matrix, &project_box, WL_OUTPUT_TRANSFORM_NORMAL, + view->rotation, &output->transform_matrix); float color[4] = { 0.2, 0.2, 0.2, 1 }; wlr_render_colored_quad(desktop->server->renderer, &color, &matrix); } -- cgit v1.2.3