[mutter/gbsneto/effects-paint-nodes: 100/105] clutter/paint-nodes: Add opacity overriding to ClutterActorNode
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/effects-paint-nodes: 100/105] clutter/paint-nodes: Add opacity overriding to ClutterActorNode
- Date: Fri, 14 Aug 2020 16:04:19 +0000 (UTC)
commit 0caca4fc49f6366e4060de3dd2a6eee9e0d904a6
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].
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 32e485c6c4..6a6a819bd1 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -3746,7 +3746,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 33664fabc5..4fa88efb80 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 f39336c015..09b50153c4 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 235f4bc456..c950899c5d 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]