You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
7.0 KiB
193 lines
7.0 KiB
From 6881aa5ca235ee0737c2a409ffab966a10e5971e Mon Sep 17 00:00:00 2001
|
|
From: Christian Hergert <christian@hergert.me>
|
|
Date: Mon, 24 Feb 2020 22:36:27 +0000
|
|
Subject: [PATCH 2/3] clutter: avoid g_signal_emit_by_name() from ClutterActor
|
|
|
|
g_signal_emit_by_name() is used to emit signals on ClutterContainer when
|
|
actors are removed or added. It happens to do various interface lookups
|
|
which are a bit unneccessary and can allocate memory.
|
|
|
|
Simply using emission wrappers makes all of that go away.
|
|
|
|
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1083
|
|
---
|
|
clutter/clutter/cally/cally-actor.c | 5 +--
|
|
clutter/clutter/clutter-actor.c | 17 ++++++++--
|
|
clutter/clutter/clutter-actor.h | 5 ++-
|
|
clutter/clutter/clutter-container-private.h | 36 +++++++++++++++++++++
|
|
clutter/clutter/clutter-container.c | 21 ++++++++++++
|
|
5 files changed, 78 insertions(+), 6 deletions(-)
|
|
create mode 100644 clutter/clutter/clutter-container-private.h
|
|
|
|
diff --git a/clutter/clutter/cally/cally-actor.c b/clutter/clutter/cally/cally-actor.c
|
|
index 548615f48..517969625 100644
|
|
--- a/clutter/clutter/cally/cally-actor.c
|
|
+++ b/clutter/clutter/cally/cally-actor.c
|
|
@@ -604,10 +604,11 @@ cally_actor_real_remove_actor (ClutterActor *container,
|
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), 0);
|
|
|
|
atk_parent = ATK_OBJECT (data);
|
|
- atk_child = clutter_actor_get_accessible (actor);
|
|
|
|
- if (atk_child)
|
|
+ if (clutter_actor_has_accessible (actor))
|
|
{
|
|
+ atk_child = clutter_actor_get_accessible (actor);
|
|
+
|
|
g_value_init (&values.old_value, G_TYPE_POINTER);
|
|
g_value_set_pointer (&values.old_value, atk_parent);
|
|
|
|
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
|
|
index 803f76aae..93d0a93ef 100644
|
|
--- a/clutter/clutter/clutter-actor.c
|
|
+++ b/clutter/clutter/clutter-actor.c
|
|
@@ -624,7 +624,7 @@
|
|
#include "clutter-color-static.h"
|
|
#include "clutter-color.h"
|
|
#include "clutter-constraint-private.h"
|
|
-#include "clutter-container.h"
|
|
+#include "clutter-container-private.h"
|
|
#include "clutter-content-private.h"
|
|
#include "clutter-debug.h"
|
|
#include "clutter-easing.h"
|
|
@@ -4372,7 +4372,7 @@ clutter_actor_remove_child_internal (ClutterActor *self,
|
|
|
|
/* we need to emit the signal before dropping the reference */
|
|
if (emit_actor_removed)
|
|
- g_signal_emit_by_name (self, "actor-removed", child);
|
|
+ _clutter_container_emit_actor_removed (CLUTTER_CONTAINER (self), child);
|
|
|
|
if (notify_first_last)
|
|
{
|
|
@@ -13060,7 +13060,7 @@ clutter_actor_add_child_internal (ClutterActor *self,
|
|
}
|
|
|
|
if (emit_actor_added)
|
|
- g_signal_emit_by_name (self, "actor-added", child);
|
|
+ _clutter_container_emit_actor_added (CLUTTER_CONTAINER (self), child);
|
|
|
|
if (notify_first_last)
|
|
{
|
|
@@ -21448,3 +21448,14 @@ clutter_actor_create_texture_paint_node (ClutterActor *self,
|
|
|
|
return node;
|
|
}
|
|
+
|
|
+gboolean
|
|
+clutter_actor_has_accessible (ClutterActor *actor)
|
|
+{
|
|
+ g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), FALSE);
|
|
+
|
|
+ if (CLUTTER_ACTOR_GET_CLASS (actor)->has_accessible)
|
|
+ return CLUTTER_ACTOR_GET_CLASS (actor)->has_accessible (actor);
|
|
+
|
|
+ return TRUE;
|
|
+}
|
|
diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h
|
|
index 7d2168af1..d286f2843 100644
|
|
--- a/clutter/clutter/clutter-actor.h
|
|
+++ b/clutter/clutter/clutter-actor.h
|
|
@@ -296,10 +296,11 @@ struct _ClutterActorClass
|
|
|
|
gboolean (* touch_event) (ClutterActor *self,
|
|
ClutterTouchEvent *event);
|
|
+ gboolean (* has_accessible) (ClutterActor *self);
|
|
|
|
/*< private >*/
|
|
/* padding for future expansion */
|
|
- gpointer _padding_dummy[26];
|
|
+ gpointer _padding_dummy[25];
|
|
};
|
|
|
|
/**
|
|
@@ -369,6 +370,8 @@ CLUTTER_EXPORT
|
|
const gchar * clutter_actor_get_name (ClutterActor *self);
|
|
CLUTTER_EXPORT
|
|
AtkObject * clutter_actor_get_accessible (ClutterActor *self);
|
|
+CLUTTER_EXPORT
|
|
+gboolean clutter_actor_has_accessible (ClutterActor *self);
|
|
|
|
CLUTTER_EXPORT
|
|
gboolean clutter_actor_is_visible (ClutterActor *self);
|
|
diff --git a/clutter/clutter/clutter-container-private.h b/clutter/clutter/clutter-container-private.h
|
|
new file mode 100644
|
|
index 000000000..d619a6531
|
|
--- /dev/null
|
|
+++ b/clutter/clutter/clutter-container-private.h
|
|
@@ -0,0 +1,36 @@
|
|
+/*
|
|
+ * Clutter.
|
|
+ *
|
|
+ * An OpenGL based 'interactive canvas' library.
|
|
+ *
|
|
+ * Copyright 2020 Red Hat, Inc.
|
|
+ *
|
|
+ * This library is free software; you can redistribute it and/or
|
|
+ * modify it under the terms of the GNU Lesser General Public
|
|
+ * License as published by the Free Software Foundation; either
|
|
+ * version 2 of the License, or (at your option) any later version.
|
|
+ *
|
|
+ * This library is distributed in the hope that it will be useful,
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
+ * Lesser General Public License for more details.
|
|
+ *
|
|
+ * You should have received a copy of the GNU Lesser General Public
|
|
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
+ */
|
|
+
|
|
+#ifndef __CLUTTER_CONTAINER_PRIVATE_H__
|
|
+#define __CLUTTER_CONTAINER_PRIVATE_H__
|
|
+
|
|
+#include <clutter/clutter-container.h>
|
|
+
|
|
+G_BEGIN_DECLS
|
|
+
|
|
+void _clutter_container_emit_actor_added (ClutterContainer *container,
|
|
+ ClutterActor *actor);
|
|
+void _clutter_container_emit_actor_removed (ClutterContainer *container,
|
|
+ ClutterActor *actor);
|
|
+
|
|
+G_END_DECLS
|
|
+
|
|
+#endif /* __CLUTTER_CONTAINER_PRIVATE_H__ */
|
|
diff --git a/clutter/clutter/clutter-container.c b/clutter/clutter/clutter-container.c
|
|
index 0f611ae55..79abb5b4f 100644
|
|
--- a/clutter/clutter/clutter-container.c
|
|
+++ b/clutter/clutter/clutter-container.c
|
|
@@ -37,6 +37,7 @@
|
|
|
|
#include "clutter-actor-private.h"
|
|
#include "clutter-child-meta.h"
|
|
+#include "clutter-container-private.h"
|
|
#include "clutter-debug.h"
|
|
#include "clutter-main.h"
|
|
#include "clutter-marshal.h"
|
|
@@ -1446,3 +1447,23 @@ clutter_container_child_notify (ClutterContainer *container,
|
|
child,
|
|
pspec);
|
|
}
|
|
+
|
|
+void
|
|
+_clutter_container_emit_actor_added (ClutterContainer *container,
|
|
+ ClutterActor *actor)
|
|
+{
|
|
+ g_return_if_fail (CLUTTER_IS_CONTAINER (container));
|
|
+ g_return_if_fail (CLUTTER_IS_ACTOR (actor));
|
|
+
|
|
+ g_signal_emit (container, container_signals[ACTOR_ADDED], 0, actor);
|
|
+}
|
|
+
|
|
+void
|
|
+_clutter_container_emit_actor_removed (ClutterContainer *container,
|
|
+ ClutterActor *actor)
|
|
+{
|
|
+ g_return_if_fail (CLUTTER_IS_CONTAINER (container));
|
|
+ g_return_if_fail (CLUTTER_IS_ACTOR (actor));
|
|
+
|
|
+ g_signal_emit (container, container_signals[ACTOR_REMOVED], 0, actor);
|
|
+}
|
|
--
|
|
2.26.0
|
|
|