[mutter/gbsneto/more-clutter-api: 21/25] clutter/image: Also invalidate size
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/more-clutter-api: 21/25] clutter/image: Also invalidate size
- Date: Fri, 1 Feb 2019 12:42:34 +0000 (UTC)
commit 25f36b3892713b1877839bf0271a354273bb7ec5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Jan 27 13:53:06 2019 -0200
clutter/image: Also invalidate size
ClutterImage is a ClutterContent implementation that
has an internally managed CoglTexture. This texture
is recreated when new image data is set.
ClutterContent implementations may have control over
the allocation of the widgets they're attached to,
through CLUTTER_REQUEST_CONTENT_SIZE. On those cases,
if the new image data differs in size from the previous
data, it is important to notify those actors about the
size change. However, currently ClutterImage does not
notify them.
With the introduction of clutter_content_invalidate_size(),
it is possible to report the size changes to attached
actors.
Adapt ClutterImage to invalidate_size() when image data
has different sizes.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/405
clutter/clutter/clutter-image.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/clutter/clutter/clutter-image.c b/clutter/clutter/clutter-image.c
index d4356598b..924626be0 100644
--- a/clutter/clutter/clutter-image.c
+++ b/clutter/clutter/clutter-image.c
@@ -53,6 +53,8 @@
struct _ClutterImagePrivate
{
CoglTexture *texture;
+ gint width;
+ gint height;
};
static void clutter_content_iface_init (ClutterContentIface *iface);
@@ -68,6 +70,27 @@ clutter_image_error_quark (void)
return g_quark_from_static_string ("clutter-image-error-quark");
}
+static void
+update_image_size (ClutterImage *self)
+{
+ gint width, height;
+
+ if (self->priv->texture == NULL)
+ return;
+
+ width = cogl_texture_get_width (self->priv->texture);
+ height = cogl_texture_get_height (self->priv->texture);
+
+ if (self->priv->width == width &&
+ self->priv->height == height)
+ return;
+
+ self->priv->width = width;
+ self->priv->height = height;
+
+ clutter_content_invalidate_size (CLUTTER_CONTENT (self));
+}
+
static void
clutter_image_finalize (GObject *gobject)
{
@@ -238,6 +261,7 @@ clutter_image_set_data (ClutterImage *image,
}
clutter_content_invalidate (CLUTTER_CONTENT (image));
+ update_image_size (image);
return TRUE;
}
@@ -306,6 +330,7 @@ clutter_image_set_bytes (ClutterImage *image,
}
clutter_content_invalidate (CLUTTER_CONTENT (image));
+ update_image_size (image);
return TRUE;
}
@@ -399,6 +424,7 @@ clutter_image_set_area (ClutterImage *image,
}
clutter_content_invalidate (CLUTTER_CONTENT (image));
+ update_image_size (image);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]