[mutter/gbsneto/pick-culling: 12/16] clutter/stage: Remove cached pick mode




commit 5dd173ba04cb23a18b4fc1affaa03ef002c1b3a4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Oct 22 19:34:51 2020 -0300

    clutter/stage: Remove cached pick mode
    
    The cached pick mode never actually cached anything, since it is
    always, unconditionally reset when painting. Furthermore, next
    commits will cull out actors during pick, which makes the pick
    stack uncacheable.
    
    Remove the cached pick mode.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520

 clutter/clutter/clutter-stage.c | 52 ++++++-----------------------------------
 1 file changed, 7 insertions(+), 45 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index c3c20936d4..55ae6423ed 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -125,9 +125,6 @@ struct _ClutterStagePrivate
   GTimer *fps_timer;
   gint32 timer_n_frames;
 
-  ClutterPickStack *pick_stack;
-  ClutterPickMode cached_pick_mode;
-
   ClutterStageState current_state;
 
   int update_freeze_count;
@@ -229,15 +226,6 @@ clutter_stage_get_preferred_height (ClutterActor *self,
     *natural_height_p = geom.height;
 }
 
-static void
-_clutter_stage_clear_pick_stack (ClutterStage *stage)
-{
-  ClutterStagePrivate *priv = stage->priv;
-
-  g_clear_pointer (&priv->pick_stack, clutter_pick_stack_unref);
-  priv->cached_pick_mode = CLUTTER_PICK_NONE;
-}
-
 static void
 clutter_stage_add_redraw_clip (ClutterStage          *stage,
                                cairo_rectangle_int_t *clip)
@@ -458,19 +446,12 @@ clutter_stage_do_paint_view (ClutterStage         *stage,
                              ClutterStageView     *view,
                              const cairo_region_t *redraw_clip)
 {
-  ClutterStagePrivate *priv = stage->priv;
   ClutterPaintContext *paint_context;
   cairo_rectangle_int_t clip_rect;
   g_autoptr (GArray) clip_frusta = NULL;
   graphene_frustum_t clip_frustum;
   int n_rectangles;
 
-  /* Any mode of painting/picking invalidates the pick cache, unless we're
-   * in the middle of building it. So we reset the cached flag but don't
-   * completely clear the pick stack.
-   */
-  priv->cached_pick_mode = CLUTTER_PICK_NONE;
-
   n_rectangles = redraw_clip ? cairo_region_num_rectangles (redraw_clip) : 0;
   if (redraw_clip && n_rectangles < MAX_FRUSTA)
     {
@@ -633,7 +614,6 @@ clutter_stage_hide (ClutterActor *self)
   ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
 
   g_assert (priv->impl != NULL);
-  _clutter_stage_clear_pick_stack (CLUTTER_STAGE (self));
   _clutter_stage_window_hide (priv->impl);
 
   CLUTTER_ACTOR_CLASS (clutter_stage_parent_class)->hide (self);
@@ -1163,31 +1143,23 @@ _clutter_stage_do_pick_on_view (ClutterStage     *stage,
                                 ClutterPickMode   mode,
                                 ClutterStageView *view)
 {
-  ClutterStagePrivate *priv = stage->priv;
+  g_autoptr (ClutterPickStack) pick_stack = NULL;
+  ClutterPickContext *pick_context;
   graphene_point3d_t p;
   graphene_ray_t ray;
   ClutterActor *actor;
 
   COGL_TRACE_BEGIN_SCOPED (ClutterStagePickView, "Pick (view)");
 
-  if (!priv->pick_stack || mode != priv->cached_pick_mode)
-    {
-      ClutterPickContext *pick_context;
-
-      _clutter_stage_clear_pick_stack (stage);
-
-      pick_context = clutter_pick_context_new_for_view (view, mode);
-
-      clutter_actor_pick (CLUTTER_ACTOR (stage), pick_context);
-      priv->pick_stack = clutter_pick_context_steal_stack (pick_context);
-      priv->cached_pick_mode = mode;
+  pick_context = clutter_pick_context_new_for_view (view, mode);
 
-      clutter_pick_context_destroy (pick_context);
-    }
+  clutter_actor_pick (CLUTTER_ACTOR (stage), pick_context);
+  pick_stack = clutter_pick_context_steal_stack (pick_context);
+  clutter_pick_context_destroy (pick_context);
 
   setup_ray_for_coordinates (stage, x, y, &p, &ray);
 
-  actor = clutter_pick_stack_search_actor (priv->pick_stack, &p, &ray);
+  actor = clutter_pick_stack_search_actor (pick_stack, &p, &ray);
   return actor ? actor : CLUTTER_ACTOR (stage);
 }
 
@@ -1399,8 +1371,6 @@ clutter_stage_finalize (GObject *object)
 
   g_array_free (priv->paint_volume_stack, TRUE);
 
-  _clutter_stage_clear_pick_stack (stage);
-
   if (priv->fps_timer != NULL)
     g_timer_destroy (priv->fps_timer);
 
@@ -1714,8 +1684,6 @@ clutter_stage_init (ClutterStage *self)
 
   priv->paint_volume_stack =
     g_array_new (FALSE, FALSE, sizeof (ClutterPaintVolume));
-
-  priv->cached_pick_mode = CLUTTER_PICK_NONE;
 }
 
 static void
@@ -2788,12 +2756,6 @@ _clutter_stage_queue_actor_redraw (ClutterStage                 *stage,
   CLUTTER_NOTE (CLIPPING, "stage_queue_actor_redraw (actor=%s, clip=%p): ",
                 _clutter_actor_get_debug_name (actor), clip);
 
-  /* Queuing a redraw or clip change invalidates the pick cache, unless we're
-   * in the middle of building it. So we reset the cached flag but don't
-   * completely clear the pick stack...
-   */
-  priv->cached_pick_mode = CLUTTER_PICK_NONE;
-
   if (!priv->pending_finish_queue_redraws)
     {
       GList *l;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]