From 3ebd870487034e80e33309e580c4e0be0900a6ac Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 1 Jul 2019 17:44:20 +0100 Subject: [PATCH] gl-renderer: Account for offset in output region translation In 55bcb93fefd6 ("gl-renderer: Use helper for conversion to EGL rects"), we extracted and lovingly commented the transformation from global to output co-ordinate space used for EGL_KHR_swap_buffer_with_damage, into a new helper function. The commenting correctly noted the steps we need to perform the transformation: shifting by the output's offset into global space, followed by applying the output's scale and rotation transformations. Unfortunately, the code did not live up to the high standards of the comment, and forgot to translate by the output's offset. This meant that for multiple outputs, we would probably end up with wildly out-of-bounds co-ordinates. Fix the code to first translate by the output's offset in global space, ensuring that both our swap_buffers_with_damage, and our partial_update co-ordinate sets, can spark joy for those blessed with more than one output. Signed-off-by: Daniel Stone --- libweston/renderer-gl/gl-renderer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index e502e7fc8..5fcf023f1 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1401,10 +1401,12 @@ pixman_region_to_egl_y_invert(struct weston_output *output, /* Translate from global to output co-ordinate space. */ pixman_region32_init(&transformed); + pixman_region32_copy(&transformed, global_region); + pixman_region32_translate(&transformed, -output->x, -output->y); weston_transformed_region(output->width, output->height, output->transform, output->current_scale, - global_region, &transformed); + &transformed, &transformed); /* If we have borders drawn around the output, shift our output damage * to account for borders being drawn around the outside, adding any