[mutter/gnome-3-36] shaped-texture: Expose ensure_size_valid() API



commit 30d21f3120efeed7419a1df194767cce3074d55a
Author: Robert Mader <robert mader posteo de>
Date:   Tue Mar 23 10:12:09 2021 +0100

    shaped-texture: Expose ensure_size_valid() API
    
    When the texture size is invalidated using `invalidate_size()`, the new
    size will only get calculated the next time `update_size()` is
    called. This happens e.g. in `meta_shaped_texture_get_preferred_size()`
    via `ensure_size_valid()`.
    
    `update_size()` can chain up to `clutter_content_invalidate_size()`
    as well as emitting a `size-changed` signal. If this happens during
    layout, the result is a 'change the layout conditions during layout'
    issue, causing heavy breakage in e.g. the Shell overview.
    
    To fix this, expose `ensure_size_valid()` as API so callers can make
    sure the texture has a valid size without creating redundant size
    invalidations calls.
    
    Note that if a buffer with a new size is attached we already trigger
    `update_size()` explicitely, avoiding such situations.
    
    
    (cherry picked from commit 5772c27e04c3b1ad5dd8bcbacc75f3025a776d09)
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1809>

 src/compositor/meta-shaped-texture-private.h |  2 ++
 src/compositor/meta-shaped-texture.c         | 18 +++++++++---------
 2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index c415260c0b..604dee81b7 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -69,4 +69,6 @@ int meta_shaped_texture_get_height (MetaShapedTexture *stex);
 void meta_shaped_texture_set_clip_region (MetaShapedTexture *stex,
                                           cairo_region_t    *clip_region);
 
+void meta_shaped_texture_ensure_size_valid (MetaShapedTexture *stex);
+
 #endif
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 015f581484..adf213f769 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -210,8 +210,8 @@ update_size (MetaShapedTexture *stex)
     }
 }
 
-static void
-ensure_size_valid (MetaShapedTexture *stex)
+void
+meta_shaped_texture_ensure_size_valid (MetaShapedTexture *stex)
 {
   if (stex->size_invalid)
     update_size (stex);
@@ -545,7 +545,7 @@ do_paint_content (MetaShapedTexture   *stex,
   CoglFramebuffer *framebuffer;
   int sample_width, sample_height;
 
-  ensure_size_valid (stex);
+  meta_shaped_texture_ensure_size_valid (stex);
 
   dst_width = stex->dst_width;
   dst_height = stex->dst_height;
@@ -822,7 +822,7 @@ meta_shaped_texture_get_preferred_size (ClutterContent *content,
 {
   MetaShapedTexture *stex = META_SHAPED_TEXTURE (content);
 
-  ensure_size_valid (stex);
+  meta_shaped_texture_ensure_size_valid (stex);
 
   if (width)
     *width = stex->dst_width;
@@ -914,7 +914,7 @@ meta_shaped_texture_update_area (MetaShapedTexture     *stex,
                                clip);
 
   inverted_transform = meta_monitor_transform_invert (stex->transform);
-  ensure_size_valid (stex);
+  meta_shaped_texture_ensure_size_valid (stex);
   meta_rectangle_transform (clip,
                             inverted_transform,
                             stex->dst_width,
@@ -1133,7 +1133,7 @@ meta_shaped_texture_is_opaque (MetaShapedTexture *stex)
 
   cairo_region_get_extents (stex->opaque_region, &opaque_rect);
 
-  ensure_size_valid (stex);
+  meta_shaped_texture_ensure_size_valid (stex);
 
   return meta_rectangle_equal (&opaque_rect,
                                &(MetaRectangle) {
@@ -1364,7 +1364,7 @@ meta_shaped_texture_get_image (MetaShapedTexture     *stex,
   if (texture == NULL)
     return NULL;
 
-  ensure_size_valid (stex);
+  meta_shaped_texture_ensure_size_valid (stex);
 
   if (stex->dst_width == 0 || stex->dst_height == 0)
     return NULL;
@@ -1507,7 +1507,7 @@ meta_shaped_texture_get_width (MetaShapedTexture *stex)
 {
   g_return_val_if_fail (META_IS_SHAPED_TEXTURE (stex), 0);
 
-  ensure_size_valid (stex);
+  meta_shaped_texture_ensure_size_valid (stex);
 
   return stex->dst_width;
 }
@@ -1517,7 +1517,7 @@ meta_shaped_texture_get_height (MetaShapedTexture *stex)
 {
   g_return_val_if_fail (META_IS_SHAPED_TEXTURE (stex), 0);
 
-  ensure_size_valid (stex);
+  meta_shaped_texture_ensure_size_valid (stex);
 
   return stex->dst_height;
 }


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