Blame SOURCES/eglstream-overview-fixes.patch

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