From f4754ad1a21eaede20f6e9c5d4e0c78294119cc1 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 30 Nov 2017 23:58:12 +0100 Subject: Fix surface transforms --- rootston/output.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'rootston') diff --git a/rootston/output.c b/rootston/output.c index bf684f2f..c1d2e9f3 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -63,10 +63,25 @@ static void render_surface(struct wlr_surface *surface, float scale[16]; wlr_matrix_scale(&scale, render_width, render_height, 1); + float translate_mdr[16]; + wlr_matrix_translate(&translate_mdr, 0.5, 0.5, 0); + + float surface_transform[16]; + wlr_matrix_transform(surface_transform, + wlr_output_transform_invert(surface->current->transform)); // TODO + + float translate_mdr2[16]; + wlr_matrix_translate(&translate_mdr2, -0.5, -0.5, 0); + float transform[16]; wlr_matrix_mul(&translate_origin, &rotate, &transform); wlr_matrix_mul(&transform, &translate_center, &transform); wlr_matrix_mul(&transform, &scale, &transform); + + wlr_matrix_mul(&transform, &translate_mdr, &transform); + wlr_matrix_mul(&transform, &surface_transform, &transform); + wlr_matrix_mul(&transform, &translate_mdr2, &transform); + wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix); wlr_render_with_matrix(desktop->server->renderer, surface->texture, -- cgit v1.2.3 From acc8f368945d540796078f0530234734e5cb1b37 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 1 Dec 2017 16:08:01 +0100 Subject: Fix pointer input for transformed surfaces --- rootston/desktop.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'rootston') diff --git a/rootston/desktop.c b/rootston/desktop.c index bb3af258..8cede819 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -295,10 +295,8 @@ static bool view_at(struct roots_view *view, double lx, double ly, struct wlr_surface_state *state = view->wlr_surface->current; struct wlr_box box = { - .x = 0, - .y = 0, - .width = state->buffer_width / state->scale, - .height = state->buffer_height / state->scale, + .x = 0, .y = 0, + .width = state->width, .height = state->height, }; if (view->rotation != 0.0) { // Coordinates relative to the center of the view -- cgit v1.2.3 From d1b29a54b92c5d13739430fe98b12ff169964272 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 1 Dec 2017 16:13:24 +0100 Subject: Refactor: rename matrices in rootston --- rootston/output.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'rootston') diff --git a/rootston/output.c b/rootston/output.c index c1d2e9f3..9df95a91 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -49,38 +49,38 @@ static void render_surface(struct wlr_surface *surface, lx, ly, lx + render_width, ly + render_height)) { float matrix[16]; - float translate_origin[16]; - wlr_matrix_translate(&translate_origin, + float translate_center[16]; + wlr_matrix_translate(&translate_center, (int)ox + render_width / 2, (int)oy + render_height / 2, 0); float rotate[16]; wlr_matrix_rotate(&rotate, rotation); - float translate_center[16]; - wlr_matrix_translate(&translate_center, -render_width / 2, + float translate_origin[16]; + wlr_matrix_translate(&translate_origin, -render_width / 2, -render_height / 2, 0); float scale[16]; wlr_matrix_scale(&scale, render_width, render_height, 1); - float translate_mdr[16]; - wlr_matrix_translate(&translate_mdr, 0.5, 0.5, 0); + 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(surface->current->transform)); // TODO + wlr_output_transform_invert(surface->current->transform)); - float translate_mdr2[16]; - wlr_matrix_translate(&translate_mdr2, -0.5, -0.5, 0); + float surface_translate_origin[16]; + wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0); float transform[16]; - wlr_matrix_mul(&translate_origin, &rotate, &transform); - wlr_matrix_mul(&transform, &translate_center, &transform); + wlr_matrix_mul(&translate_center, &rotate, &transform); + wlr_matrix_mul(&transform, &translate_origin, &transform); wlr_matrix_mul(&transform, &scale, &transform); - wlr_matrix_mul(&transform, &translate_mdr, &transform); + wlr_matrix_mul(&transform, &surface_translate_center, &transform); wlr_matrix_mul(&transform, &surface_transform, &transform); - wlr_matrix_mul(&transform, &translate_mdr2, &transform); + wlr_matrix_mul(&transform, &surface_translate_origin, &transform); wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix); -- cgit v1.2.3 From eb763439f75d3c9174280d0c75ef44941dd99340 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 1 Dec 2017 16:20:09 +0100 Subject: optimize a bit rootston renderer if there's no surface transform --- rootston/output.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'rootston') diff --git a/rootston/output.c b/rootston/output.c index 9df95a91..996f819d 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -63,24 +63,28 @@ static void render_surface(struct wlr_surface *surface, float scale[16]; wlr_matrix_scale(&scale, render_width, render_height, 1); - 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(surface->current->transform)); - - float surface_translate_origin[16]; - wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0); - float transform[16]; wlr_matrix_mul(&translate_center, &rotate, &transform); wlr_matrix_mul(&transform, &translate_origin, &transform); wlr_matrix_mul(&transform, &scale, &transform); - wlr_matrix_mul(&transform, &surface_translate_center, &transform); - wlr_matrix_mul(&transform, &surface_transform, &transform); - wlr_matrix_mul(&transform, &surface_translate_origin, &transform); + if (surface->current->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(surface->current->transform)); + + float surface_translate_origin[16]; + wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0); + + wlr_matrix_mul(&transform, &surface_translate_center, + &transform); + wlr_matrix_mul(&transform, &surface_transform, &transform); + wlr_matrix_mul(&transform, &surface_translate_origin, + &transform); + } wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix); -- cgit v1.2.3