From 061b9967680c953020ee198cc3022fddc0f37eed Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 22 Apr 2024 15:53:59 +0100 Subject: [PATCH] render/pixman: fix flipped transforms The translations for flipped offsets were set the same as non-flipped ones which was totally wrong and meant that any textures with flipped-transforms rendered entirely outside the viewport and were basically invisible. --- render/pixman/pass.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/render/pixman/pass.c b/render/pixman/pass.c index 5fe73b05..1709d810 100644 --- a/render/pixman/pass.c +++ b/render/pixman/pass.c @@ -102,6 +102,22 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass, break; } + switch (options->transform) { + case WL_OUTPUT_TRANSFORM_FLIPPED: + case WL_OUTPUT_TRANSFORM_FLIPPED_180: + tr_x = buffer->buffer->width - tr_x; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + tr_x = buffer->buffer->height - tr_x; + break; + case WL_OUTPUT_TRANSFORM_NORMAL: + case WL_OUTPUT_TRANSFORM_90: + case WL_OUTPUT_TRANSFORM_180: + case WL_OUTPUT_TRANSFORM_270: + break; + } + struct pixman_transform transform; pixman_transform_init_identity(&transform); pixman_transform_rotate(&transform, NULL, @@ -110,6 +126,9 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass, pixman_transform_scale(&transform, NULL, pixman_int_to_fixed(-1), pixman_int_to_fixed(1)); } + + // pixman rotates about the origin, translate the result so that its new top-left + // corner is back at the origin. pixman_transform_translate(&transform, NULL, pixman_int_to_fixed(tr_x), pixman_int_to_fixed(tr_y)); pixman_transform_translate(&transform, NULL,