clutter/actor: Remove pick code from paint

Now that they are properly split, remove the pick
code from paint paths.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/865
This commit is contained in:
Georges Basile Stavracas Neto 2019-10-17 17:08:19 +02:00
parent 86a5358812
commit db8fcc0537

View File

@ -3877,7 +3877,6 @@ void
clutter_actor_paint (ClutterActor *self) clutter_actor_paint (ClutterActor *self)
{ {
ClutterActorPrivate *priv; ClutterActorPrivate *priv;
ClutterPickMode pick_mode;
ClutterActorBox clip; ClutterActorBox clip;
gboolean clip_set = FALSE; gboolean clip_set = FALSE;
ClutterStage *stage; ClutterStage *stage;
@ -3888,16 +3887,11 @@ clutter_actor_paint (ClutterActor *self)
return; return;
priv = self->priv; priv = self->priv;
priv->propagated_one_redraw = FALSE;
pick_mode = _clutter_context_get_pick_mode ();
if (pick_mode == CLUTTER_PICK_NONE)
priv->propagated_one_redraw = FALSE;
/* It's an important optimization that we consider painting of /* It's an important optimization that we consider painting of
* actors with 0 opacity to be a NOP... */ * actors with 0 opacity to be a NOP... */
if (pick_mode == CLUTTER_PICK_NONE && if (/* ignore top-levels, since they might be transparent */
/* ignore top-levels, since they might be transparent */
!CLUTTER_ACTOR_IS_TOPLEVEL (self) && !CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
/* Use the override opacity if its been set */ /* Use the override opacity if its been set */
((priv->opacity_override >= 0) ? ((priv->opacity_override >= 0) ?
@ -3989,31 +3983,21 @@ clutter_actor_paint (ClutterActor *self)
if (clip_set) if (clip_set)
{ {
if (pick_mode == CLUTTER_PICK_NONE) CoglFramebuffer *fb = _clutter_stage_get_active_framebuffer (stage);
{
CoglFramebuffer *fb = _clutter_stage_get_active_framebuffer (stage);
cogl_framebuffer_push_rectangle_clip (fb, cogl_framebuffer_push_rectangle_clip (fb,
clip.x1, clip.x1,
clip.y1, clip.y1,
clip.x2, clip.x2,
clip.y2); clip.y2);
}
else
{
if (!_clutter_actor_push_pick_clip (self, &clip))
clip_set = FALSE;
}
} }
if (pick_mode == CLUTTER_PICK_NONE) /* We check whether we need to add the flatten effect before
{ * each paint so that we can avoid having a mechanism for
/* We check whether we need to add the flatten effect before * applications to notify when the value of the
each paint so that we can avoid having a mechanism for * has_overlaps virtual changes.
applications to notify when the value of the */
has_overlaps virtual changes. */ add_or_remove_flatten_effect (self);
add_or_remove_flatten_effect (self);
}
/* We save the current paint volume so that the next time the /* We save the current paint volume so that the next time the
* actor queues a redraw we can constrain the redraw to just * actor queues a redraw we can constrain the redraw to just
@ -4042,7 +4026,7 @@ clutter_actor_paint (ClutterActor *self)
* paint then the last-paint-volume would likely represent the new * paint then the last-paint-volume would likely represent the new
* actor position not the old. * actor position not the old.
*/ */
if (!in_clone_paint () && pick_mode == CLUTTER_PICK_NONE) if (!in_clone_paint ())
{ {
gboolean success; gboolean success;
/* annoyingly gcc warns if uninitialized even though /* annoyingly gcc warns if uninitialized even though
@ -4072,28 +4056,19 @@ clutter_actor_paint (ClutterActor *self)
clutter_actor_continue_paint (self); clutter_actor_continue_paint (self);
if (G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_VOLUMES && if (G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_VOLUMES))
pick_mode == CLUTTER_PICK_NONE))
_clutter_actor_draw_paint_volume (self); _clutter_actor_draw_paint_volume (self);
/* If we make it here then the actor has run through a complete /* If we make it here then the actor has run through a complete
paint run including all the effects so it's no longer dirty */ paint run including all the effects so it's no longer dirty */
if (pick_mode == CLUTTER_PICK_NONE) priv->is_dirty = FALSE;
priv->is_dirty = FALSE;
done: done:
if (clip_set) if (clip_set)
{ {
if (pick_mode == CLUTTER_PICK_NONE) CoglFramebuffer *fb = _clutter_stage_get_active_framebuffer (stage);
{
CoglFramebuffer *fb = _clutter_stage_get_active_framebuffer (stage);
cogl_framebuffer_pop_clip (fb); cogl_framebuffer_pop_clip (fb);
}
else
{
_clutter_actor_pop_pick_clip (self);
}
} }
cogl_pop_matrix (); cogl_pop_matrix ();
@ -4135,43 +4110,28 @@ clutter_actor_continue_paint (ClutterActor *self)
actual actor */ actual actor */
if (priv->next_effect_to_paint == NULL) if (priv->next_effect_to_paint == NULL)
{ {
if (_clutter_context_get_pick_mode () == CLUTTER_PICK_NONE) ClutterPaintNode *dummy;
{
ClutterPaintNode *dummy;
/* XXX - this will go away in 2.0, when we can get rid of this /* XXX - this will go away in 2.0, when we can get rid of this
* stuff and switch to a pure retained render tree of PaintNodes * stuff and switch to a pure retained render tree of PaintNodes
* for the entire frame, starting from the Stage; the paint() * for the entire frame, starting from the Stage; the paint()
* virtual function can then be called directly. * virtual function can then be called directly.
*/ */
dummy = _clutter_dummy_node_new (self); dummy = _clutter_dummy_node_new (self);
clutter_paint_node_set_name (dummy, "Root"); clutter_paint_node_set_name (dummy, "Root");
/* XXX - for 1.12, we use the return value of paint_node() to /* XXX - for 1.12, we use the return value of paint_node() to
* decide whether we should emit the ::paint signal. * decide whether we should emit the ::paint signal.
*/ */
clutter_actor_paint_node (self, dummy); clutter_actor_paint_node (self, dummy);
clutter_paint_node_unref (dummy); clutter_paint_node_unref (dummy);
/* XXX:2.0 - Call the paint() virtual directly */ /* XXX:2.0 - Call the paint() virtual directly */
if (g_signal_has_handler_pending (self, actor_signals[PAINT], if (g_signal_has_handler_pending (self, actor_signals[PAINT],
0, TRUE)) 0, TRUE))
g_signal_emit (self, actor_signals[PAINT], 0); g_signal_emit (self, actor_signals[PAINT], 0);
else
CLUTTER_ACTOR_GET_CLASS (self)->paint (self);
}
else else
{ CLUTTER_ACTOR_GET_CLASS (self)->paint (self);
/* The actor will log a silhouette of itself to the stage pick log.
*
* XXX:2.0 - Call the pick() virtual directly
*/
if (g_signal_has_handler_pending (self, actor_signals[PICK],
0, TRUE))
g_signal_emit (self, actor_signals[PICK], 0);
else
CLUTTER_ACTOR_GET_CLASS (self)->pick (self);
}
} }
else else
{ {
@ -4185,31 +4145,20 @@ clutter_actor_continue_paint (ClutterActor *self)
priv->current_effect = priv->next_effect_to_paint->data; priv->current_effect = priv->next_effect_to_paint->data;
priv->next_effect_to_paint = priv->next_effect_to_paint->next; priv->next_effect_to_paint = priv->next_effect_to_paint->next;
if (_clutter_context_get_pick_mode () == CLUTTER_PICK_NONE) if (priv->is_dirty)
{ {
if (priv->is_dirty) /* If there's an effect queued with this redraw then all
{ * effects up to that one will be considered dirty. It
/* If there's an effect queued with this redraw then all * is expected the queued effect will paint the cached
effects up to that one will be considered dirty. It * image and not call clutter_actor_continue_paint again
is expected the queued effect will paint the cached * (although it should work ok if it does)
image and not call clutter_actor_continue_paint again */
(although it should work ok if it does) */ if (priv->effect_to_redraw == NULL ||
if (priv->effect_to_redraw == NULL || priv->current_effect != priv->effect_to_redraw)
priv->current_effect != priv->effect_to_redraw) run_flags |= CLUTTER_EFFECT_PAINT_ACTOR_DIRTY;
run_flags |= CLUTTER_EFFECT_PAINT_ACTOR_DIRTY;
}
_clutter_effect_paint (priv->current_effect, run_flags);
} }
else
{
/* We can't determine when an actor has been modified since
its last pick so lets just assume it has always been
modified */
run_flags |= CLUTTER_EFFECT_PAINT_ACTOR_DIRTY;
_clutter_effect_pick (priv->current_effect, run_flags); _clutter_effect_paint (priv->current_effect, run_flags);
}
priv->current_effect = old_current_effect; priv->current_effect = old_current_effect;
} }