summaryrefslogtreecommitdiff
path: root/src/compositor/meta-shaped-texture.c
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2020-03-13 19:31:23 +0100
committerJonas Ådahl <jadahl@gmail.com>2020-03-26 08:32:46 +0000
commit8beef8ccd02388c213a57045504794cac0c6e52d (patch)
treea55be95654e1157a62427de7dd0544dfe4ce9dc0 /src/compositor/meta-shaped-texture.c
parent62d0dd907bb81955e6bec88ce3696fc3893f5f0b (diff)
downloadmutter-8beef8ccd02388c213a57045504794cac0c6e52d.tar.gz
shaped-texture: Fix use-nearest check when viewports are scaled
We checked that the content size was appropriately painted in the stage, but didn't take into account that the size of the sampled texture region, meaning that when stage views were scaled, we'd think that we would draw a texture scaled, as e.g. a 200x200 sized texture with buffer scale 2 would have the size 100x100. When stage views were not scaled, we'd apply a geometry scale meaning it'd end up as 200x200 anyway, thus pass the check, but when stage views are scaled, it'd still be painted as a 100x100 shaped texture on the stage, thus failing the are-we-unscaled test. Fix this by comparing the transformed paint size with the sampled size, instead of the paint size again, when checking whether we are being painted scaled or not. For example, when stage views are scaled, our 200x200 buffer with buffer scale 2, thus content size 100x100 will transform to a 200x200 paint command, thus passing the test. For non-scaled stage views, our 200x200 buffer with buffer scale 2 thus content size 100x100 will also transform into a 200x200 paint command, and will also pass the check, as the texture sample region is still 200x200. Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/804 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1124
Diffstat (limited to 'src/compositor/meta-shaped-texture.c')
-rw-r--r--src/compositor/meta-shaped-texture.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 6f30325cd..79bb61c8f 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -507,6 +507,17 @@ texture_is_idle_and_not_mipmapped (gpointer user_data)
return G_SOURCE_REMOVE;
}
+static inline void
+flip_ints (int *x,
+ int *y)
+{
+ int tmp;
+
+ tmp = *x;
+ *x = *y;
+ *y = tmp;
+}
+
static void
do_paint_content (MetaShapedTexture *stex,
ClutterPaintNode *root_node,
@@ -522,6 +533,7 @@ do_paint_content (MetaShapedTexture *stex,
CoglContext *ctx;
CoglPipelineFilter filter;
CoglFramebuffer *framebuffer;
+ int sample_width, sample_height;
ensure_size_valid (stex);
@@ -542,15 +554,30 @@ do_paint_content (MetaShapedTexture *stex,
* improves performance, especially with software rendering.
*/
- filter = COGL_PIPELINE_FILTER_LINEAR;
-
framebuffer = clutter_paint_node_get_framebuffer (root_node);
if (!framebuffer)
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
+
+ if (stex->has_viewport_src_rect)
+ {
+ sample_width = stex->viewport_src_rect.size.width * stex->buffer_scale;
+ sample_height = stex->viewport_src_rect.size.height * stex->buffer_scale;
+ }
+ else
+ {
+ sample_width = cogl_texture_get_width (stex->texture);
+ sample_height = cogl_texture_get_height (stex->texture);
+ }
+ if (meta_monitor_transform_is_rotated (stex->transform))
+ flip_ints (&sample_width, &sample_height);
+
if (meta_actor_painting_untransformed (framebuffer,
dst_width, dst_height,
+ sample_width, sample_height,
NULL, NULL))
filter = COGL_PIPELINE_FILTER_NEAREST;
+ else
+ filter = COGL_PIPELINE_FILTER_LINEAR;
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());