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. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1799>
This commit is contained in:
parent
50ba52b1b5
commit
5772c27e04
@ -71,4 +71,6 @@ void meta_shaped_texture_set_clip_region (MetaShapedTexture *stex,
|
||||
void meta_shaped_texture_set_opaque_region (MetaShapedTexture *stex,
|
||||
cairo_region_t *opaque_region);
|
||||
|
||||
void meta_shaped_texture_ensure_size_valid (MetaShapedTexture *stex);
|
||||
|
||||
#endif
|
||||
|
@ -220,8 +220,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);
|
||||
@ -600,7 +600,7 @@ do_paint_content (MetaShapedTexture *stex,
|
||||
int sample_width, sample_height;
|
||||
gboolean debug_paint_opaque_region;
|
||||
|
||||
ensure_size_valid (stex);
|
||||
meta_shaped_texture_ensure_size_valid (stex);
|
||||
|
||||
dst_width = stex->dst_width;
|
||||
dst_height = stex->dst_height;
|
||||
@ -914,7 +914,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;
|
||||
@ -1006,7 +1006,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,
|
||||
@ -1219,7 +1219,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) {
|
||||
@ -1485,7 +1485,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;
|
||||
@ -1643,7 +1643,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;
|
||||
}
|
||||
@ -1659,7 +1659,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user