aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-12-14 14:43:04 -0500
committerGitHub <noreply@github.com>2017-12-14 14:43:04 -0500
commit23fb663ea4eaff436d9bfab7f74cdd298fac44c5 (patch)
treef84e20d4af2a4111b0026679e853f6f55f9ddb4f /rootston
parent46ac8e1243d3d32c656b09e641f8e9732035f635 (diff)
parent466e86b7b2cbefa55ad5b85a97ee8257c24cb81b (diff)
Merge pull request #453 from emersion/surface-transform
Add surface transforms support
Diffstat (limited to 'rootston')
-rw-r--r--rootston/desktop.c6
-rw-r--r--rootston/output.c31
2 files changed, 27 insertions, 10 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c
index ef459e69..c9fc0dc6 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -294,10 +294,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
diff --git a/rootston/output.c b/rootston/output.c
index 560e5eeb..e510be71 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -48,24 +48,43 @@ 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 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);
+
+ 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);
wlr_render_with_matrix(desktop->server->renderer, surface->texture,