clutter: Use pick context to track the framebuffer

Instead of pushing and popping the Cogl framebuffer stack, use the
framebuffer passed around using the pick context. This removes usage of
the deprecated framebuffer stack when picking.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
This commit is contained in:
Jonas Ådahl 2019-11-21 17:48:20 +01:00 committed by Georges Basile Stavracas Neto
parent 138907c480
commit 61b1ead1a2
2 changed files with 15 additions and 11 deletions

View File

@ -1287,10 +1287,12 @@ clutter_actor_verify_map_state (ClutterActor *self)
static gboolean
_clutter_actor_transform_local_box_to_stage (ClutterActor *self,
ClutterStage *stage,
ClutterPickContext *pick_context,
const ClutterActorBox *box,
graphene_point_t vertices[4])
{
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
CoglFramebuffer *fb =
clutter_pick_context_get_framebuffer (pick_context);
CoglMatrix stage_transform, inv_stage_transform;
CoglMatrix modelview, transform_to_stage;
int v;
@ -1356,12 +1358,14 @@ clutter_actor_pick_box (ClutterActor *self,
stage = CLUTTER_STAGE (_clutter_actor_get_stage_internal (self));
if (_clutter_actor_transform_local_box_to_stage (self, stage, box, vertices))
if (_clutter_actor_transform_local_box_to_stage (self, stage, pick_context,
box, vertices))
clutter_stage_log_pick (stage, vertices, self);
}
static gboolean
_clutter_actor_push_pick_clip (ClutterActor *self,
ClutterPickContext *pick_context,
const ClutterActorBox *clip)
{
ClutterStage *stage;
@ -1369,7 +1373,8 @@ _clutter_actor_push_pick_clip (ClutterActor *self,
stage = CLUTTER_STAGE (_clutter_actor_get_stage_internal (self));
if (!_clutter_actor_transform_local_box_to_stage (self, stage, clip, vertices))
if (!_clutter_actor_transform_local_box_to_stage (self, stage, pick_context,
clip, vertices))
return FALSE;
clutter_stage_push_pick_clip (stage, vertices);
@ -4183,6 +4188,7 @@ clutter_actor_pick (ClutterActor *actor,
ClutterPickContext *pick_context)
{
ClutterActorPrivate *priv;
CoglFramebuffer *framebuffer;
ClutterActorBox clip;
gboolean clip_set = FALSE;
@ -4202,15 +4208,16 @@ clutter_actor_pick (ClutterActor *actor,
/* mark that we are in the paint process */
CLUTTER_SET_PRIVATE_FLAGS (actor, CLUTTER_IN_PICK);
cogl_push_matrix ();
framebuffer = clutter_pick_context_get_framebuffer (pick_context);
cogl_framebuffer_push_matrix (framebuffer);
if (priv->enable_model_view_transform)
{
CoglMatrix matrix;
cogl_get_modelview_matrix (&matrix);
cogl_framebuffer_get_modelview_matrix (framebuffer, &matrix);
_clutter_actor_apply_modelview_transform (actor, &matrix);
cogl_set_modelview_matrix (&matrix);
cogl_framebuffer_set_modelview_matrix (framebuffer, &matrix);
}
if (priv->has_clip)
@ -4231,7 +4238,7 @@ clutter_actor_pick (ClutterActor *actor,
}
if (clip_set)
clip_set = _clutter_actor_push_pick_clip (actor, &clip);
clip_set = _clutter_actor_push_pick_clip (actor, pick_context, &clip);
priv->next_effect_to_paint = NULL;
if (priv->effects)
@ -4245,7 +4252,7 @@ clutter_actor_pick (ClutterActor *actor,
if (clip_set)
_clutter_actor_pop_pick_clip (actor);
cogl_pop_matrix ();
cogl_framebuffer_pop_matrix (framebuffer);
/* paint sequence complete */
CLUTTER_UNSET_PRIVATE_FLAGS (actor, CLUTTER_IN_PICK);

View File

@ -1647,7 +1647,6 @@ _clutter_stage_do_pick_on_view (ClutterStage *stage,
{
ClutterMainContext *context = _clutter_context_get_default ();
ClutterStagePrivate *priv = stage->priv;
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view);
int i;
g_assert (context->pick_mode == CLUTTER_PICK_NONE);
@ -1659,7 +1658,6 @@ _clutter_stage_do_pick_on_view (ClutterStage *stage,
_clutter_stage_clear_pick_stack (stage);
pick_context = clutter_pick_context_new_for_view (view);
cogl_push_framebuffer (fb);
context->pick_mode = mode;
setup_view_for_pick_or_paint (stage, view, NULL);
@ -1667,7 +1665,6 @@ _clutter_stage_do_pick_on_view (ClutterStage *stage,
context->pick_mode = CLUTTER_PICK_NONE;
priv->cached_pick_mode = mode;
cogl_pop_framebuffer ();
clutter_pick_context_destroy (pick_context);
add_pick_stack_weak_refs (stage);