2011-05-08 19:27:10 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
* Authors:
|
|
|
|
* Matthew Allum
|
|
|
|
* Robert Bragg
|
|
|
|
* Neil Roberts
|
|
|
|
* Emmanuele Bassi
|
|
|
|
*/
|
|
|
|
|
2021-05-10 07:27:39 -04:00
|
|
|
#include "config.h"
|
2007-07-06 09:56:01 -04:00
|
|
|
|
2021-05-10 07:27:39 -04:00
|
|
|
#include "backends/meta-stage-impl-private.h"
|
2007-07-06 09:56:01 -04:00
|
|
|
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
#include <stdlib.h>
|
2016-08-08 06:42:44 -04:00
|
|
|
#include <math.h>
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
2021-05-10 15:56:19 -04:00
|
|
|
#include "backends/meta-stage-view-private.h"
|
2021-05-10 07:27:39 -04:00
|
|
|
#include "clutter/clutter-mutter.h"
|
|
|
|
#include "cogl/cogl.h"
|
|
|
|
#include "core/util-private.h"
|
2021-09-17 12:24:28 -04:00
|
|
|
#include "meta/meta-backend.h"
|
2007-07-06 09:56:01 -04:00
|
|
|
|
2020-02-19 20:34:49 -05:00
|
|
|
#define MAX_STACK_RECTS 256
|
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
typedef struct _MetaStageImplPrivate
|
2020-05-22 16:30:45 -04:00
|
|
|
{
|
2021-09-17 12:24:28 -04:00
|
|
|
MetaBackend *backend;
|
2020-05-22 16:30:45 -04:00
|
|
|
int64_t global_frame_counter;
|
2021-05-10 15:15:53 -04:00
|
|
|
} MetaStageImplPrivate;
|
2020-05-22 16:30:45 -04:00
|
|
|
|
2019-01-08 07:51:47 -05:00
|
|
|
static void
|
|
|
|
clutter_stage_window_iface_init (ClutterStageWindowInterface *iface);
|
2008-04-23 13:20:59 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaStageImpl,
|
|
|
|
meta_stage_impl,
|
2010-02-27 04:42:42 -05:00
|
|
|
G_TYPE_OBJECT,
|
2021-05-10 15:15:53 -04:00
|
|
|
G_ADD_PRIVATE (MetaStageImpl)
|
2008-04-23 13:20:59 -04:00
|
|
|
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
|
|
|
clutter_stage_window_iface_init));
|
2007-07-06 09:56:01 -04:00
|
|
|
|
2018-12-19 03:04:25 -05:00
|
|
|
enum
|
|
|
|
{
|
2011-08-26 18:16:12 -04:00
|
|
|
PROP_0,
|
2021-09-17 11:31:03 -04:00
|
|
|
|
2011-08-26 18:16:12 -04:00
|
|
|
PROP_WRAPPER,
|
|
|
|
PROP_BACKEND,
|
2021-09-17 11:31:03 -04:00
|
|
|
|
|
|
|
N_PROPS
|
2011-08-26 18:16:12 -04:00
|
|
|
};
|
|
|
|
|
2021-09-17 11:31:03 -04:00
|
|
|
static GParamSpec *obj_props[N_PROPS];
|
|
|
|
|
2007-07-06 09:56:01 -04:00
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_unrealize (ClutterStageWindow *stage_window)
|
2010-06-17 17:26:12 -04:00
|
|
|
{
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND, "Unrealizing Cogl stage [%p]", stage_window);
|
2011-05-08 19:27:10 -04:00
|
|
|
}
|
|
|
|
|
2010-06-17 17:26:12 -04:00
|
|
|
static gboolean
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_realize (ClutterStageWindow *stage_window)
|
2007-07-06 09:56:01 -04:00
|
|
|
{
|
2011-02-24 19:31:41 -05:00
|
|
|
ClutterBackend *backend;
|
2010-06-17 17:26:12 -04:00
|
|
|
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND,
|
|
|
|
"Realizing stage '%s' [%p]",
|
|
|
|
G_OBJECT_TYPE_NAME (stage_window),
|
|
|
|
stage_window);
|
2010-06-17 17:26:12 -04:00
|
|
|
|
2011-06-17 07:03:21 -04:00
|
|
|
backend = clutter_get_default_backend ();
|
2010-06-17 17:26:12 -04:00
|
|
|
|
2015-03-17 09:47:08 -04:00
|
|
|
if (backend->cogl_context == NULL)
|
|
|
|
{
|
|
|
|
g_warning ("Failed to realize stage: missing Cogl context");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:42:24 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-05-22 16:30:45 -04:00
|
|
|
static int64_t
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_get_frame_counter (ClutterStageWindow *stage_window)
|
2020-05-22 16:30:45 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
|
|
|
|
MetaStageImplPrivate *priv =
|
|
|
|
meta_stage_impl_get_instance_private (stage_impl);
|
2020-05-22 16:30:45 -04:00
|
|
|
|
|
|
|
return priv->global_frame_counter;
|
|
|
|
}
|
|
|
|
|
2010-02-27 04:42:42 -05:00
|
|
|
static ClutterActor *
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_get_wrapper (ClutterStageWindow *stage_window)
|
2010-02-27 04:42:42 -05:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
return CLUTTER_ACTOR (META_STAGE_IMPL (stage_window)->wrapper);
|
2007-07-06 09:56:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_show (ClutterStageWindow *stage_window,
|
|
|
|
gboolean do_raise)
|
2007-07-06 09:56:01 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
|
2008-06-11 06:19:02 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
clutter_actor_map (CLUTTER_ACTOR (stage_impl->wrapper));
|
2008-06-11 06:19:02 -04:00
|
|
|
}
|
|
|
|
|
2007-07-06 09:56:01 -04:00
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_hide (ClutterStageWindow *stage_window)
|
2007-07-06 09:56:01 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
|
2007-07-06 09:56:01 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
clutter_actor_unmap (CLUTTER_ACTOR (stage_impl->wrapper));
|
2007-07-06 09:56:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_resize (ClutterStageWindow *stage_window,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
2007-07-06 09:56:01 -04:00
|
|
|
{
|
2008-04-25 09:37:36 -04:00
|
|
|
}
|
|
|
|
|
2018-08-10 00:03:54 -04:00
|
|
|
static void
|
2019-07-27 12:39:04 -04:00
|
|
|
paint_damage_region (ClutterStageWindow *stage_window,
|
|
|
|
ClutterStageView *view,
|
2020-02-06 04:12:54 -05:00
|
|
|
cairo_region_t *swap_region,
|
|
|
|
cairo_region_t *queued_redraw_clip)
|
2018-08-10 00:03:54 -04:00
|
|
|
{
|
2020-03-07 14:29:09 -05:00
|
|
|
CoglFramebuffer *framebuffer = clutter_stage_view_get_framebuffer (view);
|
2018-08-10 00:03:54 -04:00
|
|
|
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
|
|
|
static CoglPipeline *overlay_blue = NULL;
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
|
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (stage_impl->wrapper);
|
2020-09-11 14:57:28 -04:00
|
|
|
graphene_matrix_t transform;
|
2019-07-27 12:39:04 -04:00
|
|
|
int n_rects, i;
|
2018-08-10 00:03:54 -04:00
|
|
|
|
2019-07-27 12:39:04 -04:00
|
|
|
cogl_framebuffer_push_matrix (framebuffer);
|
|
|
|
clutter_actor_get_transform (actor, &transform);
|
|
|
|
cogl_framebuffer_transform (framebuffer, &transform);
|
|
|
|
|
|
|
|
/* Blue for the swap region */
|
2018-08-10 00:03:54 -04:00
|
|
|
if (G_UNLIKELY (overlay_blue == NULL))
|
|
|
|
{
|
|
|
|
overlay_blue = cogl_pipeline_new (ctx);
|
|
|
|
cogl_pipeline_set_color4ub (overlay_blue, 0x00, 0x00, 0x33, 0x33);
|
|
|
|
}
|
|
|
|
|
2019-07-27 12:39:04 -04:00
|
|
|
n_rects = cairo_region_num_rectangles (swap_region);
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
float x_1, x_2, y_1, y_2;
|
2018-08-10 00:03:54 -04:00
|
|
|
|
2019-07-27 12:39:04 -04:00
|
|
|
cairo_region_get_rectangle (swap_region, i, &rect);
|
|
|
|
x_1 = rect.x;
|
|
|
|
x_2 = rect.x + rect.width;
|
|
|
|
y_1 = rect.y;
|
|
|
|
y_2 = rect.y + rect.height;
|
|
|
|
|
|
|
|
cogl_framebuffer_draw_rectangle (framebuffer, overlay_blue, x_1, y_1, x_2, y_2);
|
|
|
|
}
|
2018-08-10 00:03:54 -04:00
|
|
|
|
|
|
|
/* Red for the clip */
|
2020-02-06 04:12:54 -05:00
|
|
|
if (queued_redraw_clip)
|
2018-08-10 00:03:54 -04:00
|
|
|
{
|
|
|
|
static CoglPipeline *overlay_red = NULL;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (overlay_red == NULL))
|
|
|
|
{
|
|
|
|
overlay_red = cogl_pipeline_new (ctx);
|
|
|
|
cogl_pipeline_set_color4ub (overlay_red, 0x33, 0x00, 0x00, 0x33);
|
|
|
|
}
|
|
|
|
|
2020-02-06 04:12:54 -05:00
|
|
|
n_rects = cairo_region_num_rectangles (queued_redraw_clip);
|
2019-07-20 11:52:11 -04:00
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
2019-07-27 12:39:04 -04:00
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
float x_1, x_2, y_1, y_2;
|
|
|
|
|
2020-02-06 04:12:54 -05:00
|
|
|
cairo_region_get_rectangle (queued_redraw_clip, i, &rect);
|
2019-07-27 12:39:04 -04:00
|
|
|
x_1 = rect.x;
|
|
|
|
x_2 = rect.x + rect.width;
|
|
|
|
y_1 = rect.y;
|
|
|
|
y_2 = rect.y + rect.height;
|
2018-08-10 00:03:54 -04:00
|
|
|
|
2019-07-20 11:52:11 -04:00
|
|
|
cogl_framebuffer_draw_rectangle (framebuffer, overlay_red, x_1, y_1, x_2, y_2);
|
|
|
|
}
|
2018-08-10 00:03:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
cogl_framebuffer_pop_matrix (framebuffer);
|
|
|
|
}
|
|
|
|
|
2021-09-22 16:26:23 -04:00
|
|
|
static void
|
|
|
|
queue_damage_region (ClutterStageWindow *stage_window,
|
|
|
|
ClutterStageView *stage_view,
|
|
|
|
cairo_region_t *damage_region)
|
|
|
|
{
|
|
|
|
int *damage, n_rects, i;
|
|
|
|
g_autofree int *freeme = NULL;
|
|
|
|
CoglFramebuffer *framebuffer;
|
|
|
|
CoglOnscreen *onscreen;
|
|
|
|
|
|
|
|
if (cairo_region_is_empty (damage_region))
|
|
|
|
return;
|
|
|
|
|
|
|
|
framebuffer = clutter_stage_view_get_onscreen (stage_view);
|
|
|
|
if (!COGL_IS_ONSCREEN (framebuffer))
|
|
|
|
return;
|
|
|
|
|
|
|
|
onscreen = COGL_ONSCREEN (framebuffer);
|
|
|
|
|
|
|
|
n_rects = cairo_region_num_rectangles (damage_region);
|
|
|
|
|
|
|
|
if (n_rects < MAX_STACK_RECTS)
|
|
|
|
damage = g_newa (int, n_rects * 4);
|
|
|
|
else
|
|
|
|
damage = freeme = g_new (int, n_rects * 4);
|
|
|
|
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
int height = cogl_framebuffer_get_height (framebuffer);
|
|
|
|
|
|
|
|
cairo_region_get_rectangle (damage_region, i, &rect);
|
|
|
|
damage[i * 4] = rect.x;
|
|
|
|
/* y coordinate needs to be flipped for OpenGL */
|
|
|
|
damage[i * 4 + 1] = height - rect.y - rect.height;
|
|
|
|
damage[i * 4 + 2] = rect.width;
|
|
|
|
damage[i * 4 + 3] = rect.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
cogl_onscreen_queue_damage_region (onscreen, damage, n_rects);
|
|
|
|
}
|
|
|
|
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
static void
|
2019-07-27 12:39:04 -04:00
|
|
|
swap_framebuffer (ClutterStageWindow *stage_window,
|
2021-05-10 15:15:53 -04:00
|
|
|
ClutterStageView *stage_view,
|
2019-07-27 12:39:04 -04:00
|
|
|
cairo_region_t *swap_region,
|
2020-10-09 16:00:29 -04:00
|
|
|
gboolean swap_with_damage,
|
|
|
|
ClutterFrame *frame)
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
|
|
|
|
MetaStageImplPrivate *priv =
|
|
|
|
meta_stage_impl_get_instance_private (stage_impl);
|
|
|
|
CoglFramebuffer *framebuffer = clutter_stage_view_get_onscreen (stage_view);
|
2021-01-06 07:37:13 -05:00
|
|
|
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
|
2019-07-27 12:39:04 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
clutter_stage_view_before_swap_buffer (stage_view, swap_region);
|
2020-05-05 13:25:23 -04:00
|
|
|
|
2020-10-13 05:35:47 -04:00
|
|
|
if (COGL_IS_ONSCREEN (framebuffer))
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
|
|
|
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
2020-05-13 11:18:50 -04:00
|
|
|
int *damage, n_rects, i;
|
2020-05-22 15:52:29 -04:00
|
|
|
CoglFrameInfo *frame_info;
|
2020-05-13 11:18:50 -04:00
|
|
|
|
|
|
|
n_rects = cairo_region_num_rectangles (swap_region);
|
|
|
|
damage = g_newa (int, n_rects * 4);
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
|
|
|
|
cairo_region_get_rectangle (swap_region, i, &rect);
|
|
|
|
damage[i * 4] = rect.x;
|
|
|
|
damage[i * 4 + 1] = rect.y;
|
|
|
|
damage[i * 4 + 2] = rect.width;
|
|
|
|
damage[i * 4 + 3] = rect.height;
|
|
|
|
}
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
2021-01-06 07:37:13 -05:00
|
|
|
frame_info =
|
|
|
|
cogl_frame_info_new (cogl_context, priv->global_frame_counter);
|
2020-05-22 16:30:45 -04:00
|
|
|
priv->global_frame_counter++;
|
2020-05-22 15:52:29 -04:00
|
|
|
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
/* push on the screen */
|
2019-07-27 12:39:04 -04:00
|
|
|
if (n_rects > 0 && !swap_with_damage)
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND,
|
|
|
|
"cogl_onscreen_swap_region (onscreen: %p)",
|
|
|
|
onscreen);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
|
|
|
cogl_onscreen_swap_region (onscreen,
|
2020-05-22 15:52:29 -04:00
|
|
|
damage, n_rects,
|
2020-10-09 16:00:29 -04:00
|
|
|
frame_info,
|
|
|
|
frame);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND,
|
|
|
|
"cogl_onscreen_swap_buffers (onscreen: %p)",
|
|
|
|
onscreen);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
|
|
|
cogl_onscreen_swap_buffers_with_damage (onscreen,
|
2020-05-22 15:52:29 -04:00
|
|
|
damage, n_rects,
|
2020-10-09 16:00:29 -04:00
|
|
|
frame_info,
|
|
|
|
frame);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageView *view = META_STAGE_VIEW (stage_view);
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND,
|
|
|
|
"fake offscreen swap (framebuffer: %p)",
|
|
|
|
framebuffer);
|
2021-05-10 15:56:19 -04:00
|
|
|
meta_stage_view_perform_fake_swap (view, priv->global_frame_counter);
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
priv->global_frame_counter++;
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
2015-01-28 17:08:03 -05:00
|
|
|
}
|
|
|
|
|
2020-02-06 02:46:41 -05:00
|
|
|
static cairo_region_t *
|
|
|
|
offset_scale_and_clamp_region (const cairo_region_t *region,
|
|
|
|
int offset_x,
|
|
|
|
int offset_y,
|
|
|
|
float scale)
|
|
|
|
{
|
|
|
|
int n_rects, i;
|
|
|
|
cairo_rectangle_int_t *rects;
|
|
|
|
g_autofree cairo_rectangle_int_t *freeme = NULL;
|
|
|
|
|
|
|
|
n_rects = cairo_region_num_rectangles (region);
|
|
|
|
|
|
|
|
if (n_rects == 0)
|
|
|
|
return cairo_region_create ();
|
|
|
|
|
|
|
|
if (n_rects < MAX_STACK_RECTS)
|
|
|
|
rects = g_newa (cairo_rectangle_int_t, n_rects);
|
|
|
|
else
|
|
|
|
rects = freeme = g_new (cairo_rectangle_int_t, n_rects);
|
|
|
|
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
2020-05-13 05:02:56 -04:00
|
|
|
cairo_rectangle_int_t *rect = &rects[i];
|
2020-02-06 02:46:41 -05:00
|
|
|
graphene_rect_t tmp;
|
|
|
|
|
2020-05-13 05:02:56 -04:00
|
|
|
cairo_region_get_rectangle (region, i, rect);
|
|
|
|
|
|
|
|
_clutter_util_rect_from_rectangle (rect, &tmp);
|
2020-02-06 02:46:41 -05:00
|
|
|
graphene_rect_offset (&tmp, offset_x, offset_y);
|
2020-03-05 07:27:24 -05:00
|
|
|
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
2020-05-13 05:02:56 -04:00
|
|
|
_clutter_util_rectangle_int_extents (&tmp, rect);
|
2020-02-06 02:46:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return cairo_region_create_rectangles (rects, n_rects);
|
|
|
|
}
|
|
|
|
|
2020-05-13 05:04:12 -04:00
|
|
|
static cairo_region_t *
|
|
|
|
scale_offset_and_clamp_region (const cairo_region_t *region,
|
|
|
|
float scale,
|
|
|
|
int offset_x,
|
|
|
|
int offset_y)
|
|
|
|
{
|
|
|
|
int n_rects, i;
|
|
|
|
cairo_rectangle_int_t *rects;
|
|
|
|
g_autofree cairo_rectangle_int_t *freeme = NULL;
|
|
|
|
|
|
|
|
n_rects = cairo_region_num_rectangles (region);
|
|
|
|
|
|
|
|
if (n_rects == 0)
|
|
|
|
return cairo_region_create ();
|
|
|
|
|
|
|
|
if (n_rects < MAX_STACK_RECTS)
|
|
|
|
rects = g_newa (cairo_rectangle_int_t, n_rects);
|
|
|
|
else
|
|
|
|
rects = freeme = g_new (cairo_rectangle_int_t, n_rects);
|
|
|
|
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t *rect = &rects[i];
|
|
|
|
graphene_rect_t tmp;
|
|
|
|
|
|
|
|
cairo_region_get_rectangle (region, i, rect);
|
|
|
|
|
|
|
|
_clutter_util_rect_from_rectangle (rect, &tmp);
|
|
|
|
graphene_rect_scale (&tmp, scale, scale, &tmp);
|
|
|
|
graphene_rect_offset (&tmp, offset_x, offset_y);
|
|
|
|
_clutter_util_rectangle_int_extents (&tmp, rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cairo_region_create_rectangles (rects, n_rects);
|
|
|
|
}
|
|
|
|
|
2011-02-04 10:09:41 -05:00
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
paint_stage (MetaStageImpl *stage_impl,
|
|
|
|
ClutterStageView *stage_view,
|
2020-02-06 03:00:12 -05:00
|
|
|
cairo_region_t *redraw_clip)
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
ClutterStage *stage = stage_impl->wrapper;
|
2019-10-28 13:14:33 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
_clutter_stage_maybe_setup_viewport (stage, stage_view);
|
|
|
|
clutter_stage_paint_view (stage, stage_view, redraw_clip);
|
2016-07-31 20:55:13 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
clutter_stage_view_after_paint (stage_view, redraw_clip);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
|
|
|
|
2019-07-27 12:39:04 -04:00
|
|
|
static cairo_region_t *
|
2021-05-10 15:15:53 -04:00
|
|
|
transform_swap_region_to_onscreen (ClutterStageView *stage_view,
|
2019-07-27 12:39:04 -04:00
|
|
|
cairo_region_t *swap_region)
|
2016-08-08 06:42:44 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
CoglFramebuffer *onscreen = clutter_stage_view_get_onscreen (stage_view);
|
2019-07-27 12:39:04 -04:00
|
|
|
int n_rects, i;
|
|
|
|
cairo_rectangle_int_t *rects;
|
|
|
|
cairo_region_t *transformed_region;
|
2020-05-05 13:05:36 -04:00
|
|
|
int width, height;
|
2016-08-08 06:42:44 -04:00
|
|
|
|
2020-05-05 13:05:36 -04:00
|
|
|
width = cogl_framebuffer_get_width (onscreen);
|
|
|
|
height = cogl_framebuffer_get_height (onscreen);
|
2016-08-08 06:42:44 -04:00
|
|
|
|
2019-07-27 12:39:04 -04:00
|
|
|
n_rects = cairo_region_num_rectangles (swap_region);
|
|
|
|
rects = g_newa (cairo_rectangle_int_t, n_rects);
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
cairo_region_get_rectangle (swap_region, i, &rects[i]);
|
2021-05-10 15:15:53 -04:00
|
|
|
clutter_stage_view_transform_rect_to_onscreen (stage_view,
|
2020-05-05 13:05:36 -04:00
|
|
|
&rects[i],
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
&rects[i]);
|
2019-07-27 12:39:04 -04:00
|
|
|
}
|
|
|
|
transformed_region = cairo_region_create_rectangles (rects, n_rects);
|
|
|
|
|
|
|
|
return transformed_region;
|
2016-08-08 06:42:44 -04:00
|
|
|
}
|
|
|
|
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
|
|
|
|
ClutterStageView *stage_view,
|
|
|
|
ClutterFrame *frame)
|
2010-06-17 17:26:12 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
ClutterStageWindow *stage_window = CLUTTER_STAGE_WINDOW (stage_impl);
|
|
|
|
MetaStageView *view = META_STAGE_VIEW (stage_view);
|
|
|
|
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (stage_view);
|
|
|
|
CoglFramebuffer *onscreen = clutter_stage_view_get_onscreen (stage_view);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
cairo_rectangle_int_t view_rect;
|
2020-02-06 02:31:04 -05:00
|
|
|
gboolean is_full_redraw;
|
2020-06-19 03:34:59 -04:00
|
|
|
gboolean use_clipped_redraw = TRUE;
|
2011-11-04 12:13:04 -04:00
|
|
|
gboolean can_blit_sub_buffer;
|
2013-02-06 05:05:58 -05:00
|
|
|
gboolean has_buffer_age;
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
gboolean swap_with_damage;
|
2020-02-06 04:12:54 -05:00
|
|
|
cairo_region_t *redraw_clip;
|
2020-03-06 05:33:30 -05:00
|
|
|
cairo_region_t *queued_redraw_clip = NULL;
|
2019-07-20 11:52:11 -04:00
|
|
|
cairo_region_t *fb_clip_region;
|
2019-07-27 12:39:04 -04:00
|
|
|
cairo_region_t *swap_region;
|
2021-05-10 07:27:39 -04:00
|
|
|
ClutterDrawDebugFlag paint_debug_flags;
|
2021-05-10 15:56:19 -04:00
|
|
|
ClutterDamageHistory *damage_history;
|
2017-05-25 03:54:37 -04:00
|
|
|
float fb_scale;
|
2017-06-07 22:08:16 -04:00
|
|
|
int fb_width, fb_height;
|
2020-06-19 03:34:59 -04:00
|
|
|
int buffer_age = 0;
|
2011-02-24 19:31:41 -05:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
clutter_stage_view_get_layout (stage_view, &view_rect);
|
|
|
|
fb_scale = clutter_stage_view_get_scale (stage_view);
|
2017-06-07 22:08:16 -04:00
|
|
|
fb_width = cogl_framebuffer_get_width (fb);
|
|
|
|
fb_height = cogl_framebuffer_get_height (fb);
|
2011-02-24 19:31:41 -05:00
|
|
|
|
2013-07-04 11:12:27 -04:00
|
|
|
can_blit_sub_buffer =
|
2020-10-13 05:35:47 -04:00
|
|
|
COGL_IS_ONSCREEN (onscreen) &&
|
2013-07-04 11:12:27 -04:00
|
|
|
cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION);
|
2011-11-04 12:13:04 -04:00
|
|
|
|
2020-11-18 04:49:59 -05:00
|
|
|
has_buffer_age =
|
|
|
|
COGL_IS_ONSCREEN (onscreen) &&
|
|
|
|
cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE);
|
2013-12-04 23:54:27 -05:00
|
|
|
|
2022-06-25 16:14:41 -04:00
|
|
|
redraw_clip = clutter_stage_view_take_accumulated_redraw_clip (stage_view);
|
2020-02-06 04:12:54 -05:00
|
|
|
|
2019-07-20 11:52:11 -04:00
|
|
|
/* NB: a NULL redraw clip == full stage redraw */
|
2020-02-06 04:12:54 -05:00
|
|
|
if (!redraw_clip)
|
2020-02-06 02:31:04 -05:00
|
|
|
is_full_redraw = TRUE;
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
else
|
2020-02-06 04:12:54 -05:00
|
|
|
is_full_redraw = FALSE;
|
2013-12-04 23:54:27 -05:00
|
|
|
|
2021-05-10 15:56:19 -04:00
|
|
|
damage_history = meta_stage_view_get_damage_history (view);
|
|
|
|
|
2020-03-19 17:30:06 -04:00
|
|
|
if (has_buffer_age)
|
2011-09-21 13:05:03 -04:00
|
|
|
{
|
2020-05-05 13:05:36 -04:00
|
|
|
buffer_age = cogl_onscreen_get_buffer_age (COGL_ONSCREEN (onscreen));
|
2021-05-10 15:56:19 -04:00
|
|
|
if (!clutter_damage_history_is_age_valid (damage_history, buffer_age))
|
2020-03-19 17:30:06 -04:00
|
|
|
{
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND,
|
|
|
|
"Invalid back buffer(age=%d): forcing full redraw",
|
|
|
|
buffer_age);
|
2020-03-06 06:15:55 -05:00
|
|
|
use_clipped_redraw = FALSE;
|
2020-03-19 17:30:06 -04:00
|
|
|
}
|
|
|
|
}
|
2017-06-07 22:08:16 -04:00
|
|
|
|
2021-05-10 07:27:39 -04:00
|
|
|
meta_get_clutter_debug_flags (NULL, &paint_debug_flags, NULL);
|
|
|
|
|
2020-03-06 06:15:55 -05:00
|
|
|
use_clipped_redraw =
|
|
|
|
use_clipped_redraw &&
|
2021-05-10 07:27:39 -04:00
|
|
|
!(paint_debug_flags & CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS) &&
|
2020-03-06 06:15:55 -05:00
|
|
|
_clutter_stage_window_can_clip_redraws (stage_window) &&
|
|
|
|
(can_blit_sub_buffer || has_buffer_age) &&
|
|
|
|
!is_full_redraw &&
|
|
|
|
/* some drivers struggle to get going and produce some junk
|
|
|
|
* frames when starting up... */
|
2020-05-05 13:05:36 -04:00
|
|
|
cogl_onscreen_get_frame_counter (COGL_ONSCREEN (onscreen)) > 3;
|
2020-03-06 06:15:55 -05:00
|
|
|
|
|
|
|
if (use_clipped_redraw)
|
2020-03-19 17:30:06 -04:00
|
|
|
{
|
2020-02-06 02:46:41 -05:00
|
|
|
fb_clip_region = offset_scale_and_clamp_region (redraw_clip,
|
|
|
|
-view_rect.x,
|
|
|
|
-view_rect.y,
|
|
|
|
fb_scale);
|
2020-11-23 04:56:46 -05:00
|
|
|
|
2021-05-10 07:27:39 -04:00
|
|
|
if (G_UNLIKELY (paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION))
|
2020-11-23 04:56:46 -05:00
|
|
|
{
|
|
|
|
queued_redraw_clip =
|
|
|
|
scale_offset_and_clamp_region (fb_clip_region,
|
|
|
|
1.0 / fb_scale,
|
|
|
|
view_rect.x,
|
|
|
|
view_rect.y);
|
|
|
|
}
|
2011-02-24 19:31:41 -05:00
|
|
|
}
|
2014-12-03 07:05:37 -05:00
|
|
|
else
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
2020-02-05 10:43:40 -05:00
|
|
|
cairo_rectangle_int_t fb_rect;
|
|
|
|
|
|
|
|
fb_rect = (cairo_rectangle_int_t) {
|
|
|
|
.width = fb_width,
|
|
|
|
.height = fb_height,
|
|
|
|
};
|
|
|
|
fb_clip_region = cairo_region_create_rectangle (&fb_rect);
|
|
|
|
|
2021-06-09 01:48:57 -04:00
|
|
|
g_clear_pointer (&redraw_clip, cairo_region_destroy);
|
|
|
|
redraw_clip = cairo_region_create_rectangle (&view_rect);
|
|
|
|
|
2021-05-10 07:27:39 -04:00
|
|
|
if (G_UNLIKELY (paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION))
|
2020-11-23 04:56:46 -05:00
|
|
|
queued_redraw_clip = cairo_region_reference (redraw_clip);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
2010-11-16 08:54:15 -05:00
|
|
|
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
g_return_if_fail (!cairo_region_is_empty (fb_clip_region));
|
2013-08-14 06:27:48 -04:00
|
|
|
|
2022-01-10 16:50:13 -05:00
|
|
|
/* XXX: It seems there will be a race here in that the stage
|
|
|
|
* window may be resized before the cogl_onscreen_swap_region
|
|
|
|
* is handled and so we may copy the wrong region. I can't
|
|
|
|
* really see how we can handle this with the current state of X
|
|
|
|
* but at least in this case a full redraw should be queued by
|
|
|
|
* the resize anyway so it should only exhibit temporary
|
|
|
|
* artefacts.
|
|
|
|
*/
|
|
|
|
/* swap_region does not need damage history, set it up before that */
|
|
|
|
if (use_clipped_redraw)
|
|
|
|
swap_region = cairo_region_copy (fb_clip_region);
|
|
|
|
else
|
|
|
|
swap_region = cairo_region_create ();
|
|
|
|
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
swap_with_damage = FALSE;
|
2015-01-28 17:08:03 -05:00
|
|
|
if (has_buffer_age)
|
2013-02-06 05:05:58 -05:00
|
|
|
{
|
2021-05-10 15:56:19 -04:00
|
|
|
clutter_damage_history_record (damage_history, fb_clip_region);
|
2020-03-06 06:59:41 -05:00
|
|
|
|
2020-03-06 06:35:27 -05:00
|
|
|
if (use_clipped_redraw)
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
2020-05-06 03:11:34 -04:00
|
|
|
int age;
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
2020-05-06 03:11:34 -04:00
|
|
|
for (age = 1; age <= buffer_age; age++)
|
2020-03-19 17:30:06 -04:00
|
|
|
{
|
2020-05-06 03:11:34 -04:00
|
|
|
const cairo_region_t *old_damage;
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
2020-05-06 03:11:34 -04:00
|
|
|
old_damage =
|
2021-05-10 15:56:19 -04:00
|
|
|
clutter_damage_history_lookup (damage_history, age);
|
2020-12-17 02:25:35 -05:00
|
|
|
cairo_region_union (fb_clip_region, old_damage);
|
2020-03-19 17:30:06 -04:00
|
|
|
}
|
2020-02-06 02:46:41 -05:00
|
|
|
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND,
|
|
|
|
"Reusing back buffer(age=%d) - repairing region: num rects: %d",
|
|
|
|
buffer_age,
|
|
|
|
cairo_region_num_rectangles (fb_clip_region));
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
2020-03-19 17:30:06 -04:00
|
|
|
swap_with_damage = TRUE;
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
2020-05-06 03:11:34 -04:00
|
|
|
|
2021-05-10 15:56:19 -04:00
|
|
|
clutter_damage_history_step (damage_history);
|
2013-02-06 05:05:58 -05:00
|
|
|
}
|
|
|
|
|
2020-11-09 02:39:40 -05:00
|
|
|
if (use_clipped_redraw)
|
|
|
|
{
|
2022-01-08 10:01:24 -05:00
|
|
|
/* Regenerate redraw_clip because:
|
|
|
|
* 1. It's missing the regions added from damage_history above; and
|
|
|
|
* 2. If using fractional scaling then it might be a fraction of a
|
|
|
|
* logical pixel (or one physical pixel) smaller than
|
|
|
|
* fb_clip_region, due to the clamping from
|
|
|
|
* offset_scale_and_clamp_region. So we need to ensure redraw_clip
|
|
|
|
* is a superset of fb_clip_region to avoid such gaps.
|
2020-11-09 02:39:40 -05:00
|
|
|
*/
|
2022-01-08 10:01:24 -05:00
|
|
|
cairo_region_destroy (redraw_clip);
|
|
|
|
redraw_clip = scale_offset_and_clamp_region (fb_clip_region,
|
|
|
|
1.0 / fb_scale,
|
|
|
|
view_rect.x,
|
|
|
|
view_rect.y);
|
2020-11-09 02:39:40 -05:00
|
|
|
}
|
|
|
|
|
2021-05-10 07:27:39 -04:00
|
|
|
if (paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION)
|
2020-11-18 04:49:59 -05:00
|
|
|
{
|
|
|
|
cairo_region_t *debug_redraw_clip;
|
|
|
|
|
|
|
|
debug_redraw_clip = cairo_region_create_rectangle (&view_rect);
|
2021-05-10 15:15:53 -04:00
|
|
|
paint_stage (stage_impl, stage_view, debug_redraw_clip);
|
2020-11-18 04:49:59 -05:00
|
|
|
cairo_region_destroy (debug_redraw_clip);
|
|
|
|
}
|
|
|
|
else if (use_clipped_redraw)
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
2022-01-08 10:01:24 -05:00
|
|
|
queue_damage_region (stage_window, stage_view, fb_clip_region);
|
2021-09-22 16:26:23 -04:00
|
|
|
|
2022-01-08 10:01:24 -05:00
|
|
|
cogl_framebuffer_push_region_clip (fb, fb_clip_region);
|
2019-02-28 21:49:33 -05:00
|
|
|
|
2022-01-08 10:01:24 -05:00
|
|
|
paint_stage (stage_impl, stage_view, redraw_clip);
|
2019-02-28 21:49:33 -05:00
|
|
|
|
2013-12-03 07:12:52 -05:00
|
|
|
cogl_framebuffer_pop_clip (fb);
|
2010-11-16 08:54:15 -05:00
|
|
|
}
|
|
|
|
else
|
2011-05-08 19:27:10 -04:00
|
|
|
{
|
2021-07-16 13:12:01 -04:00
|
|
|
meta_topic (META_DEBUG_BACKEND, "Unclipped stage paint");
|
2011-05-08 19:27:10 -04:00
|
|
|
|
2022-01-08 10:01:24 -05:00
|
|
|
paint_stage (stage_impl, stage_view, redraw_clip);
|
2011-05-08 19:27:10 -04:00
|
|
|
}
|
2010-11-16 08:54:15 -05:00
|
|
|
|
2022-01-08 10:01:24 -05:00
|
|
|
g_clear_pointer (&redraw_clip, cairo_region_destroy);
|
|
|
|
g_clear_pointer (&fb_clip_region, cairo_region_destroy);
|
2019-07-20 11:52:11 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
COGL_TRACE_BEGIN_SCOPED (MetaStageImplRedrawViewSwapFramebuffer,
|
2020-03-06 06:35:27 -05:00
|
|
|
"Paint (swap framebuffer)");
|
2020-03-06 05:33:30 -05:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
if (clutter_stage_view_get_onscreen (stage_view) !=
|
|
|
|
clutter_stage_view_get_framebuffer (stage_view))
|
2020-03-06 06:35:27 -05:00
|
|
|
{
|
|
|
|
cairo_region_t *transformed_swap_region;
|
2019-07-27 12:39:04 -04:00
|
|
|
|
2020-03-06 06:35:27 -05:00
|
|
|
transformed_swap_region =
|
2021-05-10 15:15:53 -04:00
|
|
|
transform_swap_region_to_onscreen (stage_view, swap_region);
|
2019-07-27 12:39:04 -04:00
|
|
|
cairo_region_destroy (swap_region);
|
2020-03-06 06:35:27 -05:00
|
|
|
swap_region = transformed_swap_region;
|
2019-08-27 13:16:01 -04:00
|
|
|
}
|
2020-03-06 06:35:27 -05:00
|
|
|
|
|
|
|
if (queued_redraw_clip)
|
2019-08-27 13:16:01 -04:00
|
|
|
{
|
2020-11-18 03:20:57 -05:00
|
|
|
cairo_region_t *swap_region_in_stage_space;
|
|
|
|
|
|
|
|
swap_region_in_stage_space =
|
|
|
|
scale_offset_and_clamp_region (swap_region,
|
|
|
|
1.0f / fb_scale,
|
|
|
|
view_rect.x,
|
|
|
|
view_rect.y);
|
|
|
|
|
2020-11-18 05:09:32 -05:00
|
|
|
cairo_region_subtract (swap_region_in_stage_space, queued_redraw_clip);
|
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
paint_damage_region (stage_window, stage_view,
|
2020-11-18 03:20:57 -05:00
|
|
|
swap_region_in_stage_space, queued_redraw_clip);
|
|
|
|
|
2020-03-06 06:35:27 -05:00
|
|
|
cairo_region_destroy (queued_redraw_clip);
|
2020-11-18 03:20:57 -05:00
|
|
|
cairo_region_destroy (swap_region_in_stage_space);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
2020-03-06 06:35:27 -05:00
|
|
|
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
swap_framebuffer (stage_window,
|
2021-05-10 15:15:53 -04:00
|
|
|
stage_view,
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
swap_region,
|
2020-10-09 16:00:29 -04:00
|
|
|
swap_with_damage,
|
|
|
|
frame);
|
2020-03-06 06:35:27 -05:00
|
|
|
|
|
|
|
cairo_region_destroy (swap_region);
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
}
|
2011-05-08 19:27:10 -04:00
|
|
|
|
2020-09-10 11:41:06 -04:00
|
|
|
static gboolean
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_scanout_view (MetaStageImpl *stage_impl,
|
|
|
|
ClutterStageView *stage_view,
|
|
|
|
CoglScanout *scanout,
|
|
|
|
ClutterFrame *frame,
|
|
|
|
GError **error)
|
2019-09-12 05:28:50 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImplPrivate *priv =
|
|
|
|
meta_stage_impl_get_instance_private (stage_impl);
|
|
|
|
CoglFramebuffer *framebuffer =
|
2022-06-15 17:21:27 -04:00
|
|
|
clutter_stage_view_get_onscreen (stage_view);
|
2021-01-06 07:37:13 -05:00
|
|
|
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
|
2019-09-12 05:28:50 -04:00
|
|
|
CoglOnscreen *onscreen;
|
2020-05-22 15:52:29 -04:00
|
|
|
CoglFrameInfo *frame_info;
|
2019-09-12 05:28:50 -04:00
|
|
|
|
2020-10-13 05:35:47 -04:00
|
|
|
g_assert (COGL_IS_ONSCREEN (framebuffer));
|
2019-09-12 05:28:50 -04:00
|
|
|
|
|
|
|
onscreen = COGL_ONSCREEN (framebuffer);
|
2020-05-22 15:52:29 -04:00
|
|
|
|
2021-01-06 07:37:13 -05:00
|
|
|
frame_info = cogl_frame_info_new (cogl_context, priv->global_frame_counter);
|
2020-09-10 11:41:06 -04:00
|
|
|
|
2020-10-09 16:00:29 -04:00
|
|
|
if (!cogl_onscreen_direct_scanout (onscreen,
|
|
|
|
scanout,
|
|
|
|
frame_info,
|
|
|
|
frame,
|
|
|
|
error))
|
2020-09-10 11:41:06 -04:00
|
|
|
{
|
|
|
|
cogl_object_unref (frame_info);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-05-22 16:30:45 -04:00
|
|
|
priv->global_frame_counter++;
|
2020-05-22 15:52:29 -04:00
|
|
|
|
2020-09-10 11:41:06 -04:00
|
|
|
return TRUE;
|
2019-09-12 05:28:50 -04:00
|
|
|
}
|
|
|
|
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_redraw_view (ClutterStageWindow *stage_window,
|
|
|
|
ClutterStageView *stage_view,
|
|
|
|
ClutterFrame *frame)
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
g_autoptr (CoglScanout) scanout = NULL;
|
Introduce regional stage rendering
Add support for drawing a stage using multiple framebuffers each making
up one part of the stage. This works by the stage backend
(ClutterStageWindow) providing a list of views which will be for
splitting up the stage in different regions.
A view layout, for now, is a set of rectangles. The stage window (i.e.
stage "backend" will use this information when drawing a frame, using
one framebuffer for each view. The scene graph is adapted to explictly
take a view when painting the stage. It will use this view, its
assigned framebuffer and layout to offset and clip the drawing
accordingly.
This effectively removes any notion of "stage framebuffer", since each
stage now may consist of multiple framebuffers. Therefore, API
involving this has been deprecated and made no-ops; namely
clutter_stage_ensure_context(). Callers are now assumed to either
always use a framebuffer reference explicitly, or push/pop the
framebuffer of a given view where the code has not yet changed to use
the explicit-buffer-using cogl API.
Currently only the nested X11 backend supports this mode fully, and the
per view framebuffers are all offscreen. Upon frame completion, it'll
blit each view's framebuffer onto the onscreen framebuffer before
swapping.
Other backends (X11 CM and native/KMS) are adapted to manage a
full-stage view. The X11 CM backend will continue to use this method,
while the native/KMS backend will be adopted to use multiple view
drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-05-26 23:09:24 -04:00
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
scanout = clutter_stage_view_take_scanout (stage_view);
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
if (scanout)
|
2020-09-10 11:41:06 -04:00
|
|
|
{
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
if (meta_stage_impl_scanout_view (stage_impl,
|
|
|
|
stage_view,
|
|
|
|
scanout,
|
|
|
|
frame,
|
|
|
|
&error))
|
2022-06-25 16:14:41 -04:00
|
|
|
{
|
|
|
|
clutter_stage_view_accumulate_redraw_clip (stage_view);
|
|
|
|
return;
|
|
|
|
}
|
2020-09-10 11:41:06 -04:00
|
|
|
|
2020-10-09 17:17:06 -04:00
|
|
|
if (!g_error_matches (error,
|
|
|
|
COGL_SCANOUT_ERROR,
|
|
|
|
COGL_SCANOUT_ERROR_INHIBITED))
|
|
|
|
g_warning ("Failed to scan out client buffer: %s", error->message);
|
2020-09-10 11:41:06 -04:00
|
|
|
}
|
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_redraw_view_primary (stage_impl, stage_view, frame);
|
2011-05-08 19:27:10 -04:00
|
|
|
}
|
|
|
|
|
2020-10-09 19:02:28 -04:00
|
|
|
void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_add_onscreen_frame_info (MetaStageImpl *stage_impl,
|
|
|
|
ClutterStageView *stage_view)
|
2020-10-09 19:02:28 -04:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImplPrivate *priv =
|
|
|
|
meta_stage_impl_get_instance_private (stage_impl);
|
|
|
|
CoglFramebuffer *framebuffer = clutter_stage_view_get_onscreen (stage_view);
|
2021-01-06 07:37:13 -05:00
|
|
|
CoglContext *cogl_context = cogl_framebuffer_get_context (framebuffer);
|
2020-10-09 19:02:28 -04:00
|
|
|
CoglFrameInfo *frame_info;
|
|
|
|
|
2021-01-06 07:37:13 -05:00
|
|
|
frame_info = cogl_frame_info_new (cogl_context, priv->global_frame_counter);
|
2020-10-09 19:02:28 -04:00
|
|
|
priv->global_frame_counter++;
|
|
|
|
|
|
|
|
cogl_onscreen_add_frame_info (COGL_ONSCREEN (framebuffer), frame_info);
|
|
|
|
}
|
|
|
|
|
2011-02-09 11:16:57 -05:00
|
|
|
static void
|
2019-01-08 07:51:47 -05:00
|
|
|
clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
|
2011-02-09 11:16:57 -05:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
iface->realize = meta_stage_impl_realize;
|
|
|
|
iface->unrealize = meta_stage_impl_unrealize;
|
|
|
|
iface->get_wrapper = meta_stage_impl_get_wrapper;
|
|
|
|
iface->resize = meta_stage_impl_resize;
|
|
|
|
iface->show = meta_stage_impl_show;
|
|
|
|
iface->hide = meta_stage_impl_hide;
|
|
|
|
iface->get_frame_counter = meta_stage_impl_get_frame_counter;
|
|
|
|
iface->redraw_view = meta_stage_impl_redraw_view;
|
2011-02-09 11:16:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_set_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2011-02-09 11:16:57 -05:00
|
|
|
{
|
2021-05-10 15:15:53 -04:00
|
|
|
MetaStageImpl *self = META_STAGE_IMPL (gobject);
|
2021-09-17 12:24:28 -04:00
|
|
|
MetaStageImplPrivate *priv = meta_stage_impl_get_instance_private (self);
|
2011-08-26 18:16:12 -04:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_WRAPPER:
|
2011-11-04 12:52:44 -04:00
|
|
|
self->wrapper = g_value_get_object (value);
|
2011-08-26 18:16:12 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_BACKEND:
|
2021-09-17 12:24:28 -04:00
|
|
|
priv->backend = g_value_get_object (value);
|
2011-08-26 18:16:12 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2011-02-09 11:16:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_class_init (MetaStageImplClass *klass)
|
2011-02-09 11:16:57 -05:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2021-05-10 15:15:53 -04:00
|
|
|
gobject_class->set_property = meta_stage_impl_set_property;
|
2011-08-26 18:16:12 -04:00
|
|
|
|
2021-09-17 11:31:03 -04:00
|
|
|
obj_props[PROP_WRAPPER] =
|
|
|
|
g_param_spec_object ("wrapper",
|
|
|
|
"Wrapper",
|
|
|
|
"Back pointer to the Stage actor",
|
|
|
|
CLUTTER_TYPE_STAGE,
|
|
|
|
G_PARAM_WRITABLE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
obj_props[PROP_BACKEND] =
|
|
|
|
g_param_spec_object ("backend",
|
2021-09-17 12:24:28 -04:00
|
|
|
"MetaBackend",
|
|
|
|
"MetaBackend",
|
|
|
|
META_TYPE_BACKEND,
|
2021-09-17 11:31:03 -04:00
|
|
|
G_PARAM_WRITABLE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
g_object_class_install_properties (gobject_class, N_PROPS, obj_props);
|
2011-02-09 11:16:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-05-10 15:15:53 -04:00
|
|
|
meta_stage_impl_init (MetaStageImpl *stage)
|
2011-02-09 11:16:57 -05:00
|
|
|
{
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-29 18:27:56 -04:00
|
|
|
}
|
2021-09-17 12:24:28 -04:00
|
|
|
|
|
|
|
MetaBackend *
|
|
|
|
meta_stage_impl_get_backend (MetaStageImpl *stage_impl)
|
|
|
|
{
|
|
|
|
MetaStageImplPrivate *priv =
|
|
|
|
meta_stage_impl_get_instance_private (stage_impl);
|
|
|
|
|
|
|
|
return priv->backend;
|
|
|
|
}
|