[mutter/gbsneto/window-screencast-fixes: 13/14] clutter/actor: Add culling inhibiting API
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/window-screencast-fixes: 13/14] clutter/actor: Add culling inhibiting API
- Date: Fri, 27 Mar 2020 18:10:47 +0000 (UTC)
commit 8dd3872854720a5406172e86b037f94deb105430
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Mar 18 21:12:26 2020 -0300
clutter/actor: Add culling inhibiting API
This will allow us to continue painting actors that are
outside the visible boundaries of the stage view.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
clutter/clutter/clutter-actor.c | 62 ++++++++++++++++++++++++++++++++++++++++-
clutter/clutter/clutter-actor.h | 5 ++++
2 files changed, 66 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 2841be091..088dd0f4b 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -710,6 +710,7 @@ struct _ClutterActorPrivate
guint8 opacity;
gint opacity_override;
+ unsigned int inhibit_culling_counter;
ClutterOffscreenRedirect offscreen_redirect;
@@ -3951,6 +3952,7 @@ clutter_actor_paint (ClutterActor *self,
g_autoptr (ClutterPaintNode) root_node = NULL;
ClutterActorPrivate *priv;
ClutterActorBox clip;
+ gboolean culling_inhibited;
gboolean clip_set = FALSE;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
@@ -4099,7 +4101,8 @@ clutter_actor_paint (ClutterActor *self,
* paint then the last-paint-volume would likely represent the new
* actor position not the old.
*/
- if (!in_clone_paint ())
+ culling_inhibited = priv->inhibit_culling_counter > 0;
+ if (!culling_inhibited && !in_clone_paint ())
{
gboolean success;
/* annoyingly gcc warns if uninitialized even though
@@ -16002,6 +16005,63 @@ clutter_actor_get_opacity_override (ClutterActor *self)
return self->priv->opacity_override;
}
+/**
+ * clutter_actor_inhibit_culling:
+ * @actor: a #ClutterActor
+ *
+ * Increases the culling inhibitor counter. Inhibiting culling
+ * forces the actor to be painted even when outside the visible
+ * bounds of the stage view.
+ *
+ * This is usually necessary when an actor is being painted on
+ * another paint context.
+ *
+ * Pair with clutter_actor_inhibit_culling() when the actor doesn't
+ * need to be painted anymore.
+ */
+void
+clutter_actor_inhibit_culling (ClutterActor *actor)
+{
+ ClutterActorPrivate *priv;
+
+ g_return_if_fail (CLUTTER_IS_ACTOR (actor));
+
+ priv = actor->priv;
+
+ priv->inhibit_culling_counter++;
+ _clutter_actor_set_enable_paint_unmapped (actor, TRUE);
+}
+
+/**
+ * clutter_actor_uninhibit_culling:
+ * @actor: a #ClutterActor
+ *
+ * Decreases the culling inhibitor counter. See clutter_actor_inhibit_culling()
+ * for when inhibit culling is necessary.
+ *
+ * Calling this function without a matching call to
+ * clutter_actor_inhibit_culling() is a programming error.
+ */
+void
+clutter_actor_uninhibit_culling (ClutterActor *actor)
+{
+ ClutterActorPrivate *priv;
+
+ g_return_if_fail (CLUTTER_IS_ACTOR (actor));
+
+ priv = actor->priv;
+
+ if (priv->inhibit_culling_counter == 0)
+ {
+ g_critical ("Unpaired call to clutter_actor_uninhibit_culling");
+ return;
+ }
+
+ priv->inhibit_culling_counter--;
+ if (priv->inhibit_culling_counter == 0)
+ _clutter_actor_set_enable_paint_unmapped (actor, FALSE);
+}
+
/* Allows you to disable applying the actors model view transform during
* a paint. Used by ClutterClone. */
void
diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h
index e4f25d985..a4140022e 100644
--- a/clutter/clutter/clutter-actor.h
+++ b/clutter/clutter/clutter-actor.h
@@ -884,6 +884,11 @@ void clutter_actor_set_opacity_override
CLUTTER_EXPORT
gint clutter_actor_get_opacity_override (ClutterActor
*self);
+CLUTTER_EXPORT
+void clutter_actor_inhibit_culling (ClutterActor
*actor);
+CLUTTER_EXPORT
+void clutter_actor_uninhibit_culling (ClutterActor
*actor);
+
/**
* ClutterActorCreateChildFunc:
* @item: (type GObject): the item in the model
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]