From 2ded9c4bf2d5bea9538beb8c133f67038614c5fd Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 19 Apr 2021 14:46:08 +0200 Subject: [PATCH] shaped-texture: Apply viewport and rotation in right order When using buffer transforms and viewports together, we currently apply the transformation (read: rotation) first, resulting in wrong buffer coordinates for viewport source rects. Flip the order in whitch we apply our matrix transformations. This can be tested e.g. via: `weston-simple-damage --use-viewport --transform=flipped-180` Part-of: --- src/compositor/meta-shaped-texture.c | 68 ++++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 8614f1fd4..6f6d85345 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -290,6 +290,40 @@ get_base_pipeline (MetaShapedTexture *stex, graphene_matrix_init_identity (&matrix); + if (stex->has_viewport_src_rect) + { + float scaled_tex_width = stex->tex_width / (float) stex->buffer_scale; + float scaled_tex_height = stex->tex_height / (float) stex->buffer_scale; + graphene_point3d_t p; + + graphene_point3d_init (&p, + stex->viewport_src_rect.origin.x / + stex->viewport_src_rect.size.width, + stex->viewport_src_rect.origin.y / + stex->viewport_src_rect.size.height, + 0); + graphene_matrix_translate (&matrix, &p); + + if (meta_monitor_transform_is_rotated (stex->transform)) + { + graphene_matrix_scale (&matrix, + stex->viewport_src_rect.size.width / + scaled_tex_height, + stex->viewport_src_rect.size.height / + scaled_tex_width, + 1); + } + else + { + graphene_matrix_scale (&matrix, + stex->viewport_src_rect.size.width / + scaled_tex_width, + stex->viewport_src_rect.size.height / + scaled_tex_height, + 1); + } + } + if (stex->transform != META_MONITOR_TRANSFORM_NORMAL) { graphene_euler_t euler; @@ -334,40 +368,6 @@ get_base_pipeline (MetaShapedTexture *stex, &GRAPHENE_POINT3D_INIT (0.5, 0.5, 0.0)); } - if (stex->has_viewport_src_rect) - { - float scaled_tex_width = stex->tex_width / (float) stex->buffer_scale; - float scaled_tex_height = stex->tex_height / (float) stex->buffer_scale; - graphene_point3d_t p; - - graphene_point3d_init (&p, - stex->viewport_src_rect.origin.x / - stex->viewport_src_rect.size.width, - stex->viewport_src_rect.origin.y / - stex->viewport_src_rect.size.height, - 0); - graphene_matrix_translate (&matrix, &p); - - if (meta_monitor_transform_is_rotated (stex->transform)) - { - graphene_matrix_scale (&matrix, - stex->viewport_src_rect.size.width / - scaled_tex_height, - stex->viewport_src_rect.size.height / - scaled_tex_width, - 1); - } - else - { - graphene_matrix_scale (&matrix, - stex->viewport_src_rect.size.width / - scaled_tex_width, - stex->viewport_src_rect.size.height / - scaled_tex_height, - 1); - } - } - if (!stex->is_y_inverted) { graphene_matrix_translate (&matrix, &GRAPHENE_POINT3D_INIT (0, -1, 0));