[mutter/gbsneto/content-part2: 5/7] window-content: Track subsurfaces invalidations
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/content-part2: 5/7] window-content: Track subsurfaces invalidations
- Date: Mon, 4 Feb 2019 11:15:56 +0000 (UTC)
commit bde0fd454d01826431ac928163e05bb975ca8f73
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Dec 27 23:30:20 2018 -0200
window-content: Track subsurfaces invalidations
WIP
src/compositor/meta-shaped-texture-private.h | 14 ++++++
src/compositor/meta-shaped-texture.c | 51 ++++++++++++++++++++
src/compositor/meta-window-content.c | 69 +++++++++++++++++++++++++++-
3 files changed, 133 insertions(+), 1 deletion(-)
---
diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index c80cb7250..3b72c36a3 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -52,4 +52,18 @@ void meta_shaped_texture_set_scale (MetaShapedTexture *stex,
double scale);
double meta_shaped_texture_get_scale (MetaShapedTexture *stex);
+void meta_shaped_texture_paint_node (MetaShapedTexture *stex,
+ ClutterPaintNode *root_node,
+ ClutterActorBox *box,
+ double tex_scale,
+ guchar opacity);
+
+typedef void (*MetaShapedTextureInvalidateFunc) (MetaShapedTexture *stex,
+ gboolean size_changed,
+ gpointer user_data);
+
+void meta_shaped_texture_set_invalidate_func (MetaShapedTexture *stex,
+ MetaShapedTextureInvalidateFunc func,
+ gpointer user_data);
+
#endif
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index e22db1da7..2848a2fae 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -100,6 +100,9 @@ struct _MetaShapedTexture
double scale;
+ MetaShapedTextureInvalidateFunc invalidate_func;
+ gpointer invalidate_user_data;
+
guint create_mipmaps : 1;
};
@@ -721,11 +724,35 @@ meta_shaped_texture_get_preferred_size (ClutterContent *content,
return TRUE;
}
+static void
+meta_shaped_texture_invalidate (ClutterContent *content)
+{
+ MetaShapedTexture *stex = META_SHAPED_TEXTURE (content);
+
+ if (!stex->invalidate_func)
+ return;
+
+ stex->invalidate_func (stex, FALSE, stex->invalidate_user_data);
+}
+
+static void
+meta_shaped_texture_invalidate_size (ClutterContent *content)
+{
+ MetaShapedTexture *stex = META_SHAPED_TEXTURE (content);
+
+ if (!stex->invalidate_func)
+ return;
+
+ stex->invalidate_func (stex, TRUE, stex->invalidate_user_data);
+}
+
static void
clutter_content_iface_init (ClutterContentIface *iface)
{
iface->paint_content = meta_shaped_texture_paint_content;
iface->get_preferred_size = meta_shaped_texture_get_preferred_size;
+ iface->invalidate = meta_shaped_texture_invalidate;
+ iface->invalidate_size = meta_shaped_texture_invalidate_size;
}
void
@@ -1222,3 +1249,27 @@ meta_shaped_texture_get_scale (MetaShapedTexture *stex)
return stex->scale;
}
+
+void
+meta_shaped_texture_paint_node (MetaShapedTexture *stex,
+ ClutterPaintNode *root_node,
+ ClutterActorBox *box,
+ double tex_scale,
+ guchar opacity)
+{
+ g_return_if_fail (META_IS_SHAPED_TEXTURE (stex));
+
+ if (!stex->texture)
+ return;
+
+ do_paint_content (stex, root_node, stex->texture, box, tex_scale, opacity);
+}
+
+void
+meta_shaped_texture_set_invalidate_func (MetaShapedTexture *stex,
+ MetaShapedTextureInvalidateFunc func,
+ gpointer user_data)
+{
+ stex->invalidate_func = func;
+ stex->invalidate_user_data = user_data;
+}
diff --git a/src/compositor/meta-window-content.c b/src/compositor/meta-window-content.c
index 1b4b9d51a..08c52d7dd 100644
--- a/src/compositor/meta-window-content.c
+++ b/src/compositor/meta-window-content.c
@@ -82,6 +82,53 @@ enum
static GParamSpec *properties [N_PROPS];
+static void
+texture_invalidate_func (MetaShapedTexture *stex,
+ gboolean size_changed,
+ gpointer user_data)
+{
+ MetaWindowContent *window_content = (MetaWindowContent*) user_data;
+
+ if (window_content->attached_actors == 0)
+ return;
+
+ if (size_changed)
+ clutter_content_invalidate_size (CLUTTER_CONTENT (user_data));
+ else
+ clutter_content_invalidate (CLUTTER_CONTENT (user_data));
+}
+
+static void
+set_surface_invalidate_func (MetaWindowContent *window_content,
+ MetaSurfaceActor *surface_actor,
+ MetaShapedTextureInvalidateFunc func)
+{
+ MetaShapedTexture *stex =
+ meta_surface_actor_get_texture (surface_actor);
+ ClutterActorIter iter;
+ ClutterActor *child;
+
+ meta_shaped_texture_set_invalidate_func (stex, func, window_content);
+
+ clutter_actor_iter_init (&iter, CLUTTER_ACTOR (surface_actor));
+ while (clutter_actor_iter_next (&iter, &child))
+ set_surface_invalidate_func (window_content, META_SURFACE_ACTOR (child), func);
+}
+
+static void
+ensure_shaped_textures_invalidate_func (MetaWindowContent *window_content)
+{
+ MetaSurfaceActor *surface_actor =
+ meta_window_actor_get_surface (window_content->window_actor);
+
+ if (!surface_actor)
+ return;
+
+ set_surface_invalidate_func (window_content,
+ surface_actor,
+ texture_invalidate_func);
+}
+
static void
add_surface_paint_nodes (MetaSurfaceActor *surface_actor,
ClutterActor *actor,
@@ -119,7 +166,7 @@ add_surface_paint_nodes (MetaSurfaceActor *surface_actor,
clutter_actor_get_scale (actor, &actor_scale, NULL);
clutter_actor_get_scale (CLUTTER_ACTOR (surface_actor), &surface_scale, NULL);
- _meta_shaped_texture_paint_node (shaped_texture,
+ meta_shaped_texture_paint_node (shaped_texture,
root_node,
&box,
actor_scale * surface_scale,
@@ -158,6 +205,8 @@ meta_window_content_paint_content (ClutterContent *content,
if (!surface_actor)
return;
+ ensure_shaped_textures_invalidate_func (window_content);
+
/* Horizontal and vertical scales */
clutter_actor_get_size (CLUTTER_ACTOR (surface_actor),
&width, &height);
@@ -182,6 +231,8 @@ meta_window_content_get_preferred_size (ClutterContent *content,
if (!surface_actor)
return FALSE;
+ ensure_shaped_textures_invalidate_func (window_content);
+
clutter_actor_get_size (CLUTTER_ACTOR (surface_actor),
width, height);
return TRUE;
@@ -194,6 +245,8 @@ meta_window_content_attached (ClutterContent *content,
MetaWindowContent *window_content = META_WINDOW_CONTENT (content);
window_content->attached_actors++;
+
+ ensure_shaped_textures_invalidate_func (window_content);
}
static void
@@ -255,11 +308,25 @@ meta_window_content_set_property (GObject *object,
}
}
+static void
+meta_window_content_dispose (GObject *object)
+{
+ MetaWindowContent *window_content = META_WINDOW_CONTENT (object);
+ MetaSurfaceActor *surface_actor =
+ meta_window_actor_get_surface (window_content->window_actor);
+
+ if (surface_actor)
+ set_surface_invalidate_func (window_content, surface_actor, NULL);
+
+ G_OBJECT_CLASS (meta_window_content_parent_class)->dispose (object);
+}
+
static void
meta_window_content_class_init (MetaWindowContentClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = meta_window_content_dispose;
object_class->get_property = meta_window_content_get_property;
object_class->set_property = meta_window_content_set_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]