[mutter] shaped-texture: Pass along the snippet to the texture tower



commit d4ffaf291ffb805b2c1d0389b284a57ba3471383
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Feb 8 17:14:06 2022 +0100

    shaped-texture: Pass along the snippet to the texture tower
    
    The snippet is used make sure the right source is sampled in the shader.
    This wasn't done in the texture tower, meaning the textures from the
    tower were not correct.
    
    Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2278>

 src/compositor/meta-shaped-texture.c |  2 ++
 src/compositor/meta-texture-tower.c  | 27 +++++++++++++++++++++++++++
 src/compositor/meta-texture-tower.h  |  3 +++
 3 files changed, 32 insertions(+)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index fd3dc73fc7..b45b1732cd 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -1144,6 +1144,8 @@ meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
   g_clear_pointer (&stex->snippet, cogl_object_unref);
   if (snippet)
     stex->snippet = cogl_object_ref (snippet);
+
+  meta_texture_tower_set_snippet (stex->paint_tower, snippet);
 }
 
 /**
diff --git a/src/compositor/meta-texture-tower.c b/src/compositor/meta-texture-tower.c
index c491e4d123..510e85f796 100644
--- a/src/compositor/meta-texture-tower.c
+++ b/src/compositor/meta-texture-tower.c
@@ -62,6 +62,7 @@ struct _MetaTextureTower
   CoglOffscreen *fbos[MAX_TEXTURE_LEVELS];
   Box invalid[MAX_TEXTURE_LEVELS];
   CoglPipeline *pipeline_template;
+  CoglSnippet *snippet;
 };
 
 /**
@@ -97,6 +98,7 @@ meta_texture_tower_free (MetaTextureTower *tower)
     cogl_object_unref (tower->pipeline_template);
 
   meta_texture_tower_set_base_texture (tower, NULL);
+  cogl_clear_object (&tower->snippet);
 
   g_free (tower);
 }
@@ -216,6 +218,28 @@ meta_texture_tower_update_area (MetaTextureTower *tower,
     }
 }
 
+void
+meta_texture_tower_set_snippet (MetaTextureTower *tower,
+                                CoglSnippet      *snippet)
+{
+  int i;
+
+  if (tower->snippet == snippet)
+    return;
+
+  g_clear_pointer (&tower->snippet, cogl_object_unref);
+
+  if (snippet)
+    tower->snippet = cogl_object_ref (snippet);
+
+  for (i = 1; i < tower->n_levels; i++)
+    {
+      cogl_clear_object (&tower->textures[i]);
+      g_clear_object (&tower->fbos[i]);
+    }
+  cogl_clear_object (&tower->pipeline_template);
+}
+
 /* It generally looks worse if we scale up a window texture by even a
  * small amount than if we scale it down using bilinear filtering, so
  * we always pick the *larger* adjacent level. */
@@ -410,6 +434,9 @@ texture_tower_revalidate (MetaTextureTower *tower,
   pipeline = cogl_pipeline_copy (tower->pipeline_template);
   cogl_pipeline_set_layer_texture (pipeline, 0, tower->textures[level - 1]);
 
+  if (tower->snippet && level == 1)
+    cogl_pipeline_add_layer_snippet (pipeline, 0, tower->snippet);
+
   cogl_framebuffer_draw_textured_rectangle (fb, pipeline,
                                             invalid->x1, invalid->y1,
                                             invalid->x2, invalid->y2,
diff --git a/src/compositor/meta-texture-tower.h b/src/compositor/meta-texture-tower.h
index 1f5b371467..5522dfbb16 100644
--- a/src/compositor/meta-texture-tower.h
+++ b/src/compositor/meta-texture-tower.h
@@ -63,6 +63,9 @@ void              meta_texture_tower_update_area       (MetaTextureTower *tower,
 CoglTexture      *meta_texture_tower_get_paint_texture (MetaTextureTower    *tower,
                                                         ClutterPaintContext *paint_context);
 
+void meta_texture_tower_set_snippet (MetaTextureTower *tower,
+                                     CoglSnippet      *snippet);
+
 G_END_DECLS
 
 #endif /* __META_TEXTURE_TOWER_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]