clutter-effect: Add clutter_effect_queue_rerun
This adds a new public function to queue a rerun of an effect. If nothing else queues a redraw then when the effect's actor is painted the effect will be run without the CLUTTER_EFFECT_RUN_ACTOR_DIRTY flag. This allows parametrised offscreen effects to report that they need to redraw the image without having to redraw the underlying actor. This will be used to implement the 'transparency' effect of ClutterActor. If multiple redraws are queued with different effects then redrawing is started from the one that occurs last in the list of effects. Internally the function is a wrapper around the new function _clutter_actor_queue_redraw_full. This is intended to be the sole point of code for queuing redraws on an actor. It has parameters for the clip and the effect. The other two existing functions to queue a redraw (one with a clip and one without) now wrap around this function by passing a NULL effect.
This commit is contained in:
@ -203,6 +203,7 @@
|
||||
#include "clutter-enum-types.h"
|
||||
#include "clutter-marshal.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-actor-private.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (ClutterEffect,
|
||||
clutter_effect,
|
||||
@ -316,3 +317,62 @@ _clutter_effect_get_paint_volume (ClutterEffect *effect,
|
||||
|
||||
return CLUTTER_EFFECT_GET_CLASS (effect)->get_paint_volume (effect, volume);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_effect_queue_rerun:
|
||||
* @effect: A #ClutterEffect which needs redrawing
|
||||
*
|
||||
* Queues a rerun of the effect. The effect can detect when the ‘run’
|
||||
* method is called as a result of this function because it will not
|
||||
* have the %CLUTTER_EFFECT_RUN_ACTOR_DIRTY flag set. In that case the
|
||||
* effect is free to assume that the actor has not changed its
|
||||
* appearance since the last time it was painted so it doesn't need to
|
||||
* call clutter_actor_continue_paint() if it can draw a cached
|
||||
* image. This is mostly intended for effects that are using a
|
||||
* %CoglOffscreen to redirect the actor (such as
|
||||
* %ClutterOffscreenEffect). In that case the effect can save a bit of
|
||||
* rendering time by painting the cached texture without causing the
|
||||
* entire actor to be painted.
|
||||
*
|
||||
* This function can be used by effects that have their own animatable
|
||||
* parameters. For example, an effect which adds a varying degree of a
|
||||
* red tint to an actor by redirecting it through a CoglOffscreen
|
||||
* might have a property to specify the level of tint. When this value
|
||||
* changes, the underlying actor doesn't need to be redrawn so the
|
||||
* effect can call clutter_effect_queue_rerun() to make sure the
|
||||
* effect is repainted.
|
||||
*
|
||||
* Note however that modifying the position of the parent of an actor
|
||||
* may change the appearance of the actor because its transformation
|
||||
* matrix would change. In this case a redraw wouldn't be queued on
|
||||
* the actor itself so the %CLUTTER_EFFECT_RUN_ACTOR_DIRTY would still
|
||||
* not be set. The effect can detect this case by keeping track of the
|
||||
* last modelview matrix that was used to render the actor and
|
||||
* veryifying that it remains the same in the next paint.
|
||||
*
|
||||
* Any other effects that are layered on top of the passed in effect
|
||||
* will still be passed the %CLUTTER_EFFECT_RUN_ACTOR_DIRTY flag. If
|
||||
* anything queues a redraw on the actor without specifying an effect
|
||||
* or with an effect that is lower in the chain of effects than this
|
||||
* one then that will override this call. In that case this effect
|
||||
* will instead be called with the %CLUTTER_EFFECT_RUN_ACTOR_DIRTY
|
||||
* flag set.
|
||||
*
|
||||
* Since: 1.8
|
||||
*/
|
||||
void
|
||||
clutter_effect_queue_rerun (ClutterEffect *effect)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_EFFECT (effect));
|
||||
|
||||
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
|
||||
|
||||
/* If the effect has no actor then nothing needs to be done */
|
||||
if (actor != NULL)
|
||||
_clutter_actor_queue_redraw_full (actor,
|
||||
0, /* flags */
|
||||
NULL, /* clip volume */
|
||||
effect /* effect */);
|
||||
}
|
||||
|
Reference in New Issue
Block a user