clutter/stage-view: Move fb viewport and projection setting to here

The stage would fetch the front framebuffer and set the viewport and
projection matrix, but if we are going to more than one front buffer,
that won't work, so let the stage just pass the viewport and projection
matrix to the view and have the view deal with the framebuffer(s).

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
This commit is contained in:
Jonas Ådahl 2020-04-30 21:51:10 +02:00 committed by Georges Basile Stavracas Neto
parent 675a2d13b9
commit c4949b553d
3 changed files with 42 additions and 10 deletions

View File

@ -27,11 +27,20 @@ gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view);
void clutter_stage_view_set_dirty_viewport (ClutterStageView *view, void clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
gboolean dirty); gboolean dirty);
void clutter_stage_view_set_viewport (ClutterStageView *view,
float x,
float y,
float width,
float height);
gboolean clutter_stage_view_is_dirty_projection (ClutterStageView *view); gboolean clutter_stage_view_is_dirty_projection (ClutterStageView *view);
void clutter_stage_view_set_dirty_projection (ClutterStageView *view, void clutter_stage_view_set_dirty_projection (ClutterStageView *view,
gboolean dirty); gboolean dirty);
void clutter_stage_view_set_projection (ClutterStageView *view,
const CoglMatrix *matrix);
void clutter_stage_view_add_redraw_clip (ClutterStageView *view, void clutter_stage_view_add_redraw_clip (ClutterStageView *view,
const cairo_rectangle_int_t *clip); const cairo_rectangle_int_t *clip);

View File

@ -363,6 +363,22 @@ clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
priv->dirty_viewport = dirty; priv->dirty_viewport = dirty;
} }
void
clutter_stage_view_set_viewport (ClutterStageView *view,
float x,
float y,
float width,
float height)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
CoglFramebuffer *framebuffer;
priv->dirty_viewport = FALSE;
framebuffer = clutter_stage_view_get_framebuffer (view);
cogl_framebuffer_set_viewport (framebuffer, x, y, width, height);
}
gboolean gboolean
clutter_stage_view_is_dirty_projection (ClutterStageView *view) clutter_stage_view_is_dirty_projection (ClutterStageView *view)
{ {
@ -382,6 +398,19 @@ clutter_stage_view_set_dirty_projection (ClutterStageView *view,
priv->dirty_projection = dirty; priv->dirty_projection = dirty;
} }
void
clutter_stage_view_set_projection (ClutterStageView *view,
const CoglMatrix *matrix)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
CoglFramebuffer *framebuffer;
priv->dirty_projection = FALSE;
framebuffer = clutter_stage_view_get_framebuffer (view);
cogl_framebuffer_set_projection_matrix (framebuffer, matrix);
}
void void
clutter_stage_view_get_offscreen_transformation_matrix (ClutterStageView *view, clutter_stage_view_get_offscreen_transformation_matrix (ClutterStageView *view,
CoglMatrix *matrix) CoglMatrix *matrix)

View File

@ -3147,7 +3147,6 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage,
ClutterStageView *view) ClutterStageView *view)
{ {
ClutterStagePrivate *priv = stage->priv; ClutterStagePrivate *priv = stage->priv;
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view);
if (clutter_stage_view_is_dirty_viewport (view)) if (clutter_stage_view_is_dirty_viewport (view))
{ {
@ -3174,19 +3173,14 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage,
viewport_y = roundf (priv->viewport[1] * fb_scale - viewport_offset_y); viewport_y = roundf (priv->viewport[1] * fb_scale - viewport_offset_y);
viewport_width = roundf (priv->viewport[2] * fb_scale); viewport_width = roundf (priv->viewport[2] * fb_scale);
viewport_height = roundf (priv->viewport[3] * fb_scale); viewport_height = roundf (priv->viewport[3] * fb_scale);
cogl_framebuffer_set_viewport (fb,
clutter_stage_view_set_viewport (view,
viewport_x, viewport_y, viewport_x, viewport_y,
viewport_width, viewport_height); viewport_width, viewport_height);
clutter_stage_view_set_dirty_viewport (view, FALSE);
} }
if (clutter_stage_view_is_dirty_projection (view)) if (clutter_stage_view_is_dirty_projection (view))
{ clutter_stage_view_set_projection (view, &priv->projection);
cogl_framebuffer_set_projection_matrix (fb, &priv->projection);
clutter_stage_view_set_dirty_projection (view, FALSE);
}
} }
#undef _DEG_TO_RAD #undef _DEG_TO_RAD