[mutter/gbsneto/effects-paint-nodes: 8/11] clutter/paint-nodes: Add opacity overriding to ClutterActorNode
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/effects-paint-nodes: 8/11] clutter/paint-nodes: Add opacity overriding to ClutterActorNode
- Date: Tue, 8 Dec 2020 15:14:07 +0000 (UTC)
commit 89f9be0dd167c7ffbb028ef0585b24c648aa2f7a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Jul 5 16:27:08 2020 -0300
clutter/paint-nodes: Add opacity overriding to ClutterActorNode
Some effects, such as ShellBlurEffect and ClutterOffscreenEffect, need
to make sure the actor is painted fully opaque. With ClutterActorNode,
however, that is currently not possible.
Add a new 'opacity' parameter to clutter_actor_node_new(). It follows
the opacity override heuristic, where -1 means disable, and anything
else is clamped to [0, 255].
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340>
clutter/clutter/clutter-actor.c | 2 +-
clutter/clutter/clutter-effect.c | 2 +-
clutter/clutter/clutter-paint-nodes.c | 21 ++++++++++++++++++++-
clutter/clutter/clutter-paint-nodes.h | 3 ++-
4 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index c77cd3eef8..f7b31ec4be 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -3669,7 +3669,7 @@ clutter_actor_paint (ClutterActor *self,
if (!CLUTTER_ACTOR_IS_MAPPED (self))
return;
- actor_node = clutter_actor_node_new (self);
+ actor_node = clutter_actor_node_new (self, -1);
root_node = clutter_paint_node_ref (actor_node);
if (priv->has_clip)
diff --git a/clutter/clutter/clutter-effect.c b/clutter/clutter/clutter-effect.c
index 87ca311be7..1df651f200 100644
--- a/clutter/clutter/clutter-effect.c
+++ b/clutter/clutter/clutter-effect.c
@@ -209,7 +209,7 @@ clutter_effect_real_paint_node (ClutterEffect *effect,
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
- actor_node = clutter_actor_node_new (actor);
+ actor_node = clutter_actor_node_new (actor, -1);
clutter_paint_node_add_child (node, actor_node);
clutter_paint_node_unref (actor_node);
}
diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c
index 23a192969a..e709466672 100644
--- a/clutter/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter/clutter-paint-nodes.c
@@ -1115,6 +1115,8 @@ struct _ClutterActorNode
ClutterPaintNode parent_instance;
ClutterActor *actor;
+ int opacity_override;
+ int saved_opacity_override;
};
struct _ClutterActorNodeClass
@@ -1130,6 +1132,14 @@ clutter_actor_node_pre_draw (ClutterPaintNode *node,
{
ClutterActorNode *actor_node = CLUTTER_ACTOR_NODE (node);
+ if (actor_node->opacity_override != -1)
+ {
+ actor_node->saved_opacity_override =
+ clutter_actor_get_opacity_override (actor_node->actor);
+ clutter_actor_set_opacity_override (actor_node->actor,
+ actor_node->opacity_override);
+ }
+
CLUTTER_SET_PRIVATE_FLAGS (actor_node->actor, CLUTTER_IN_PAINT);
return TRUE;
@@ -1151,6 +1161,12 @@ clutter_actor_node_post_draw (ClutterPaintNode *node,
ClutterActorNode *actor_node = CLUTTER_ACTOR_NODE (node);
CLUTTER_UNSET_PRIVATE_FLAGS (actor_node->actor, CLUTTER_IN_PAINT);
+
+ if (actor_node->opacity_override != -1)
+ {
+ clutter_actor_set_opacity_override (actor_node->actor,
+ actor_node->saved_opacity_override);
+ }
}
static JsonNode *
@@ -1192,6 +1208,7 @@ clutter_actor_node_init (ClutterActorNode *self)
/*
* clutter_actor_node_new:
* @actor: the actor to paint
+ * @opacity: opacity to draw the actor with, or -1 to use the actor's opacity
*
* Creates a new #ClutterActorNode.
*
@@ -1203,7 +1220,8 @@ clutter_actor_node_init (ClutterActorNode *self)
* Use clutter_paint_node_unref() when done.
*/
ClutterPaintNode *
-clutter_actor_node_new (ClutterActor *actor)
+clutter_actor_node_new (ClutterActor *actor,
+ int opacity)
{
ClutterActorNode *res;
@@ -1211,6 +1229,7 @@ clutter_actor_node_new (ClutterActor *actor)
res = _clutter_paint_node_create (CLUTTER_TYPE_ACTOR_NODE);
res->actor = actor;
+ res->opacity_override = CLAMP (opacity, -1, 255);
return (ClutterPaintNode *) res;
}
diff --git a/clutter/clutter/clutter-paint-nodes.h b/clutter/clutter/clutter-paint-nodes.h
index 2e81c2b5df..32b56a8d39 100644
--- a/clutter/clutter/clutter-paint-nodes.h
+++ b/clutter/clutter/clutter-paint-nodes.h
@@ -160,7 +160,8 @@ CLUTTER_EXPORT
GType clutter_actor_node_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
-ClutterPaintNode * clutter_actor_node_new (ClutterActor *actor);
+ClutterPaintNode * clutter_actor_node_new (ClutterActor *actor,
+ int opacity);
#define CLUTTER_TYPE_ROOT_NODE (clutter_root_node_get_type ())
#define CLUTTER_ROOT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ROOT_NODE,
ClutterRootNode))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]