From 8bba5b6dec5e8d7c82d8b7802ceb682ef5d4480b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 16 Nov 2020 11:51:50 +0100 Subject: [PATCH] Fix 180-degree rotated buffers without Y_INVERT When the compositor sends a buffer without the Y_INVERT flag, the resulting image had it rotated by 180 degrees. References: https://github.com/swaywm/sway/issues/5818 --- render.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/render.c b/render.c index 8f31e7e..38ec8c0 100644 --- a/render.c +++ b/render.c @@ -104,10 +104,11 @@ cairo_surface_t *render(struct grim_state *state, struct grim_box *geometry, cairo_matrix_translate(&matrix, (double)output->geometry.width / 2, (double)output->geometry.height / 2); - cairo_matrix_rotate(&matrix, get_output_rotation(output->transform)); cairo_matrix_scale(&matrix, - (double)raw_output_width / output_width * output_flipped_x, + (double)raw_output_width / output_width, (double)raw_output_height / output_height * output_flipped_y); + cairo_matrix_rotate(&matrix, -get_output_rotation(output->transform)); + cairo_matrix_scale(&matrix, output_flipped_x, 1); cairo_matrix_translate(&matrix, -(double)output_width / 2, -(double)output_height / 2);