[mutter/gbsneto/effects-paint-nodes: 9/16] clutter/effect: Add paint_node vfunc
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/effects-paint-nodes: 9/16] clutter/effect: Add paint_node vfunc
- Date: Tue, 30 Jun 2020 16:53:02 +0000 (UTC)
commit 6bebca66baba0c33a342c299c47d5d4c0615f8ba
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Jun 27 12:12:03 2020 -0300
clutter/effect: Add paint_node vfunc
Introduce a new paint_node vfunc that, if implemented, allows
the effect to add nodes to a transient paint node that is
immediately painted. This is a transitional step until we
have fully delegated paint node rendering.
The most basic implementation of a ClutterEffect.paint_node
vfunc, and also the default implementation, is with an actor
node, as follows:
```
static void
foo_bar_paint_node (ClutterEffect *effect,
ClutterPaintNode *node,
ClutterPaintContext *paint_context,
ClutterEffectPaintFlags flags)
{
g_autoptr (ClutterPaintNode) actor_node = NULL;
actor_node = clutter_actor_node_new (effect->actor);
clutter_paint_node_add_child (node, actor_node);
}
```
This example gives the exact same behavior of simply calling
clutter_actor_continue_paint(). In the future, the paint node
itself will be a parameter of clutter_actor_continue_paint()
and we'll be able to simplify it event more.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1340
clutter/clutter/clutter-effect.c | 30 +++++++++++++++++++++++++++++-
clutter/clutter/clutter-effect.h | 4 ++++
2 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-effect.c b/clutter/clutter/clutter-effect.c
index 399e7b3cca..a4feae8d64 100644
--- a/clutter/clutter/clutter-effect.c
+++ b/clutter/clutter/clutter-effect.c
@@ -169,6 +169,8 @@
#include "clutter-effect-private.h"
#include "clutter-enum-types.h"
#include "clutter-marshal.h"
+#include "clutter-paint-node-private.h"
+#include "clutter-paint-nodes.h"
#include "clutter-private.h"
#include "clutter-actor-private.h"
@@ -196,6 +198,22 @@ clutter_effect_real_modify_paint_volume (ClutterEffect *effect,
return TRUE;
}
+static void
+clutter_effect_real_paint_node (ClutterEffect *effect,
+ ClutterPaintNode *node,
+ ClutterPaintContext *paint_context,
+ ClutterEffectPaintFlags flags)
+{
+ ClutterPaintNode *actor_node;
+ ClutterActor *actor;
+
+ actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
+
+ actor_node = clutter_actor_node_new (actor);
+ clutter_paint_node_add_child (node, actor_node);
+ clutter_paint_node_unref (actor_node);
+}
+
static void
clutter_effect_real_paint (ClutterEffect *effect,
ClutterPaintContext *paint_context,
@@ -203,6 +221,8 @@ clutter_effect_real_paint (ClutterEffect *effect,
{
ClutterEffectClass *effect_class = CLUTTER_EFFECT_GET_CLASS (effect);
ClutterActorMeta *actor_meta = CLUTTER_ACTOR_META (effect);
+ ClutterPaintNode *node;
+ CoglFramebuffer *framebuffer;
ClutterActor *actor;
gboolean pre_paint_succeeded;
@@ -213,10 +233,17 @@ clutter_effect_real_paint (ClutterEffect *effect,
pre_paint_succeeded = effect_class->pre_paint (effect, paint_context);
actor = clutter_actor_meta_get_actor (actor_meta);
- clutter_actor_continue_paint (actor, paint_context);
+ framebuffer = clutter_paint_context_get_framebuffer (paint_context);
+ node = _clutter_dummy_node_new (actor, framebuffer);
+
+ effect_class->paint_node (effect, node, paint_context, flags);
+
+ clutter_paint_node_paint (node, paint_context);
if (pre_paint_succeeded)
effect_class->post_paint (effect, paint_context);
+
+ clutter_paint_node_unref (node);
}
static void
@@ -256,6 +283,7 @@ clutter_effect_class_init (ClutterEffectClass *klass)
klass->post_paint = clutter_effect_real_post_paint;
klass->modify_paint_volume = clutter_effect_real_modify_paint_volume;
klass->paint = clutter_effect_real_paint;
+ klass->paint_node = clutter_effect_real_paint_node;
klass->pick = clutter_effect_real_pick;
}
diff --git a/clutter/clutter/clutter-effect.h b/clutter/clutter/clutter-effect.h
index 8e8b57b92f..d15015cf9e 100644
--- a/clutter/clutter/clutter-effect.h
+++ b/clutter/clutter/clutter-effect.h
@@ -87,6 +87,10 @@ struct _ClutterEffectClass
void (* paint) (ClutterEffect *effect,
ClutterPaintContext *paint_context,
ClutterEffectPaintFlags flags);
+ void (* paint_node) (ClutterEffect *effect,
+ ClutterPaintNode *node,
+ ClutterPaintContext *paint_context,
+ ClutterEffectPaintFlags flags);
void (* pick) (ClutterEffect *effect,
ClutterPickContext *pick_context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]