[mutter/gbsneto/graphene-frustrum: 9/13] clutter/stage: Move clip frustum to ClutterPaintContext




commit ef537a470f33663af0f2d78492dcafab7e4bac01
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Oct 9 20:23:04 2020 -0300

    clutter/stage: Move clip frustum to ClutterPaintContext
    
    The clip planes / frustum are contextual to painting. In the past, for
    the lack of a better place, it was added to ClutterStage, but now we
    have an appropriate home for such data: ClutterPaintContext.
    
    Move the frustum to the paint context.

 clutter/clutter/clutter-actor.c                 |  7 ++++---
 clutter/clutter/clutter-paint-context-private.h | 11 ++++++++---
 clutter/clutter/clutter-paint-context.c         | 16 ++++++++++++---
 clutter/clutter/clutter-stage-private.h         |  2 --
 clutter/clutter/clutter-stage.c                 | 26 ++++++++++---------------
 5 files changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index b087e1541a..e3c628e149 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -3447,7 +3447,6 @@ cull_actor (ClutterActor        *self,
             ClutterCullResult   *result_out)
 {
   ClutterActorPrivate *priv = self->priv;
-  ClutterStage *stage;
   const graphene_frustum_t *clip_frustum;
 
   if (!priv->last_paint_volume_valid)
@@ -3469,8 +3468,7 @@ cull_actor (ClutterActor        *self,
       return FALSE;
     }
 
-  stage = (ClutterStage *) _clutter_actor_get_stage_internal (self);
-  clip_frustum = _clutter_stage_get_clip (stage);
+  clip_frustum = clutter_paint_context_get_clip_frustum (paint_context);
 
   *result_out =
     _clutter_paint_volume_cull (&priv->last_paint_volume, clip_frustum);
@@ -3485,6 +3483,9 @@ cull_actor (ClutterActor        *self,
           ClutterActorBox paint_box;
           cairo_rectangle_int_t paint_box_bounds;
           cairo_region_overlap_t overlap;
+          ClutterStage *stage;
+
+          stage = (ClutterStage *) _clutter_actor_get_stage_internal (self);
 
           _clutter_paint_volume_get_stage_paint_box (&priv->last_paint_volume,
                                                      stage,
diff --git a/clutter/clutter/clutter-paint-context-private.h b/clutter/clutter/clutter-paint-context-private.h
index 1e6f3fa00f..ff26edf21c 100644
--- a/clutter/clutter/clutter-paint-context-private.h
+++ b/clutter/clutter/clutter-paint-context-private.h
@@ -20,12 +20,17 @@
 
 #include "clutter-paint-context.h"
 
-ClutterPaintContext * clutter_paint_context_new_for_view (ClutterStageView     *view,
-                                                          const cairo_region_t *redraw_clip,
-                                                          ClutterPaintFlag      paint_flags);
+ClutterPaintContext *
+clutter_paint_context_new_for_view (ClutterStageView         *view,
+                                    const cairo_region_t     *redraw_clip,
+                                    const graphene_frustum_t *clip_frustum,
+                                    ClutterPaintFlag          paint_flags);
 
 gboolean clutter_paint_context_is_drawing_off_stage (ClutterPaintContext *paint_context);
 
 CoglFramebuffer * clutter_paint_context_get_base_framebuffer (ClutterPaintContext *paint_context);
 
+const graphene_frustum_t *
+clutter_paint_context_get_clip_frustum (ClutterPaintContext *paint_context);
+
 #endif /* CLUTTER_PAINT_CONTEXT_PRIVATE_H */
diff --git a/clutter/clutter/clutter-paint-context.c b/clutter/clutter/clutter-paint-context.c
index 5981835068..2153fdb6f6 100644
--- a/clutter/clutter/clutter-paint-context.c
+++ b/clutter/clutter/clutter-paint-context.c
@@ -30,6 +30,7 @@ struct _ClutterPaintContext
   ClutterStageView *view;
 
   cairo_region_t *redraw_clip;
+  graphene_frustum_t clip_frustum;
 };
 
 G_DEFINE_BOXED_TYPE (ClutterPaintContext, clutter_paint_context,
@@ -37,9 +38,10 @@ G_DEFINE_BOXED_TYPE (ClutterPaintContext, clutter_paint_context,
                      clutter_paint_context_unref)
 
 ClutterPaintContext *
-clutter_paint_context_new_for_view (ClutterStageView     *view,
-                                    const cairo_region_t *redraw_clip,
-                                    ClutterPaintFlag      paint_flags)
+clutter_paint_context_new_for_view (ClutterStageView         *view,
+                                    const cairo_region_t     *redraw_clip,
+                                    const graphene_frustum_t *clip_frustum,
+                                    ClutterPaintFlag          paint_flags)
 {
   ClutterPaintContext *paint_context;
   CoglFramebuffer *framebuffer;
@@ -49,6 +51,8 @@ clutter_paint_context_new_for_view (ClutterStageView     *view,
   paint_context->view = view;
   paint_context->redraw_clip = cairo_region_copy (redraw_clip);
   paint_context->paint_flags = paint_flags;
+  graphene_frustum_init_from_frustum (&paint_context->clip_frustum,
+                                      clip_frustum);
 
   framebuffer = clutter_stage_view_get_framebuffer (view);
   clutter_paint_context_push_framebuffer (paint_context, framebuffer);
@@ -134,6 +138,12 @@ clutter_paint_context_get_redraw_clip (ClutterPaintContext *paint_context)
   return paint_context->redraw_clip;
 }
 
+const graphene_frustum_t *
+clutter_paint_context_get_clip_frustum (ClutterPaintContext *paint_context)
+{
+  return &paint_context->clip_frustum;
+}
+
 /**
  * clutter_paint_context_get_framebuffer:
  * @paint_context: The #ClutterPaintContext
diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h
index 68fec2a840..a80539666b 100644
--- a/clutter/clutter/clutter-stage-private.h
+++ b/clutter/clutter/clutter-stage-private.h
@@ -98,8 +98,6 @@ ClutterActor *_clutter_stage_do_pick (ClutterStage    *stage,
 ClutterPaintVolume *_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage);
 void                _clutter_stage_paint_volume_stack_free_all (ClutterStage *stage);
 
-const graphene_frustum_t *_clutter_stage_get_clip (ClutterStage *stage);
-
 ClutterStageQueueRedrawEntry *_clutter_stage_queue_actor_redraw            (ClutterStage                 
*stage,
                                                                             ClutterStageQueueRedrawEntry 
*entry,
                                                                             ClutterActor                 
*actor,
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index cddcb250a9..9523cb0e84 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -115,8 +115,6 @@ struct _ClutterStagePrivate
 
   GArray *paint_volume_stack;
 
-  graphene_frustum_t clip_frustum;
-
   GSList *pending_relayouts;
   GList *pending_queue_redraws;
 
@@ -771,7 +769,8 @@ _cogl_util_get_eye_planes_for_screen_poly (float                   *polygon,
 static void
 setup_view_for_paint (ClutterStage                *stage,
                       ClutterStageView            *view,
-                      const cairo_rectangle_int_t *clip)
+                      const cairo_rectangle_int_t *clip,
+                      graphene_frustum_t          *out_frustum)
 {
   ClutterStagePrivate *priv = stage->priv;
   cairo_rectangle_int_t view_layout;
@@ -821,7 +820,7 @@ setup_view_for_paint (ClutterStage                *stage,
                                              viewport,
                                              &priv->projection,
                                              &priv->inverse_projection,
-                                             &priv->clip_frustum);
+                                             out_frustum);
 
   _clutter_stage_paint_volume_stack_free_all (stage);
 }
@@ -833,12 +832,15 @@ clutter_stage_do_paint_view (ClutterStage         *stage,
 {
   ClutterPaintContext *paint_context;
   cairo_rectangle_int_t clip_rect;
-
-  paint_context = clutter_paint_context_new_for_view (view, redraw_clip,
-                                                      CLUTTER_PAINT_FLAG_NONE);
+  graphene_frustum_t clip_frustum;
 
   cairo_region_get_extents (redraw_clip, &clip_rect);
-  setup_view_for_paint (stage, view, &clip_rect);
+  setup_view_for_paint (stage, view, &clip_rect, &clip_frustum);
+
+  paint_context = clutter_paint_context_new_for_view (view,
+                                                      redraw_clip,
+                                                      &clip_frustum,
+                                                      CLUTTER_PAINT_FLAG_NONE);
 
   clutter_actor_paint (CLUTTER_ACTOR (stage), paint_context);
   clutter_paint_context_destroy (paint_context);
@@ -3085,14 +3087,6 @@ _clutter_stage_paint_volume_stack_free_all (ClutterStage *stage)
   g_array_set_size (paint_volume_stack, 0);
 }
 
-/* The is an out-of-band parameter available while painting that
- * can be used to cull actors. */
-const graphene_frustum_t *
-_clutter_stage_get_clip (ClutterStage *stage)
-{
-  return &stage->priv->clip_frustum;
-}
-
 /* When an actor queues a redraw we add it to a list on the stage that
  * gets processed once all updates to the stage have been finished.
  *


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