From c4949b553df45b0ee03016c23f392003dcf40a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 30 Apr 2020 21:51:10 +0200 Subject: [PATCH] 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 --- clutter/clutter/clutter-stage-view-private.h | 9 ++++++ clutter/clutter/clutter-stage-view.c | 29 ++++++++++++++++++++ clutter/clutter/clutter-stage.c | 14 +++------- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/clutter/clutter/clutter-stage-view-private.h b/clutter/clutter/clutter-stage-view-private.h index 2e5ad4c53..6b445448e 100644 --- a/clutter/clutter/clutter-stage-view-private.h +++ b/clutter/clutter/clutter-stage-view-private.h @@ -27,11 +27,20 @@ gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view); void clutter_stage_view_set_dirty_viewport (ClutterStageView *view, 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); void clutter_stage_view_set_dirty_projection (ClutterStageView *view, gboolean dirty); +void clutter_stage_view_set_projection (ClutterStageView *view, + const CoglMatrix *matrix); + void clutter_stage_view_add_redraw_clip (ClutterStageView *view, const cairo_rectangle_int_t *clip); diff --git a/clutter/clutter/clutter-stage-view.c b/clutter/clutter/clutter-stage-view.c index 0aa92f3fb..3ebe9c445 100644 --- a/clutter/clutter/clutter-stage-view.c +++ b/clutter/clutter/clutter-stage-view.c @@ -363,6 +363,22 @@ clutter_stage_view_set_dirty_viewport (ClutterStageView *view, 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 clutter_stage_view_is_dirty_projection (ClutterStageView *view) { @@ -382,6 +398,19 @@ clutter_stage_view_set_dirty_projection (ClutterStageView *view, 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 clutter_stage_view_get_offscreen_transformation_matrix (ClutterStageView *view, CoglMatrix *matrix) diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 9657dc8b5..310da1744 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -3147,7 +3147,6 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage, ClutterStageView *view) { ClutterStagePrivate *priv = stage->priv; - CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (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_width = roundf (priv->viewport[2] * fb_scale); viewport_height = roundf (priv->viewport[3] * fb_scale); - cogl_framebuffer_set_viewport (fb, - viewport_x, viewport_y, - viewport_width, viewport_height); - clutter_stage_view_set_dirty_viewport (view, FALSE); + clutter_stage_view_set_viewport (view, + viewport_x, viewport_y, + viewport_width, viewport_height); } if (clutter_stage_view_is_dirty_projection (view)) - { - cogl_framebuffer_set_projection_matrix (fb, &priv->projection); - - clutter_stage_view_set_dirty_projection (view, FALSE); - } + clutter_stage_view_set_projection (view, &priv->projection); } #undef _DEG_TO_RAD