Blame SOURCES/eglstream-overview-fixes.patch

890a48
From d3d8ab8eabc3178f3c31ee71dcc926297ff1c1b0 Mon Sep 17 00:00:00 2001
890a48
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
890a48
Date: Tue, 8 Feb 2022 17:14:06 +0100
890a48
Subject: [PATCH 1/2] shaped-texture: Pass along the snippet to the texture
890a48
 tower
890a48
890a48
The snippet is used make sure the right source is sampled in the shader.
890a48
This wasn't done in the texture tower, meaning the textures from the
890a48
tower were not correct.
890a48
890a48
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
890a48
---
890a48
 src/compositor/meta-shaped-texture.c |  2 ++
890a48
 src/compositor/meta-texture-tower.c  | 27 +++++++++++++++++++++++++++
890a48
 src/compositor/meta-texture-tower.h  |  3 +++
890a48
 3 files changed, 32 insertions(+)
890a48
890a48
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
890a48
index 095dd246f0c0..68919c5f1c5c 100644
890a48
--- a/src/compositor/meta-shaped-texture.c
890a48
+++ b/src/compositor/meta-shaped-texture.c
890a48
@@ -1242,6 +1242,8 @@ meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
890a48
   g_clear_pointer (&stex->snippet, cogl_object_unref);
890a48
   if (snippet)
890a48
     stex->snippet = cogl_object_ref (snippet);
890a48
+
890a48
+  meta_texture_tower_set_snippet (stex->paint_tower, snippet);
890a48
 }
890a48
 
890a48
 /**
890a48
diff --git a/src/compositor/meta-texture-tower.c b/src/compositor/meta-texture-tower.c
890a48
index 1fc4623e5e54..0ae717abe4d4 100644
890a48
--- a/src/compositor/meta-texture-tower.c
890a48
+++ b/src/compositor/meta-texture-tower.c
890a48
@@ -62,6 +62,7 @@ struct _MetaTextureTower
890a48
   CoglOffscreen *fbos[MAX_TEXTURE_LEVELS];
890a48
   Box invalid[MAX_TEXTURE_LEVELS];
890a48
   CoglPipeline *pipeline_template;
890a48
+  CoglSnippet *snippet;
890a48
 };
890a48
 
890a48
 /**
890a48
@@ -97,6 +98,7 @@ meta_texture_tower_free (MetaTextureTower *tower)
890a48
     cogl_object_unref (tower->pipeline_template);
890a48
 
890a48
   meta_texture_tower_set_base_texture (tower, NULL);
890a48
+  cogl_clear_object (&tower->snippet);
890a48
 
890a48
   g_free (tower);
890a48
 }
890a48
@@ -216,6 +218,28 @@ meta_texture_tower_update_area (MetaTextureTower *tower,
890a48
     }
890a48
 }
890a48
 
890a48
+void
890a48
+meta_texture_tower_set_snippet (MetaTextureTower *tower,
890a48
+                                CoglSnippet      *snippet)
890a48
+{
890a48
+  int i;
890a48
+
890a48
+  if (tower->snippet == snippet)
890a48
+    return;
890a48
+
890a48
+  g_clear_pointer (&tower->snippet, cogl_object_unref);
890a48
+
890a48
+  if (snippet)
890a48
+    tower->snippet = cogl_object_ref (snippet);
890a48
+
890a48
+  for (i = 1; i < tower->n_levels; i++)
890a48
+    {
890a48
+      cogl_clear_object (&tower->textures[i]);
890a48
+      g_clear_object (&tower->fbos[i]);
890a48
+    }
890a48
+  cogl_clear_object (&tower->pipeline_template);
890a48
+}
890a48
+
890a48
 /* It generally looks worse if we scale up a window texture by even a
890a48
  * small amount than if we scale it down using bilinear filtering, so
890a48
  * we always pick the *larger* adjacent level. */
890a48
@@ -408,6 +432,9 @@ texture_tower_revalidate (MetaTextureTower *tower,
890a48
   pipeline = cogl_pipeline_copy (tower->pipeline_template);
890a48
   cogl_pipeline_set_layer_texture (pipeline, 0, tower->textures[level - 1]);
890a48
 
890a48
+  if (tower->snippet && level == 1)
890a48
+    cogl_pipeline_add_layer_snippet (pipeline, 0, tower->snippet);
890a48
+
890a48
   cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
890a48
                                             invalid->x1, invalid->y1,
890a48
                                             invalid->x2, invalid->y2,
890a48
diff --git a/src/compositor/meta-texture-tower.h b/src/compositor/meta-texture-tower.h
890a48
index 1f5b371467c9..5522dfbb16ac 100644
890a48
--- a/src/compositor/meta-texture-tower.h
890a48
+++ b/src/compositor/meta-texture-tower.h
890a48
@@ -63,6 +63,9 @@ void              meta_texture_tower_update_area       (MetaTextureTower *tower,
890a48
 CoglTexture      *meta_texture_tower_get_paint_texture (MetaTextureTower    *tower,
890a48
                                                         ClutterPaintContext *paint_context);
890a48
 
890a48
+void meta_texture_tower_set_snippet (MetaTextureTower *tower,
890a48
+                                     CoglSnippet      *snippet);
890a48
+
890a48
 G_END_DECLS
890a48
 
890a48
 #endif /* __META_TEXTURE_TOWER_H__ */
890a48
-- 
890a48
2.34.1
890a48
890a48
890a48
From b78a24dfebf56b04538058ff731890ee997d0d10 Mon Sep 17 00:00:00 2001
890a48
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
890a48
Date: Wed, 9 Feb 2022 12:41:14 +0100
890a48
Subject: [PATCH 2/2] shaped-texture: Paint with the right layer snippet
890a48
890a48
When we get passed a "snippet" to the shaped texture, it's added as a
890a48
pipeline layer snippet to change how the source texture is sampled. When
890a48
we draw from a texture tower however we have allocated regular textures
890a48
which doesn't need any special layer snippet, so create separate
890a48
pipelines for those that doesn't use that snippet.
890a48
890a48
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
890a48
---
890a48
 src/compositor/meta-shaped-texture.c | 126 +++++++++++++++++++++------
890a48
 1 file changed, 98 insertions(+), 28 deletions(-)
890a48
890a48
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
890a48
index 68919c5f1c5c..0d09f2f4e164 100644
890a48
--- a/src/compositor/meta-shaped-texture.c
890a48
+++ b/src/compositor/meta-shaped-texture.c
890a48
@@ -91,8 +91,12 @@ struct _MetaShapedTexture
890a48
   CoglSnippet *snippet;
890a48
 
890a48
   CoglPipeline *base_pipeline;
890a48
+  CoglPipeline *unmasked_pipeline;
890a48
+  CoglPipeline *unmasked_tower_pipeline;
890a48
   CoglPipeline *masked_pipeline;
890a48
+  CoglPipeline *masked_tower_pipeline;
890a48
   CoglPipeline *unblended_pipeline;
890a48
+  CoglPipeline *unblended_tower_pipeline;
890a48
 
890a48
   gboolean is_y_inverted;
890a48
 
890a48
@@ -243,8 +247,12 @@ static void
890a48
 meta_shaped_texture_reset_pipelines (MetaShapedTexture *stex)
890a48
 {
890a48
   g_clear_pointer (&stex->base_pipeline, cogl_object_unref);
890a48
+  g_clear_pointer (&stex->unmasked_pipeline, cogl_object_unref);
890a48
+  g_clear_pointer (&stex->unmasked_tower_pipeline, cogl_object_unref);
890a48
   g_clear_pointer (&stex->masked_pipeline, cogl_object_unref);
890a48
+  g_clear_pointer (&stex->masked_tower_pipeline, cogl_object_unref);
890a48
   g_clear_pointer (&stex->unblended_pipeline, cogl_object_unref);
890a48
+  g_clear_pointer (&stex->unblended_tower_pipeline, cogl_object_unref);
890a48
 }
890a48
 
890a48
 static void
890a48
@@ -381,9 +389,6 @@ get_base_pipeline (MetaShapedTexture *stex,
890a48
 
890a48
   cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
890a48
 
890a48
-  if (stex->snippet)
890a48
-    cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
890a48
-
890a48
   stex->base_pipeline = pipeline;
890a48
 
890a48
   return stex->base_pipeline;
890a48
@@ -391,47 +396,112 @@ get_base_pipeline (MetaShapedTexture *stex,
890a48
 
890a48
 static CoglPipeline *
890a48
 get_unmasked_pipeline (MetaShapedTexture *stex,
890a48
-                       CoglContext       *ctx)
890a48
+                       CoglContext       *ctx,
890a48
+                       CoglTexture       *tex)
890a48
 {
890a48
-  return get_base_pipeline (stex, ctx);
890a48
+  if (stex->texture == tex)
890a48
+    {
890a48
+      CoglPipeline *pipeline;
890a48
+
890a48
+      if (stex->unmasked_pipeline)
890a48
+        return stex->unmasked_pipeline;
890a48
+
890a48
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
+      if (stex->snippet)
890a48
+        cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
890a48
+
890a48
+      stex->unmasked_pipeline = pipeline;
890a48
+      return pipeline;
890a48
+    }
890a48
+  else
890a48
+    {
890a48
+      CoglPipeline *pipeline;
890a48
+
890a48
+      if (stex->unmasked_tower_pipeline)
890a48
+        return stex->unmasked_tower_pipeline;
890a48
+
890a48
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
+      stex->unmasked_tower_pipeline = pipeline;
890a48
+      return pipeline;
890a48
+    }
890a48
 }
890a48
 
890a48
 static CoglPipeline *
890a48
 get_masked_pipeline (MetaShapedTexture *stex,
890a48
-                     CoglContext       *ctx)
890a48
+                     CoglContext       *ctx,
890a48
+                     CoglTexture       *tex)
890a48
 {
890a48
-  CoglPipeline *pipeline;
890a48
+  if (stex->texture == tex)
890a48
+    {
890a48
+      CoglPipeline *pipeline;
890a48
 
890a48
-  if (stex->masked_pipeline)
890a48
-    return stex->masked_pipeline;
890a48
+      if (stex->masked_pipeline)
890a48
+        return stex->masked_pipeline;
890a48
 
890a48
-  pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
-  cogl_pipeline_set_layer_combine (pipeline, 1,
890a48
-                                   "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
890a48
-                                   NULL);
890a48
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
+      cogl_pipeline_set_layer_combine (pipeline, 1,
890a48
+                                       "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
890a48
+                                       NULL);
890a48
+      if (stex->snippet)
890a48
+        cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
890a48
 
890a48
-  stex->masked_pipeline = pipeline;
890a48
+      stex->masked_pipeline = pipeline;
890a48
+      return pipeline;
890a48
+    }
890a48
+  else
890a48
+    {
890a48
+      CoglPipeline *pipeline;
890a48
 
890a48
-  return pipeline;
890a48
+      if (stex->masked_tower_pipeline)
890a48
+        return stex->masked_tower_pipeline;
890a48
+
890a48
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
+      cogl_pipeline_set_layer_combine (pipeline, 1,
890a48
+                                       "RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
890a48
+                                       NULL);
890a48
+
890a48
+      stex->masked_tower_pipeline = pipeline;
890a48
+      return pipeline;
890a48
+    }
890a48
 }
890a48
 
890a48
 static CoglPipeline *
890a48
 get_unblended_pipeline (MetaShapedTexture *stex,
890a48
-                        CoglContext       *ctx)
890a48
+                        CoglContext       *ctx,
890a48
+                        CoglTexture       *tex)
890a48
 {
890a48
-  CoglPipeline *pipeline;
890a48
+  if (stex->texture == tex)
890a48
+    {
890a48
+      CoglPipeline *pipeline;
890a48
 
890a48
-  if (stex->unblended_pipeline)
890a48
-    return stex->unblended_pipeline;
890a48
+      if (stex->unblended_pipeline)
890a48
+        return stex->unblended_pipeline;
890a48
 
890a48
-  pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
-  cogl_pipeline_set_layer_combine (pipeline, 0,
890a48
-                                   "RGBA = REPLACE (TEXTURE)",
890a48
-                                   NULL);
890a48
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
+      cogl_pipeline_set_layer_combine (pipeline, 0,
890a48
+                                       "RGBA = REPLACE (TEXTURE)",
890a48
+                                       NULL);
890a48
+      if (stex->snippet)
890a48
+        cogl_pipeline_add_layer_snippet (pipeline, 0, stex->snippet);
890a48
 
890a48
-  stex->unblended_pipeline = pipeline;
890a48
+      stex->unblended_pipeline = pipeline;
890a48
+      return pipeline;
890a48
+    }
890a48
+  else
890a48
+    {
890a48
+      CoglPipeline *pipeline;
890a48
 
890a48
-  return pipeline;
890a48
+      if (stex->unblended_tower_pipeline)
890a48
+        return stex->unblended_tower_pipeline;
890a48
+
890a48
+      pipeline = cogl_pipeline_copy (get_base_pipeline (stex, ctx));
890a48
+      cogl_pipeline_set_layer_combine (pipeline, 0,
890a48
+                                       "RGBA = REPLACE (TEXTURE)",
890a48
+                                       NULL);
890a48
+
890a48
+      stex->unblended_tower_pipeline = pipeline;
890a48
+      return pipeline;
890a48
+    }
890a48
 }
890a48
 
890a48
 static CoglPipeline *
890a48
@@ -742,7 +812,7 @@ do_paint_content (MetaShapedTexture   *stex,
890a48
         {
890a48
           CoglPipeline *opaque_pipeline;
890a48
 
890a48
-          opaque_pipeline = get_unblended_pipeline (stex, ctx);
890a48
+          opaque_pipeline = get_unblended_pipeline (stex, ctx, paint_tex);
890a48
           cogl_pipeline_set_layer_texture (opaque_pipeline, 0, paint_tex);
890a48
           cogl_pipeline_set_layer_filters (opaque_pipeline, 0, filter, filter);
890a48
 
890a48
@@ -786,11 +856,11 @@ do_paint_content (MetaShapedTexture   *stex,
890a48
 
890a48
       if (stex->mask_texture == NULL)
890a48
         {
890a48
-          blended_pipeline = get_unmasked_pipeline (stex, ctx);
890a48
+          blended_pipeline = get_unmasked_pipeline (stex, ctx, paint_tex);
890a48
         }
890a48
       else
890a48
         {
890a48
-          blended_pipeline = get_masked_pipeline (stex, ctx);
890a48
+          blended_pipeline = get_masked_pipeline (stex, ctx, paint_tex);
890a48
           cogl_pipeline_set_layer_texture (blended_pipeline, 1, stex->mask_texture);
890a48
           cogl_pipeline_set_layer_filters (blended_pipeline, 1, filter, filter);
890a48
         }
890a48
-- 
890a48
2.34.1
890a48