Revert "picking: Fix tracking of pick buffer validity"

This reverts commit d7e86e26960f4cb2f5f0600357f5df89bd1c46c1.

This was a half baked patch that was pushed a bit early since it broke
test-texture-pick-with-alpha + the commit message refers to a change on
the wip/paint-box branch that hasn't happened yet.
This commit is contained in:
Robert Bragg 2010-09-23 11:35:42 +01:00
parent d7e86e2696
commit b2a56c9cda
4 changed files with 25 additions and 59 deletions

View File

@ -1780,6 +1780,7 @@ clutter_actor_real_queue_redraw (ClutterActor *self,
ClutterActor *origin) ClutterActor *origin)
{ {
ClutterActor *parent; ClutterActor *parent;
ClutterMainContext *context;
CLUTTER_NOTE (PAINT, "Redraw queued on '%s' (from: '%s')", CLUTTER_NOTE (PAINT, "Redraw queued on '%s' (from: '%s')",
get_actor_debug_name (self), get_actor_debug_name (self),
@ -1797,6 +1798,17 @@ clutter_actor_real_queue_redraw (ClutterActor *self,
if (!CLUTTER_ACTOR_IS_VISIBLE (self)) if (!CLUTTER_ACTOR_IS_VISIBLE (self))
return; return;
/* We have an optimization in _clutter_do_pick to detect when the scene is
* static so we can cache a full, un-clipped pick buffer to avoid continuous
* pick renders.
*
* Currently the assumption is that actors queue a redraw when some state
* changes that affects painting *or* picking so we can use this point
* to invalidate any currently cached pick buffer.
*/
context = _clutter_context_get_default ();
context->have_complete_pick_buffer = FALSE;
/* Although we could determine here that a full stage redraw /* Although we could determine here that a full stage redraw
* has already been queued and immediately bail out, we actually * has already been queued and immediately bail out, we actually
* guarantee that we will propagate a queue-redraw signal to our * guarantee that we will propagate a queue-redraw signal to our

View File

@ -274,8 +274,12 @@ _clutter_do_redraw (ClutterStage *stage)
ctx = _clutter_context_get_default (); ctx = _clutter_context_get_default ();
_clutter_stage_set_pick_buffer_valid (stage, FALSE); /* We have an optimization to avoid pick renders while scene is static.
_clutter_stage_unset_pick_counter (stage); * This is implied by seeing multiple picks per frame so we have to
* reset a pick counter each frame and also invalidate any current pick
* buffer. */
ctx->picks_per_frame = 0;
ctx->have_complete_pick_buffer = FALSE;
/* Before we can paint, we have to be sure we have the latest layout */ /* Before we can paint, we have to be sure we have the latest layout */
_clutter_stage_maybe_relayout (CLUTTER_ACTOR (stage)); _clutter_stage_maybe_relayout (CLUTTER_ACTOR (stage));
@ -597,7 +601,7 @@ _clutter_do_pick (ClutterStage *stage,
/* It's possible that we currently have a static scene and have renderered a /* It's possible that we currently have a static scene and have renderered a
* full, unclipped pick buffer. If so we can simply continue to read from * full, unclipped pick buffer. If so we can simply continue to read from
* this cached buffer until the scene next changes. */ * this cached buffer until the scene next changes. */
if (_clutter_stage_get_pick_buffer_valid (stage)) if (context->have_complete_pick_buffer)
{ {
CLUTTER_TIMER_START (_clutter_uprof_context, pick_read); CLUTTER_TIMER_START (_clutter_uprof_context, pick_read);
cogl_read_pixels (x, y, 1, 1, cogl_read_pixels (x, y, 1, 1,
@ -624,7 +628,7 @@ _clutter_do_pick (ClutterStage *stage,
goto result; goto result;
} }
_clutter_stage_increment_pick_counter (stage); context->picks_per_frame++;
_clutter_backend_ensure_context (context->backend, stage); _clutter_backend_ensure_context (context->backend, stage);
@ -634,7 +638,7 @@ _clutter_do_pick (ClutterStage *stage,
/* If we are seeing multiple picks per frame that means the scene is static /* If we are seeing multiple picks per frame that means the scene is static
* so we promote to doing a non-scissored pick render so that all subsequent * so we promote to doing a non-scissored pick render so that all subsequent
* picks for the same static scene won't require additional renders */ * picks for the same static scene won't require additional renders */
if (_clutter_stage_get_pick_counter (stage) < 2) if (context->picks_per_frame < 2)
{ {
if (G_LIKELY (!(clutter_pick_debug_flags & if (G_LIKELY (!(clutter_pick_debug_flags &
CLUTTER_DEBUG_DUMP_PICK_BUFFERS))) CLUTTER_DEBUG_DUMP_PICK_BUFFERS)))
@ -676,7 +680,7 @@ _clutter_do_pick (ClutterStage *stage,
cogl_clip_pop (); cogl_clip_pop ();
} }
else else
_clutter_stage_set_pick_buffer_valid (stage, TRUE); context->have_complete_pick_buffer = TRUE;
/* Make sure Cogl flushes any batched geometry to the GPU driver */ /* Make sure Cogl flushes any batched geometry to the GPU driver */
cogl_flush (); cogl_flush ();

View File

@ -183,6 +183,9 @@ struct _ClutterMainContext
GList *repaint_funcs; GList *repaint_funcs;
ClutterSettings *settings; ClutterSettings *settings;
gint picks_per_frame;
gboolean have_complete_pick_buffer;
}; };
#define CLUTTER_CONTEXT() (_clutter_context_get_default ()) #define CLUTTER_CONTEXT() (_clutter_context_get_default ())
@ -276,13 +279,6 @@ int _clutter_stage_get_pending_swaps (ClutterStage *stage);
gboolean _clutter_stage_has_full_redraw_queued (ClutterStage *stage); gboolean _clutter_stage_has_full_redraw_queued (ClutterStage *stage);
void _clutter_stage_set_pick_buffer_valid (ClutterStage *stage,
gboolean valid);
gboolean _clutter_stage_get_pick_buffer_valid (ClutterStage *stage);
void _clutter_stage_increment_pick_counter (ClutterStage *stage);
void _clutter_stage_unset_pick_counter (ClutterStage *stage);
guint _clutter_stage_get_pick_counter (ClutterStage *stage);
/* vfuncs implemented by backend */ /* vfuncs implemented by backend */
GType _clutter_backend_impl_get_type (void); GType _clutter_backend_impl_get_type (void);

View File

@ -116,8 +116,6 @@ struct _ClutterStagePrivate
ClutterStageHint stage_hints; ClutterStageHint stage_hints;
gint picks_per_frame;
guint redraw_pending : 1; guint redraw_pending : 1;
guint is_fullscreen : 1; guint is_fullscreen : 1;
guint is_cursor_visible : 1; guint is_cursor_visible : 1;
@ -128,7 +126,6 @@ struct _ClutterStagePrivate
guint min_size_changed : 1; guint min_size_changed : 1;
guint dirty_viewport : 1; guint dirty_viewport : 1;
guint dirty_projection : 1; guint dirty_projection : 1;
guint have_valid_pick_buffer : 1;
}; };
enum enum
@ -737,16 +734,6 @@ clutter_stage_real_queue_redraw (ClutterActor *actor,
else else
CLUTTER_CONTEXT ()->redraw_count += 1; CLUTTER_CONTEXT ()->redraw_count += 1;
/* We have an optimization in _clutter_do_pick to detect when the
* scene is static so we can cache a full, un-clipped pick buffer to
* avoid continuous pick renders.
*
* Currently the assumption is that actors queue a redraw when some
* state changes that affects painting *or* picking so we can use
* this point to invalidate any currently cached pick buffer.
*/
_clutter_stage_set_pick_buffer_valid (stage, FALSE);
/* If the backend can't do anything with redraw clips (e.g. it already knows /* If the backend can't do anything with redraw clips (e.g. it already knows
* it needs to redraw everything anyway) then don't spend time transforming * it needs to redraw everything anyway) then don't spend time transforming
* any clip regions into stage coordinates... */ * any clip regions into stage coordinates... */
@ -2942,36 +2929,3 @@ clutter_stage_get_no_clear_hint (ClutterStage *stage)
return (stage->priv->stage_hints & CLUTTER_STAGE_NO_CLEAR_ON_PAINT) != 0; return (stage->priv->stage_hints & CLUTTER_STAGE_NO_CLEAR_ON_PAINT) != 0;
} }
gboolean
_clutter_stage_get_pick_buffer_valid (ClutterStage *stage)
{
return stage->priv->have_valid_pick_buffer;
}
void
_clutter_stage_set_pick_buffer_valid (ClutterStage *stage,
gboolean valid)
{
valid = !!valid;
stage->priv->have_valid_pick_buffer = valid;
}
void
_clutter_stage_increment_pick_counter (ClutterStage *stage)
{
stage->priv->picks_per_frame += 1;
}
void
_clutter_stage_unset_pick_counter (ClutterStage *stage)
{
stage->priv->picks_per_frame = 0;
}
guint
_clutter_stage_get_pick_counter (ClutterStage *stage)
{
return stage->priv->picks_per_frame;
}