mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 00:50:42 -05:00
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
This commit is contained in:
parent
e8f9d093b1
commit
35af306acc
@ -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,14 +198,29 @@ 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,
|
||||
ClutterEffectPaintFlags flags)
|
||||
{
|
||||
ClutterEffectClass *effect_class = CLUTTER_EFFECT_GET_CLASS (effect);
|
||||
ClutterActorMeta *actor_meta = CLUTTER_ACTOR_META (effect);
|
||||
ClutterActor *actor;
|
||||
ClutterPaintNode *node;
|
||||
gboolean pre_paint_succeeded;
|
||||
|
||||
/* The default implementation provides a compatibility wrapper for
|
||||
@ -212,11 +229,15 @@ 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);
|
||||
node = clutter_effect_node_new (effect);
|
||||
|
||||
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 +277,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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user