mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1832>
This commit is contained in:
parent
6e00e5e6e7
commit
2ded9c4bf2
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user