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.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
This commit is contained in:
Georges Basile Stavracas Neto 2020-10-09 20:23:04 -03:00
parent b6fa26cf45
commit feb8397c97
5 changed files with 35 additions and 27 deletions

View File

@ -3449,7 +3449,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)
@ -3471,8 +3470,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);
@ -3487,6 +3485,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,

View File

@ -20,12 +20,17 @@
#include "clutter-paint-context.h"
ClutterPaintContext * clutter_paint_context_new_for_view (ClutterStageView *view,
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 */

View File

@ -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,
@ -39,6 +40,7 @@ G_DEFINE_BOXED_TYPE (ClutterPaintContext, clutter_paint_context,
ClutterPaintContext *
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;
@ -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);
@ -133,6 +137,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

View File

@ -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,

View File

@ -115,8 +115,6 @@ struct _ClutterStagePrivate
GArray *paint_volume_stack;
graphene_frustum_t clip_frustum;
GSList *pending_relayouts;
GList *pending_queue_redraws;
@ -774,7 +772,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;
@ -825,7 +824,7 @@ setup_view_for_paint (ClutterStage *stage,
&priv->projection,
&priv->inverse_projection,
&priv->perspective,
&priv->clip_frustum);
out_frustum);
_clutter_stage_paint_volume_stack_free_all (stage);
}
@ -837,12 +836,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);
@ -3089,14 +3091,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.
*