Blame SOURCES/eglstream-overview-fixes.patch

51907a
From 529eb8fa3a15e0ae5bf131b1855a117c8a1a026e Mon Sep 17 00:00:00 2001
51907a
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
51907a
Date: Tue, 8 Feb 2022 17:14:06 +0100
51907a
Subject: [PATCH 1/2] shaped-texture: Pass along the snippet to the texture
51907a
 tower
51907a
51907a
The snippet is used make sure the right source is sampled in the shader.
51907a
This wasn't done in the texture tower, meaning the textures from the
51907a
tower were not correct.
51907a
51907a
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
51907a
---
51907a
 src/compositor/meta-shaped-texture.c |  2 ++
51907a
 src/compositor/meta-texture-tower.c  | 27 +++++++++++++++++++++++++++
51907a
 src/compositor/meta-texture-tower.h  |  3 +++
51907a
 3 files changed, 32 insertions(+)
51907a
51907a
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
51907a
index 9cae4df07d74..32af6bdc19d7 100644
51907a
--- a/src/compositor/meta-shaped-texture.c
51907a
+++ b/src/compositor/meta-shaped-texture.c
51907a
@@ -1204,6 +1204,8 @@ meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
51907a
   g_clear_pointer (&stex->snippet, cogl_object_unref);
51907a
   if (snippet)
51907a
     stex->snippet = cogl_object_ref (snippet);
51907a
+
51907a
+  meta_texture_tower_set_snippet (stex->paint_tower, snippet);
51907a
 }
51907a
 
51907a
 /**
51907a
diff --git a/src/compositor/meta-texture-tower.c b/src/compositor/meta-texture-tower.c
51907a
index a41cdc89dd94..374e1af151ad 100644
51907a
--- a/src/compositor/meta-texture-tower.c
51907a
+++ b/src/compositor/meta-texture-tower.c
51907a
@@ -63,6 +63,7 @@ struct _MetaTextureTower
51907a
   CoglOffscreen *fbos[MAX_TEXTURE_LEVELS];
51907a
   Box invalid[MAX_TEXTURE_LEVELS];
51907a
   CoglPipeline *pipeline_template;
51907a
+  CoglSnippet *snippet;
51907a
 };
51907a
 
51907a
 /**
51907a
@@ -98,6 +99,7 @@ meta_texture_tower_free (MetaTextureTower *tower)
51907a
     cogl_object_unref (tower->pipeline_template);
51907a
 
51907a
   meta_texture_tower_set_base_texture (tower, NULL);
51907a
+  cogl_clear_object (&tower->snippet);
51907a
 
51907a
   g_slice_free (MetaTextureTower, tower);
51907a
 }
51907a
@@ -226,6 +228,28 @@ meta_texture_tower_update_area (MetaTextureTower *tower,
51907a
     }
51907a
 }
51907a
 
51907a
+void
51907a
+meta_texture_tower_set_snippet (MetaTextureTower *tower,
51907a
+                                CoglSnippet      *snippet)
51907a
+{
51907a
+  int i;
51907a
+
51907a
+  if (tower->snippet == snippet)
51907a
+    return;
51907a
+
51907a
+  g_clear_pointer (&tower->snippet, cogl_object_unref);
51907a
+
51907a
+  if (snippet)
51907a
+    tower->snippet = cogl_object_ref (snippet);
51907a
+
51907a
+  for (i = 1; i < tower->n_levels; i++)
51907a
+    {
51907a
+      cogl_clear_object (&tower->textures[i]);
51907a
+      g_clear_object (&tower->fbos[i]);
51907a
+    }
51907a
+  cogl_clear_object (&tower->pipeline_template);
51907a
+}
51907a
+
51907a
 /* It generally looks worse if we scale up a window texture by even a
51907a
  * small amount than if we scale it down using bilinear filtering, so
51907a
  * we always pick the *larger* adjacent level. */
51907a
@@ -420,6 +444,9 @@ texture_tower_revalidate (MetaTextureTower *tower,
51907a
   pipeline = cogl_pipeline_copy (tower->pipeline_template);
51907a
   cogl_pipeline_set_layer_texture (pipeline, 0, tower->textures[level - 1]);
51907a
 
51907a
+  if (tower->snippet && level == 1)
51907a
+    cogl_pipeline_add_layer_snippet (pipeline, 0, tower->snippet);
51907a
+
51907a
   cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
51907a
                                             invalid->x1, invalid->y1,
51907a
                                             invalid->x2, invalid->y2,
51907a
diff --git a/src/compositor/meta-texture-tower.h b/src/compositor/meta-texture-tower.h
51907a
index 6a39e4184200..e3cfe3608b8f 100644
51907a
--- a/src/compositor/meta-texture-tower.h
51907a
+++ b/src/compositor/meta-texture-tower.h
51907a
@@ -62,6 +62,9 @@ void              meta_texture_tower_update_area       (MetaTextureTower *tower,
51907a
                                                         int               height);
51907a
 CoglTexture      *meta_texture_tower_get_paint_texture (MetaTextureTower *tower);
51907a
 
51907a
+void meta_texture_tower_set_snippet (MetaTextureTower *tower,
51907a
+                                     CoglSnippet      *snippet);
51907a
+
51907a
 G_END_DECLS
51907a
 
51907a
 #endif /* __META_TEXTURE_TOWER_H__ */
51907a
-- 
51907a
2.34.1
51907a
51907a
51907a
From 4827e201b341ac4dd0b4ca697df46946b19ae14c Mon Sep 17 00:00:00 2001
51907a
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
51907a
Date: Mon, 21 Feb 2022 18:12:25 +0100
51907a
Subject: [PATCH 2/2] shaped-texture: Paint with the right layer snippet
51907a
51907a
When we get passed a "snippet" to the shaped texture, it's added as a
51907a
pipeline layer snippet to change how the source texture is sampled. When
51907a
we draw from a texture tower however we have allocated regular textures
51907a
which doesn't need any special layer snippet, so create separate
51907a
pipelines for those that doesn't use that snippet.
51907a
51907a
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
51907a
---
51907a
 src/compositor/meta-shaped-texture.c | 135 +++++++++++++++++++++------
51907a
 1 file changed, 104 insertions(+), 31 deletions(-)
51907a
51907a
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
51907a
index 32af6bdc19d7..705d27d5b842 100644
51907a
--- a/src/compositor/meta-shaped-texture.c
51907a
+++ b/src/compositor/meta-shaped-texture.c
51907a
@@ -96,8 +96,12 @@ struct _MetaShapedTexture
51907a
   CoglSnippet *snippet;
51907a
 
51907a
   CoglPipeline *base_pipeline;
51907a
+  CoglPipeline *unmasked_pipeline;
51907a
+  CoglPipeline *unmasked_tower_pipeline;
51907a
   CoglPipeline *masked_pipeline;
51907a
+  CoglPipeline *masked_tower_pipeline;
51907a
   CoglPipeline *unblended_pipeline;
51907a
+  CoglPipeline *unblended_tower_pipeline;
51907a
 
51907a
   gboolean is_y_inverted;
51907a
 
51907a
@@ -281,8 +285,12 @@ static void
51907a
 meta_shaped_texture_reset_pipelines (MetaShapedTexture *stex)
51907a
 {
51907a
   g_clear_pointer (&stex->base_pipeline, cogl_object_unref);
51907a
+  g_clear_pointer (&stex->unmasked_pipeline, cogl_object_unref);
51907a
+  g_clear_pointer (&stex->unmasked_tower_pipeline, cogl_object_unref);
51907a
   g_clear_pointer (&stex->masked_pipeline, cogl_object_unref);
51907a
+  g_clear_pointer (&stex->masked_tower_pipeline, cogl_object_unref);
51907a
   g_clear_pointer (&stex->unblended_pipeline, cogl_object_unref);
51907a
+  g_clear_pointer (&stex->unblended_tower_pipeline, cogl_object_unref);
51907a
 }
51907a
 
51907a
 static void
51907a
@@ -385,9 +393,6 @@ get_base_pipeline (MetaShapedTexture *stex,
51907a
       cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix);
51907a
     }
51907a
 
51907a
-  if (stex->snippet)
51907a
-    cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
51907a
-
51907a
   stex->base_pipeline = pipeline;
51907a
 
51907a
   return stex->base_pipeline;
51907a
@@ -395,50 +400,118 @@ get_base_pipeline (MetaShapedTexture *stex,
51907a
 
51907a
 static CoglPipeline *
51907a
 get_unmasked_pipeline (MetaShapedTexture *stex,
51907a
-                       CoglContext       *ctx)
51907a
+                       CoglContext       *ctx,
51907a
+                       CoglTexture       *tex)
51907a
 {
51907a
-  return get_base_pipeline (stex, ctx);
51907a
+  if (stex->texture == tex)
51907a
+    {
51907a
+      CoglPipeline *pipeline;
51907a
+
51907a
+      if (stex->unmasked_pipeline)
51907a
+        return stex->unmasked_pipeline;
51907a
+
51907a
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
+      if (stex->snippet)
51907a
+        cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
51907a
+
51907a
+      stex->unmasked_pipeline = pipeline;
51907a
+      return pipeline;
51907a
+    }
51907a
+  else
51907a
+    {
51907a
+      CoglPipeline *pipeline;
51907a
+
51907a
+      if (stex->unmasked_tower_pipeline)
51907a
+        return stex->unmasked_tower_pipeline;
51907a
+
51907a
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
+      stex->unmasked_tower_pipeline = pipeline;
51907a
+      return pipeline;
51907a
+    }
51907a
 }
51907a
 
51907a
 static CoglPipeline *
51907a
 get_masked_pipeline (MetaShapedTexture *stex,
51907a
-                     CoglContext       *ctx)
51907a
+                     CoglContext       *ctx,
51907a
+                     CoglTexture       *tex)
51907a
 {
51907a
-  CoglPipeline *pipeline;
51907a
+  if (stex->texture == tex)
51907a
+    {
51907a
+      CoglPipeline *pipeline;
51907a
 
51907a
-  if (stex->masked_pipeline)
51907a
-    return stex->masked_pipeline;
51907a
+      if (stex->masked_pipeline)
51907a
+        return stex->masked_pipeline;
51907a
 
51907a
-  pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
-  cogl_pipeline_set_layer_combine (pipeline, 1,
51907a
-                                   "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
51907a
-                                   NULL);
51907a
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
+      cogl_pipeline_set_layer_combine (pipeline, 1,
51907a
+                                       "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
51907a
+                                       NULL);
51907a
+      if (stex->snippet)
51907a
+        cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
51907a
 
51907a
-  stex->masked_pipeline = pipeline;
51907a
+      stex->masked_pipeline = pipeline;
51907a
+      return pipeline;
51907a
+    }
51907a
+  else
51907a
+    {
51907a
+      CoglPipeline *pipeline;
51907a
+
51907a
+      if (stex->masked_tower_pipeline)
51907a
+        return stex->masked_tower_pipeline;
51907a
 
51907a
-  return pipeline;
51907a
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
+      cogl_pipeline_set_layer_combine (pipeline, 1,
51907a
+                                       "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
51907a
+                                       NULL);
51907a
+
51907a
+      stex->masked_tower_pipeline = pipeline;
51907a
+      return pipeline;
51907a
+    }
51907a
 }
51907a
 
51907a
 static CoglPipeline *
51907a
 get_unblended_pipeline (MetaShapedTexture *stex,
51907a
-                        CoglContext       *ctx)
51907a
+                        CoglContext       *ctx,
51907a
+                        CoglTexture       *tex)
51907a
 {
51907a
-  CoglPipeline *pipeline;
51907a
-  CoglColor color;
51907a
+  if (stex->texture == tex)
51907a
+    {
51907a
+      CoglPipeline *pipeline;
51907a
+      CoglColor color;
51907a
 
51907a
-  if (stex->unblended_pipeline)
51907a
-    return stex->unblended_pipeline;
51907a
+      if (stex->unblended_pipeline)
51907a
+        return stex->unblended_pipeline;
51907a
 
51907a
-  pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
-  cogl_color_init_from_4ub (&color, 255, 255, 255, 255);
51907a
-  cogl_pipeline_set_blend (pipeline,
51907a
-                           "RGBA = ADD (SRC_COLOR, 0)",
51907a
-                           NULL);
51907a
-  cogl_pipeline_set_color (pipeline, &color;;
51907a
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
+      cogl_color_init_from_4ub (&color, 255, 255, 255, 255);
51907a
+      cogl_pipeline_set_blend (pipeline,
51907a
+                               "RGBA = ADD (SRC_COLOR, 0)",
51907a
+                               NULL);
51907a
+      cogl_pipeline_set_color (pipeline, &color;;
51907a
+      if (stex->snippet)
51907a
+        cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
51907a
 
51907a
-  stex->unblended_pipeline = pipeline;
51907a
+      stex->unblended_pipeline = pipeline;
51907a
+      return pipeline;
51907a
+    }
51907a
+  else
51907a
+    {
51907a
+      CoglPipeline *pipeline;
51907a
+      CoglColor color;
51907a
 
51907a
-  return pipeline;
51907a
+      if (stex->unblended_tower_pipeline)
51907a
+        return stex->unblended_tower_pipeline;
51907a
+
51907a
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
51907a
+      cogl_color_init_from_4ub (&color, 255, 255, 255, 255);
51907a
+      cogl_pipeline_set_blend (pipeline,
51907a
+                               "RGBA = ADD (SRC_COLOR, 0)",
51907a
+                               NULL);
51907a
+      cogl_pipeline_set_color (pipeline, &color;;
51907a
+
51907a
+      stex->unblended_tower_pipeline = pipeline;
51907a
+      return pipeline;
51907a
+    }
51907a
 }
51907a
 
51907a
 static void
51907a
@@ -714,7 +787,7 @@ do_paint (MetaShapedTexture *stex,
51907a
 
51907a
       if (!cairo_region_is_empty (region))
51907a
         {
51907a
-          opaque_pipeline = get_unblended_pipeline (stex, ctx);
51907a
+          opaque_pipeline = get_unblended_pipeline (stex, ctx, paint_tex);
51907a
           cogl_pipeline_set_layer_texture (opaque_pipeline, 0, paint_tex);
51907a
           cogl_pipeline_set_layer_filters (opaque_pipeline, 0, filter, filter);
51907a
 
51907a
@@ -750,11 +823,11 @@ do_paint (MetaShapedTexture *stex,
51907a
 
51907a
       if (stex->mask_texture == NULL)
51907a
         {
51907a
-          blended_pipeline = get_unmasked_pipeline (stex, ctx);
51907a
+          blended_pipeline = get_unmasked_pipeline (stex, ctx, paint_tex);
51907a
         }
51907a
       else
51907a
         {
51907a
-          blended_pipeline = get_masked_pipeline (stex, ctx);
51907a
+          blended_pipeline = get_masked_pipeline (stex, ctx, paint_tex);
51907a
           cogl_pipeline_set_layer_texture (blended_pipeline, 1, stex->mask_texture);
51907a
           cogl_pipeline_set_layer_filters (blended_pipeline, 1, filter, filter);
51907a
         }
51907a
-- 
51907a
2.34.1
51907a