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-27 11:09:24 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "clutter-build-config.h"
|
|
|
|
|
|
|
|
#include "clutter/clutter-stage-view.h"
|
2019-06-17 18:24:02 -03:00
|
|
|
#include "clutter/clutter-stage-view-private.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-27 11:09:24 +08:00
|
|
|
|
|
|
|
#include <cairo-gobject.h>
|
2017-05-25 15:54:37 +08: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-27 11:09:24 +08:00
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
#include "clutter/clutter-damage-history.h"
|
2020-05-22 22:57:39 +02:00
|
|
|
#include "clutter/clutter-frame-clock.h"
|
2020-10-09 18:16:16 +02:00
|
|
|
#include "clutter/clutter-frame-private.h"
|
2020-02-06 10:12:54 +01:00
|
|
|
#include "clutter/clutter-private.h"
|
2019-09-12 11:28:50 +02:00
|
|
|
#include "clutter/clutter-mutter.h"
|
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-30 00:27:56 +02:00
|
|
|
#include "clutter/clutter-stage-private.h"
|
2019-09-12 11:28:50 +02:00
|
|
|
#include "cogl/cogl.h"
|
2020-02-06 10:12:54 +01: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-27 11:09:24 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
2020-04-30 10:42:30 +02:00
|
|
|
PROP_NAME,
|
2020-03-30 17:34:43 +02:00
|
|
|
PROP_STAGE,
|
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-27 11:09:24 +08:00
|
|
|
PROP_LAYOUT,
|
|
|
|
PROP_FRAMEBUFFER,
|
2016-08-01 02:44:57 +02:00
|
|
|
PROP_OFFSCREEN,
|
2020-04-30 17:53:30 +02:00
|
|
|
PROP_USE_SHADOWFB,
|
2017-02-24 17:38:47 +08:00
|
|
|
PROP_SCALE,
|
2020-04-17 09:18:37 +02:00
|
|
|
PROP_REFRESH_RATE,
|
2021-01-06 15:18:26 +03:00
|
|
|
PROP_VBLANK_DURATION_US,
|
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-27 11:09:24 +08:00
|
|
|
|
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *obj_props[PROP_LAST];
|
|
|
|
|
|
|
|
typedef struct _ClutterStageViewPrivate
|
|
|
|
{
|
2020-04-30 10:42:30 +02:00
|
|
|
char *name;
|
|
|
|
|
2020-03-30 17:34:43 +02:00
|
|
|
ClutterStage *stage;
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
cairo_rectangle_int_t layout;
|
2017-05-25 15:54:37 +08:00
|
|
|
float scale;
|
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-27 11:09:24 +08:00
|
|
|
CoglFramebuffer *framebuffer;
|
2016-08-01 02:44:57 +02:00
|
|
|
|
|
|
|
CoglOffscreen *offscreen;
|
2019-10-22 17:03:03 +02:00
|
|
|
CoglPipeline *offscreen_pipeline;
|
|
|
|
|
2020-04-30 17:53:30 +02:00
|
|
|
gboolean use_shadowfb;
|
2020-04-30 18:19:30 +02:00
|
|
|
struct {
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
struct {
|
|
|
|
CoglDmaBufHandle *handles[2];
|
|
|
|
int current_idx;
|
|
|
|
ClutterDamageHistory *damage_history;
|
|
|
|
} dma_buf;
|
|
|
|
|
2020-04-30 18:19:30 +02:00
|
|
|
CoglOffscreen *framebuffer;
|
|
|
|
} shadow;
|
2016-08-01 02:44:57 +02:00
|
|
|
|
2019-09-12 11:28:50 +02:00
|
|
|
CoglScanout *next_scanout;
|
|
|
|
|
2020-02-06 10:12:54 +01:00
|
|
|
gboolean has_redraw_clip;
|
|
|
|
cairo_region_t *redraw_clip;
|
2022-06-25 22:14:41 +02:00
|
|
|
gboolean has_accumulated_redraw_clip;
|
|
|
|
cairo_region_t *accumulated_redraw_clip;
|
2020-02-06 10:12:54 +01:00
|
|
|
|
2020-04-17 09:18:37 +02:00
|
|
|
float refresh_rate;
|
2021-01-06 15:18:26 +03:00
|
|
|
int64_t vblank_duration_us;
|
2020-05-22 22:57:39 +02:00
|
|
|
ClutterFrameClock *frame_clock;
|
2020-04-17 09:18:37 +02:00
|
|
|
|
2021-01-25 17:45:47 +08:00
|
|
|
struct {
|
|
|
|
int frame_count;
|
|
|
|
int64_t last_print_time_us;
|
|
|
|
int64_t cumulative_draw_time_us;
|
|
|
|
int64_t began_draw_time_us;
|
|
|
|
int64_t worst_draw_time_us;
|
|
|
|
} frame_timings;
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
guint dirty_viewport : 1;
|
|
|
|
guint dirty_projection : 1;
|
2022-01-26 18:39:27 +01:00
|
|
|
guint needs_update_devices : 1;
|
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-27 11:09:24 +08:00
|
|
|
} ClutterStageViewPrivate;
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (ClutterStageView, clutter_stage_view, G_TYPE_OBJECT)
|
|
|
|
|
2020-08-12 15:28:34 +02:00
|
|
|
void
|
|
|
|
clutter_stage_view_destroy (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
g_object_run_dispose (G_OBJECT (view));
|
|
|
|
g_object_unref (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-27 11:09:24 +08:00
|
|
|
void
|
|
|
|
clutter_stage_view_get_layout (ClutterStageView *view,
|
|
|
|
cairo_rectangle_int_t *rect)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
*rect = priv->layout;
|
|
|
|
}
|
|
|
|
|
2019-06-17 18:32:12 -03:00
|
|
|
/**
|
|
|
|
* clutter_stage_view_get_framebuffer:
|
|
|
|
* @view: a #ClutterStageView
|
|
|
|
*
|
|
|
|
* Retrieves the framebuffer of @view to draw to.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): a #CoglFramebuffer
|
|
|
|
*/
|
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-27 11:09:24 +08:00
|
|
|
CoglFramebuffer *
|
|
|
|
clutter_stage_view_get_framebuffer (ClutterStageView *view)
|
2016-08-01 02:44:57 +02:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
if (priv->offscreen)
|
2020-05-22 22:37:47 +02:00
|
|
|
return COGL_FRAMEBUFFER (priv->offscreen);
|
2020-04-30 18:19:30 +02:00
|
|
|
else if (priv->shadow.framebuffer)
|
2020-05-22 22:37:47 +02:00
|
|
|
return COGL_FRAMEBUFFER (priv->shadow.framebuffer);
|
2016-08-01 02:44:57 +02:00
|
|
|
else
|
|
|
|
return priv->framebuffer;
|
|
|
|
}
|
|
|
|
|
2019-06-17 18:32:12 -03:00
|
|
|
/**
|
|
|
|
* clutter_stage_view_get_onscreen:
|
|
|
|
* @view: a #ClutterStageView
|
|
|
|
*
|
|
|
|
* Retrieves the onscreen framebuffer of @view if available.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): a #CoglFramebuffer
|
|
|
|
*/
|
2016-08-01 02:44:57 +02:00
|
|
|
CoglFramebuffer *
|
|
|
|
clutter_stage_view_get_onscreen (ClutterStageView *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-27 11:09:24 +08:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->framebuffer;
|
|
|
|
}
|
|
|
|
|
2019-10-22 17:03:03 +02:00
|
|
|
static CoglPipeline *
|
2020-05-22 22:37:47 +02:00
|
|
|
clutter_stage_view_create_offscreen_pipeline (CoglOffscreen *offscreen)
|
2019-10-22 17:03:03 +02:00
|
|
|
{
|
2020-05-22 22:37:47 +02:00
|
|
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
|
2019-10-22 17:03:03 +02:00
|
|
|
CoglPipeline *pipeline;
|
|
|
|
|
|
|
|
pipeline = cogl_pipeline_new (cogl_framebuffer_get_context (framebuffer));
|
|
|
|
|
|
|
|
cogl_pipeline_set_layer_filters (pipeline, 0,
|
|
|
|
COGL_PIPELINE_FILTER_NEAREST,
|
|
|
|
COGL_PIPELINE_FILTER_NEAREST);
|
|
|
|
cogl_pipeline_set_layer_texture (pipeline, 0,
|
2020-05-22 22:37:47 +02:00
|
|
|
cogl_offscreen_get_texture (offscreen));
|
2019-10-22 17:03:03 +02:00
|
|
|
cogl_pipeline_set_layer_wrap_mode (pipeline, 0,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE);
|
|
|
|
|
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2016-08-01 02:44:57 +02:00
|
|
|
static void
|
|
|
|
clutter_stage_view_ensure_offscreen_blit_pipeline (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
ClutterStageViewClass *view_class =
|
|
|
|
CLUTTER_STAGE_VIEW_GET_CLASS (view);
|
|
|
|
|
|
|
|
g_assert (priv->offscreen != NULL);
|
|
|
|
|
2019-10-22 17:03:03 +02:00
|
|
|
if (priv->offscreen_pipeline)
|
2016-08-01 02:44:57 +02:00
|
|
|
return;
|
|
|
|
|
2019-10-22 17:03:03 +02:00
|
|
|
priv->offscreen_pipeline =
|
2020-05-22 22:37:47 +02:00
|
|
|
clutter_stage_view_create_offscreen_pipeline (priv->offscreen);
|
2016-08-01 02:44:57 +02:00
|
|
|
|
|
|
|
if (view_class->setup_offscreen_blit_pipeline)
|
2019-10-22 17:03:03 +02:00
|
|
|
view_class->setup_offscreen_blit_pipeline (view, priv->offscreen_pipeline);
|
2016-08-01 02:44:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-10-22 17:03:03 +02:00
|
|
|
clutter_stage_view_invalidate_offscreen_blit_pipeline (ClutterStageView *view)
|
2016-08-01 02:44:57 +02:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
2019-10-22 17:03:03 +02:00
|
|
|
|
|
|
|
g_clear_pointer (&priv->offscreen_pipeline, cogl_object_unref);
|
|
|
|
}
|
|
|
|
|
2020-05-05 19:05:36 +02:00
|
|
|
void
|
|
|
|
clutter_stage_view_transform_rect_to_onscreen (ClutterStageView *view,
|
|
|
|
const cairo_rectangle_int_t *src_rect,
|
|
|
|
int dst_width,
|
|
|
|
int dst_height,
|
|
|
|
cairo_rectangle_int_t *dst_rect)
|
|
|
|
{
|
|
|
|
ClutterStageViewClass *view_class = CLUTTER_STAGE_VIEW_GET_CLASS (view);
|
|
|
|
|
|
|
|
return view_class->transform_rect_to_onscreen (view,
|
|
|
|
src_rect,
|
|
|
|
dst_width,
|
|
|
|
dst_height,
|
|
|
|
dst_rect);
|
|
|
|
}
|
|
|
|
|
2019-10-22 17:03:03 +02:00
|
|
|
static void
|
2020-05-05 19:22:10 +02:00
|
|
|
paint_transformed_framebuffer (ClutterStageView *view,
|
|
|
|
CoglPipeline *pipeline,
|
2020-05-22 22:37:47 +02:00
|
|
|
CoglOffscreen *src_framebuffer,
|
2020-05-05 19:22:10 +02:00
|
|
|
CoglFramebuffer *dst_framebuffer,
|
|
|
|
const cairo_region_t *redraw_clip)
|
2019-10-22 17:03:03 +02:00
|
|
|
{
|
2020-09-11 15:57:28 -03:00
|
|
|
graphene_matrix_t matrix;
|
2020-05-05 19:22:10 +02:00
|
|
|
unsigned int n_rectangles, i;
|
|
|
|
int dst_width, dst_height;
|
|
|
|
cairo_rectangle_int_t view_layout;
|
|
|
|
cairo_rectangle_int_t onscreen_layout;
|
|
|
|
float view_scale;
|
|
|
|
float *coordinates;
|
|
|
|
|
|
|
|
dst_width = cogl_framebuffer_get_width (dst_framebuffer);
|
|
|
|
dst_height = cogl_framebuffer_get_height (dst_framebuffer);
|
|
|
|
clutter_stage_view_get_layout (view, &view_layout);
|
|
|
|
clutter_stage_view_transform_rect_to_onscreen (view,
|
|
|
|
&(cairo_rectangle_int_t) {
|
|
|
|
.width = view_layout.width,
|
|
|
|
.height = view_layout.height,
|
|
|
|
},
|
|
|
|
view_layout.width,
|
|
|
|
view_layout.height,
|
|
|
|
&onscreen_layout);
|
|
|
|
view_scale = clutter_stage_view_get_scale (view);
|
2016-08-01 02:44:57 +02:00
|
|
|
|
2019-10-22 17:03:03 +02:00
|
|
|
cogl_framebuffer_push_matrix (dst_framebuffer);
|
2016-08-01 02:44:57 +02:00
|
|
|
|
2020-09-11 16:39:50 -03:00
|
|
|
graphene_matrix_init_translate (&matrix,
|
|
|
|
&GRAPHENE_POINT3D_INIT (-dst_width / 2.0,
|
|
|
|
-dst_height / 2.0,
|
|
|
|
0.f));
|
|
|
|
graphene_matrix_scale (&matrix,
|
|
|
|
1.0 / (dst_width / 2.0),
|
|
|
|
-1.0 / (dst_height / 2.0),
|
|
|
|
0.f);
|
2019-10-22 17:03:03 +02:00
|
|
|
cogl_framebuffer_set_projection_matrix (dst_framebuffer, &matrix);
|
2020-05-05 19:22:10 +02:00
|
|
|
cogl_framebuffer_set_viewport (dst_framebuffer,
|
|
|
|
0, 0, dst_width, dst_height);
|
2016-08-01 02:44:57 +02:00
|
|
|
|
2020-05-05 19:22:10 +02:00
|
|
|
n_rectangles = cairo_region_num_rectangles (redraw_clip);
|
|
|
|
coordinates = g_newa (float, 2 * 4 * n_rectangles);
|
|
|
|
|
|
|
|
for (i = 0; i < n_rectangles; i++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t src_rect;
|
|
|
|
cairo_rectangle_int_t dst_rect;
|
|
|
|
|
|
|
|
cairo_region_get_rectangle (redraw_clip, i, &src_rect);
|
|
|
|
_clutter_util_rectangle_offset (&src_rect,
|
|
|
|
-view_layout.x,
|
|
|
|
-view_layout.y,
|
|
|
|
&src_rect);
|
|
|
|
|
|
|
|
clutter_stage_view_transform_rect_to_onscreen (view,
|
|
|
|
&src_rect,
|
|
|
|
onscreen_layout.width,
|
|
|
|
onscreen_layout.height,
|
|
|
|
&dst_rect);
|
|
|
|
|
|
|
|
coordinates[i * 8 + 0] = (float) dst_rect.x * view_scale;
|
|
|
|
coordinates[i * 8 + 1] = (float) dst_rect.y * view_scale;
|
|
|
|
coordinates[i * 8 + 2] = ((float) (dst_rect.x + dst_rect.width) *
|
|
|
|
view_scale);
|
|
|
|
coordinates[i * 8 + 3] = ((float) (dst_rect.y + dst_rect.height) *
|
|
|
|
view_scale);
|
|
|
|
|
|
|
|
coordinates[i * 8 + 4] = (((float) dst_rect.x / (float) dst_width) *
|
|
|
|
view_scale);
|
|
|
|
coordinates[i * 8 + 5] = (((float) dst_rect.y / (float) dst_height) *
|
|
|
|
view_scale);
|
|
|
|
coordinates[i * 8 + 6] = ((float) (dst_rect.x + dst_rect.width) /
|
|
|
|
(float) dst_width) * view_scale;
|
|
|
|
coordinates[i * 8 + 7] = ((float) (dst_rect.y + dst_rect.height) /
|
|
|
|
(float) dst_height) * view_scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
cogl_framebuffer_draw_textured_rectangles (dst_framebuffer,
|
|
|
|
pipeline,
|
|
|
|
coordinates,
|
|
|
|
n_rectangles);
|
2016-08-01 02:44:57 +02:00
|
|
|
|
2019-10-22 17:03:03 +02:00
|
|
|
cogl_framebuffer_pop_matrix (dst_framebuffer);
|
|
|
|
}
|
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
static gboolean
|
|
|
|
is_shadowfb_double_buffered (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->shadow.dma_buf.handles[0] && priv->shadow.dma_buf.handles[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
init_dma_buf_shadowfbs (ClutterStageView *view,
|
|
|
|
CoglContext *cogl_context,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context);
|
|
|
|
CoglFramebuffer *initial_shadowfb;
|
|
|
|
|
|
|
|
if (!cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE))
|
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
|
|
"Buffer age not supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-10-13 11:35:47 +02:00
|
|
|
if (!COGL_IS_ONSCREEN (priv->framebuffer))
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
|
|
"Tried to use shadow buffer without onscreen");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->shadow.dma_buf.handles[0] = cogl_renderer_create_dma_buf (cogl_renderer,
|
|
|
|
width, height,
|
|
|
|
error);
|
|
|
|
if (!priv->shadow.dma_buf.handles[0])
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
priv->shadow.dma_buf.handles[1] = cogl_renderer_create_dma_buf (cogl_renderer,
|
|
|
|
width, height,
|
|
|
|
error);
|
|
|
|
if (!priv->shadow.dma_buf.handles[1])
|
|
|
|
{
|
|
|
|
g_clear_pointer (&priv->shadow.dma_buf.handles[0],
|
|
|
|
cogl_dma_buf_handle_free);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->shadow.dma_buf.damage_history = clutter_damage_history_new ();
|
|
|
|
|
|
|
|
initial_shadowfb =
|
|
|
|
cogl_dma_buf_handle_get_framebuffer (priv->shadow.dma_buf.handles[0]);
|
2020-10-13 11:35:47 +02:00
|
|
|
priv->shadow.framebuffer = COGL_OFFSCREEN (g_object_ref (initial_shadowfb));
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-04-30 17:53:30 +02:00
|
|
|
static CoglOffscreen *
|
|
|
|
create_offscreen_framebuffer (CoglContext *context,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
CoglOffscreen *framebuffer;
|
|
|
|
CoglTexture2D *texture;
|
|
|
|
|
|
|
|
texture = cogl_texture_2d_new_with_size (context, width, height);
|
|
|
|
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (texture),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
if (!cogl_texture_allocate (COGL_TEXTURE (texture), error))
|
|
|
|
{
|
|
|
|
cogl_object_unref (texture);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
framebuffer = cogl_offscreen_new_with_texture (COGL_TEXTURE (texture));
|
|
|
|
cogl_object_unref (texture);
|
|
|
|
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (framebuffer), error))
|
|
|
|
{
|
2020-10-13 11:35:47 +02:00
|
|
|
g_object_unref (framebuffer);
|
2020-04-30 17:53:30 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return framebuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
init_fallback_shadowfb (ClutterStageView *view,
|
|
|
|
CoglContext *cogl_context,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
GError **error)
|
2020-04-30 17:53:30 +02:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
CoglOffscreen *offscreen;
|
|
|
|
|
|
|
|
offscreen = create_offscreen_framebuffer (cogl_context, width, height, error);
|
|
|
|
if (!offscreen)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-04-30 18:19:30 +02:00
|
|
|
priv->shadow.framebuffer = offscreen;
|
2020-04-30 17:53:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_shadowfb (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
CoglContext *cogl_context;
|
|
|
|
|
|
|
|
width = cogl_framebuffer_get_width (priv->framebuffer);
|
|
|
|
height = cogl_framebuffer_get_height (priv->framebuffer);
|
|
|
|
cogl_context = cogl_framebuffer_get_context (priv->framebuffer);
|
|
|
|
|
2021-02-10 09:39:18 +01:00
|
|
|
if (g_strcmp0 (g_getenv ("MUTTER_DEBUG_ENABLE_DOUBLE_SHADOWFB"), "1") == 0)
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
{
|
2021-02-10 09:39:18 +01:00
|
|
|
if (init_dma_buf_shadowfbs (view, cogl_context, width, height, &error))
|
|
|
|
{
|
|
|
|
g_message ("Initialized double buffered shadow fb for %s",
|
|
|
|
priv->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warning ("Failed to initialize double buffered shadow fb for %s: %s",
|
|
|
|
priv->name, error->message);
|
|
|
|
g_clear_error (&error);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!init_fallback_shadowfb (view, cogl_context, width, height, &error))
|
2020-04-30 17:53:30 +02:00
|
|
|
{
|
|
|
|
g_warning ("Failed to initialize single buffered shadow fb for %s: %s",
|
|
|
|
priv->name, error->message);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_message ("Initialized single buffered shadow fb for %s", priv->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-22 17:03:03 +02:00
|
|
|
void
|
2020-05-05 19:22:10 +02:00
|
|
|
clutter_stage_view_after_paint (ClutterStageView *view,
|
|
|
|
cairo_region_t *redraw_clip)
|
2019-10-22 17:03:03 +02:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
if (priv->offscreen)
|
|
|
|
{
|
|
|
|
clutter_stage_view_ensure_offscreen_blit_pipeline (view);
|
|
|
|
|
2020-04-30 18:19:30 +02:00
|
|
|
if (priv->shadow.framebuffer)
|
2019-10-22 17:03:03 +02:00
|
|
|
{
|
2020-05-22 22:37:47 +02:00
|
|
|
CoglFramebuffer *shadowfb =
|
|
|
|
COGL_FRAMEBUFFER (priv->shadow.framebuffer);
|
|
|
|
|
2020-05-05 18:59:32 +02:00
|
|
|
paint_transformed_framebuffer (view,
|
|
|
|
priv->offscreen_pipeline,
|
|
|
|
priv->offscreen,
|
2020-05-22 22:37:47 +02:00
|
|
|
shadowfb,
|
2020-05-05 19:22:10 +02:00
|
|
|
redraw_clip);
|
2019-10-22 17:03:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-05 18:59:32 +02:00
|
|
|
paint_transformed_framebuffer (view,
|
|
|
|
priv->offscreen_pipeline,
|
|
|
|
priv->offscreen,
|
2020-05-05 19:22:10 +02:00
|
|
|
priv->framebuffer,
|
|
|
|
redraw_clip);
|
2019-10-22 17:03:03 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-05 19:25:23 +02:00
|
|
|
}
|
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
static gboolean
|
|
|
|
is_tile_dirty (cairo_rectangle_int_t *tile,
|
|
|
|
uint8_t *current_data,
|
|
|
|
uint8_t *prev_data,
|
|
|
|
int bpp,
|
|
|
|
int stride)
|
|
|
|
{
|
|
|
|
int y;
|
|
|
|
|
|
|
|
for (y = tile->y; y < tile->y + tile->height; y++)
|
|
|
|
{
|
|
|
|
if (memcmp (prev_data + y * stride + tile->x * bpp,
|
|
|
|
current_data + y * stride + tile->x * bpp,
|
|
|
|
tile->width * bpp) != 0)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
flip_dma_buf_idx (int idx)
|
|
|
|
{
|
|
|
|
return (idx + 1) % 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cairo_region_t *
|
|
|
|
find_damaged_tiles (ClutterStageView *view,
|
|
|
|
const cairo_region_t *damage_region,
|
|
|
|
GError **error)
|
2020-05-05 19:25:23 +02:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
cairo_region_t *tile_damage_region;
|
|
|
|
cairo_rectangle_int_t damage_extents;
|
|
|
|
cairo_rectangle_int_t fb_rect;
|
|
|
|
int prev_dma_buf_idx;
|
|
|
|
CoglDmaBufHandle *prev_dma_buf_handle;
|
|
|
|
uint8_t *prev_data;
|
|
|
|
int current_dma_buf_idx;
|
|
|
|
CoglDmaBufHandle *current_dma_buf_handle;
|
|
|
|
uint8_t *current_data;
|
|
|
|
int width, height, stride, bpp;
|
|
|
|
int tile_x_min, tile_x_max;
|
|
|
|
int tile_y_min, tile_y_max;
|
|
|
|
int tile_x, tile_y;
|
|
|
|
const int tile_size = 16;
|
|
|
|
|
|
|
|
prev_dma_buf_idx = flip_dma_buf_idx (priv->shadow.dma_buf.current_idx);
|
|
|
|
prev_dma_buf_handle = priv->shadow.dma_buf.handles[prev_dma_buf_idx];
|
|
|
|
|
|
|
|
current_dma_buf_idx = priv->shadow.dma_buf.current_idx;
|
|
|
|
current_dma_buf_handle = priv->shadow.dma_buf.handles[current_dma_buf_idx];
|
|
|
|
|
|
|
|
width = cogl_dma_buf_handle_get_width (current_dma_buf_handle);
|
|
|
|
height = cogl_dma_buf_handle_get_height (current_dma_buf_handle);
|
|
|
|
stride = cogl_dma_buf_handle_get_stride (current_dma_buf_handle);
|
|
|
|
bpp = cogl_dma_buf_handle_get_bpp (current_dma_buf_handle);
|
|
|
|
|
2020-05-22 22:37:47 +02:00
|
|
|
cogl_framebuffer_finish (COGL_FRAMEBUFFER (priv->shadow.framebuffer));
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
|
|
|
|
if (!cogl_dma_buf_handle_sync_read_start (prev_dma_buf_handle, error))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!cogl_dma_buf_handle_sync_read_start (current_dma_buf_handle, error))
|
|
|
|
goto err_sync_read_current;
|
|
|
|
|
|
|
|
prev_data = cogl_dma_buf_handle_mmap (prev_dma_buf_handle, error);
|
|
|
|
if (!prev_data)
|
|
|
|
goto err_mmap_prev;
|
|
|
|
current_data = cogl_dma_buf_handle_mmap (current_dma_buf_handle, error);
|
|
|
|
if (!current_data)
|
|
|
|
goto err_mmap_current;
|
|
|
|
|
|
|
|
fb_rect = (cairo_rectangle_int_t) {
|
|
|
|
.width = width,
|
|
|
|
.height = height,
|
|
|
|
};
|
|
|
|
|
|
|
|
cairo_region_get_extents (damage_region, &damage_extents);
|
|
|
|
|
|
|
|
tile_x_min = damage_extents.x / tile_size;
|
|
|
|
tile_x_max = ((damage_extents.x + damage_extents.width + tile_size - 1) /
|
|
|
|
tile_size);
|
|
|
|
tile_y_min = damage_extents.y / tile_size;
|
|
|
|
tile_y_max = ((damage_extents.y + damage_extents.height + tile_size - 1) /
|
|
|
|
tile_size);
|
|
|
|
|
|
|
|
tile_damage_region = cairo_region_create ();
|
|
|
|
|
|
|
|
for (tile_y = tile_y_min; tile_y <= tile_y_max; tile_y++)
|
|
|
|
{
|
|
|
|
for (tile_x = tile_x_min; tile_x <= tile_x_max; tile_x++)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t tile = {
|
|
|
|
.x = tile_x * tile_size,
|
|
|
|
.y = tile_y * tile_size,
|
|
|
|
.width = tile_size,
|
|
|
|
.height = tile_size,
|
|
|
|
};
|
2019-10-22 17:03:03 +02:00
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
if (cairo_region_contains_rectangle (damage_region, &tile) ==
|
|
|
|
CAIRO_REGION_OVERLAP_OUT)
|
|
|
|
continue;
|
2020-05-05 19:25:23 +02:00
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
_clutter_util_rectangle_intersection (&tile, &fb_rect, &tile);
|
|
|
|
|
|
|
|
if (is_tile_dirty (&tile, current_data, prev_data, bpp, stride))
|
|
|
|
cairo_region_union_rectangle (tile_damage_region, &tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cogl_dma_buf_handle_sync_read_end (prev_dma_buf_handle, error))
|
2019-10-22 17:03:03 +02:00
|
|
|
{
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
g_warning ("Failed to end DMA buffer read synchronization: %s",
|
|
|
|
(*error)->message);
|
|
|
|
g_clear_error (error);
|
|
|
|
}
|
2020-05-05 18:55:03 +02:00
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
if (!cogl_dma_buf_handle_sync_read_end (current_dma_buf_handle, error))
|
|
|
|
{
|
|
|
|
g_warning ("Failed to end DMA buffer read synchronization: %s",
|
|
|
|
(*error)->message);
|
|
|
|
g_clear_error (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
cogl_dma_buf_handle_munmap (prev_dma_buf_handle, prev_data, NULL);
|
|
|
|
cogl_dma_buf_handle_munmap (current_dma_buf_handle, current_data, NULL);
|
|
|
|
|
|
|
|
cairo_region_intersect (tile_damage_region, damage_region);
|
|
|
|
|
|
|
|
return tile_damage_region;
|
|
|
|
|
|
|
|
err_mmap_current:
|
|
|
|
cogl_dma_buf_handle_munmap (prev_dma_buf_handle, prev_data, NULL);
|
|
|
|
|
|
|
|
err_mmap_prev:
|
|
|
|
cogl_dma_buf_handle_sync_read_end (current_dma_buf_handle, NULL);
|
|
|
|
|
|
|
|
err_sync_read_current:
|
|
|
|
cogl_dma_buf_handle_sync_read_end (prev_dma_buf_handle, NULL);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
swap_dma_buf_framebuffer (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
int next_idx;
|
|
|
|
CoglDmaBufHandle *next_dma_buf_handle;
|
2020-05-22 22:37:47 +02:00
|
|
|
CoglFramebuffer *next_framebuffer;
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
|
|
|
|
next_idx = ((priv->shadow.dma_buf.current_idx + 1) %
|
|
|
|
G_N_ELEMENTS (priv->shadow.dma_buf.handles));
|
|
|
|
priv->shadow.dma_buf.current_idx = next_idx;
|
|
|
|
|
|
|
|
next_dma_buf_handle = priv->shadow.dma_buf.handles[next_idx];
|
|
|
|
next_framebuffer =
|
|
|
|
cogl_dma_buf_handle_get_framebuffer (next_dma_buf_handle);
|
2020-10-13 11:35:47 +02:00
|
|
|
g_clear_object (&priv->shadow.framebuffer);
|
|
|
|
priv->shadow.framebuffer = COGL_OFFSCREEN (g_object_ref (next_framebuffer));
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
copy_shadowfb_to_onscreen (ClutterStageView *view,
|
|
|
|
const cairo_region_t *swap_region)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
ClutterDamageHistory *damage_history = priv->shadow.dma_buf.damage_history;
|
|
|
|
cairo_region_t *damage_region;
|
|
|
|
int age;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (cairo_region_is_empty (swap_region))
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t full_damage = {
|
|
|
|
.width = cogl_framebuffer_get_width (priv->framebuffer),
|
|
|
|
.height = cogl_framebuffer_get_height (priv->framebuffer),
|
|
|
|
};
|
|
|
|
damage_region = cairo_region_create_rectangle (&full_damage);
|
2020-05-05 19:25:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
damage_region = cairo_region_copy (swap_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_shadowfb_double_buffered (view))
|
|
|
|
{
|
|
|
|
CoglOnscreen *onscreen = COGL_ONSCREEN (priv->framebuffer);
|
|
|
|
cairo_region_t *changed_region;
|
2020-05-05 19:25:23 +02:00
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
if (cogl_onscreen_get_frame_counter (onscreen) >= 1)
|
2020-05-05 18:55:03 +02:00
|
|
|
{
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
|
|
changed_region = find_damaged_tiles (view, damage_region, &error);
|
|
|
|
if (!changed_region)
|
2020-05-05 19:25:23 +02:00
|
|
|
{
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
int other_dma_buf_idx;
|
|
|
|
|
|
|
|
g_warning ("Disabling actual damage detection: %s",
|
|
|
|
error->message);
|
|
|
|
|
|
|
|
other_dma_buf_idx =
|
|
|
|
flip_dma_buf_idx (priv->shadow.dma_buf.current_idx);
|
|
|
|
g_clear_pointer (&priv->shadow.dma_buf.handles[other_dma_buf_idx],
|
|
|
|
cogl_dma_buf_handle_free);
|
2020-05-05 19:25:23 +02:00
|
|
|
}
|
2020-05-05 18:55:03 +02:00
|
|
|
}
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
changed_region = cairo_region_copy (damage_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed_region)
|
|
|
|
{
|
|
|
|
int buffer_age;
|
|
|
|
|
|
|
|
clutter_damage_history_record (damage_history, changed_region);
|
|
|
|
|
|
|
|
buffer_age = cogl_onscreen_get_buffer_age (onscreen);
|
|
|
|
if (clutter_damage_history_is_age_valid (damage_history, buffer_age))
|
|
|
|
{
|
|
|
|
for (age = 1; age <= buffer_age; age++)
|
|
|
|
{
|
|
|
|
const cairo_region_t *old_damage;
|
|
|
|
|
|
|
|
old_damage = clutter_damage_history_lookup (damage_history, age);
|
|
|
|
cairo_region_union (changed_region, old_damage);
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_region_destroy (damage_region);
|
|
|
|
damage_region = g_steal_pointer (&changed_region);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cairo_region_destroy (changed_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
clutter_damage_history_step (damage_history);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < cairo_region_num_rectangles (damage_region); i++)
|
|
|
|
{
|
2020-05-22 22:37:47 +02:00
|
|
|
CoglFramebuffer *shadowfb = COGL_FRAMEBUFFER (priv->shadow.framebuffer);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
|
|
|
|
cairo_region_get_rectangle (damage_region, i, &rect);
|
|
|
|
|
2020-05-22 22:37:47 +02:00
|
|
|
if (!cogl_blit_framebuffer (shadowfb,
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
priv->framebuffer,
|
|
|
|
rect.x, rect.y,
|
|
|
|
rect.x, rect.y,
|
|
|
|
rect.width, rect.height,
|
|
|
|
&error))
|
|
|
|
{
|
|
|
|
g_warning ("Failed to blit shadow buffer: %s", error->message);
|
|
|
|
cairo_region_destroy (damage_region);
|
|
|
|
return;
|
|
|
|
}
|
2019-10-22 17:03:03 +02:00
|
|
|
}
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
|
|
|
|
cairo_region_destroy (damage_region);
|
|
|
|
|
|
|
|
if (is_shadowfb_double_buffered (view))
|
|
|
|
swap_dma_buf_framebuffer (view);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
clutter_stage_view_before_swap_buffer (ClutterStageView *view,
|
|
|
|
const cairo_region_t *swap_region)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
if (priv->shadow.framebuffer)
|
|
|
|
copy_shadowfb_to_onscreen (view, swap_region);
|
2016-08-01 02:44:57 +02:00
|
|
|
}
|
|
|
|
|
2017-05-25 15:54:37 +08:00
|
|
|
float
|
2017-02-24 17:38:47 +08:00
|
|
|
clutter_stage_view_get_scale (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->scale;
|
|
|
|
}
|
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
typedef void (*FrontBufferCallback) (CoglFramebuffer *framebuffer,
|
|
|
|
gconstpointer user_data);
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_view_foreach_front_buffer (ClutterStageView *view,
|
|
|
|
FrontBufferCallback callback,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
if (priv->offscreen)
|
|
|
|
{
|
2020-05-22 22:37:47 +02:00
|
|
|
callback (COGL_FRAMEBUFFER (priv->offscreen), user_data);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
}
|
|
|
|
else if (priv->shadow.framebuffer)
|
|
|
|
{
|
|
|
|
if (is_shadowfb_double_buffered (view))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (priv->shadow.dma_buf.handles); i++)
|
|
|
|
{
|
|
|
|
CoglDmaBufHandle *handle = priv->shadow.dma_buf.handles[i];
|
|
|
|
CoglFramebuffer *framebuffer =
|
|
|
|
cogl_dma_buf_handle_get_framebuffer (handle);
|
|
|
|
|
|
|
|
callback (framebuffer, user_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-22 22:37:47 +02:00
|
|
|
callback (COGL_FRAMEBUFFER (priv->shadow.framebuffer), user_data);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
callback (priv->framebuffer, user_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
gboolean
|
|
|
|
clutter_stage_view_is_dirty_viewport (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->dirty_viewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-04-30 21:59:49 +02:00
|
|
|
clutter_stage_view_invalidate_viewport (ClutterStageView *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-27 11:09:24 +08:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
2020-04-30 21:59:49 +02:00
|
|
|
priv->dirty_viewport = 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-27 11:09:24 +08:00
|
|
|
}
|
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
static void
|
|
|
|
set_framebuffer_viewport (CoglFramebuffer *framebuffer,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
const graphene_rect_t *rect = user_data;
|
|
|
|
|
|
|
|
cogl_framebuffer_set_viewport (framebuffer,
|
|
|
|
rect->origin.x,
|
|
|
|
rect->origin.y,
|
|
|
|
rect->size.width,
|
|
|
|
rect->size.height);
|
|
|
|
}
|
|
|
|
|
2020-04-30 21:51:10 +02:00
|
|
|
void
|
|
|
|
clutter_stage_view_set_viewport (ClutterStageView *view,
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
float width,
|
|
|
|
float height)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
graphene_rect_t rect;
|
2020-04-30 21:51:10 +02:00
|
|
|
|
|
|
|
priv->dirty_viewport = FALSE;
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
|
|
|
|
rect = (graphene_rect_t) {
|
|
|
|
.origin = { .x = x, .y = y },
|
|
|
|
.size = { .width = width, .height = height },
|
|
|
|
};
|
|
|
|
clutter_stage_view_foreach_front_buffer (view,
|
|
|
|
set_framebuffer_viewport,
|
|
|
|
&rect);
|
2020-04-30 21:51:10 +02: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-27 11:09:24 +08:00
|
|
|
gboolean
|
|
|
|
clutter_stage_view_is_dirty_projection (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->dirty_projection;
|
|
|
|
}
|
|
|
|
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
static void
|
|
|
|
set_framebuffer_projection_matrix (CoglFramebuffer *framebuffer,
|
|
|
|
gconstpointer user_data)
|
|
|
|
{
|
|
|
|
cogl_framebuffer_set_projection_matrix (framebuffer, user_data);
|
|
|
|
}
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
void
|
2020-04-30 21:59:49 +02:00
|
|
|
clutter_stage_view_invalidate_projection (ClutterStageView *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-27 11:09:24 +08:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
2020-04-30 21:59:49 +02:00
|
|
|
priv->dirty_projection = 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-27 11:09:24 +08:00
|
|
|
}
|
|
|
|
|
2020-04-30 21:51:10 +02:00
|
|
|
void
|
2020-09-11 15:57:28 -03:00
|
|
|
clutter_stage_view_set_projection (ClutterStageView *view,
|
|
|
|
const graphene_matrix_t *matrix)
|
2020-04-30 21:51:10 +02:00
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
priv->dirty_projection = FALSE;
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
clutter_stage_view_foreach_front_buffer (view,
|
|
|
|
set_framebuffer_projection_matrix,
|
|
|
|
matrix);
|
2020-04-30 21:51:10 +02:00
|
|
|
}
|
|
|
|
|
2017-03-07 18:02:52 +08:00
|
|
|
void
|
2020-09-11 15:57:28 -03:00
|
|
|
clutter_stage_view_get_offscreen_transformation_matrix (ClutterStageView *view,
|
|
|
|
graphene_matrix_t *matrix)
|
2017-03-07 18:02:52 +08:00
|
|
|
{
|
|
|
|
ClutterStageViewClass *view_class = CLUTTER_STAGE_VIEW_GET_CLASS (view);
|
|
|
|
|
|
|
|
view_class->get_offscreen_transformation_matrix (view, matrix);
|
|
|
|
}
|
|
|
|
|
2022-06-25 22:14:41 +02:00
|
|
|
static void
|
|
|
|
maybe_mark_full_redraw (ClutterStageView *view,
|
|
|
|
cairo_region_t **region)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
if (cairo_region_num_rectangles (*region) == 1)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t region_extents;
|
|
|
|
|
|
|
|
cairo_region_get_extents (*region, ®ion_extents);
|
|
|
|
if (clutter_util_rectangle_equal (&priv->layout, ®ion_extents))
|
|
|
|
g_clear_pointer (region, cairo_region_destroy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 10:12:54 +01:00
|
|
|
void
|
|
|
|
clutter_stage_view_add_redraw_clip (ClutterStageView *view,
|
|
|
|
const cairo_rectangle_int_t *clip)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
if (priv->has_redraw_clip && !priv->redraw_clip)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!clip)
|
|
|
|
{
|
|
|
|
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
|
|
|
|
priv->has_redraw_clip = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clip->width == 0 || clip->height == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!priv->redraw_clip)
|
|
|
|
{
|
|
|
|
if (!clutter_util_rectangle_equal (&priv->layout, clip))
|
|
|
|
priv->redraw_clip = cairo_region_create_rectangle (clip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cairo_region_union_rectangle (priv->redraw_clip, clip);
|
2022-06-25 22:14:41 +02:00
|
|
|
maybe_mark_full_redraw (view, &priv->redraw_clip);
|
2020-02-06 10:12:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
priv->has_redraw_clip = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
clutter_stage_view_has_redraw_clip (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->has_redraw_clip;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
clutter_stage_view_has_full_redraw_clip (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->has_redraw_clip && !priv->redraw_clip;
|
|
|
|
}
|
|
|
|
|
|
|
|
const cairo_region_t *
|
|
|
|
clutter_stage_view_peek_redraw_clip (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->redraw_clip;
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_region_t *
|
|
|
|
clutter_stage_view_take_redraw_clip (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
priv->has_redraw_clip = FALSE;
|
|
|
|
|
|
|
|
return g_steal_pointer (&priv->redraw_clip);
|
|
|
|
}
|
|
|
|
|
2022-06-25 22:14:41 +02:00
|
|
|
cairo_region_t *
|
|
|
|
clutter_stage_view_take_accumulated_redraw_clip (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
g_return_val_if_fail (priv->has_redraw_clip, NULL);
|
|
|
|
|
|
|
|
clutter_stage_view_accumulate_redraw_clip (view);
|
|
|
|
|
|
|
|
priv->has_accumulated_redraw_clip = FALSE;
|
|
|
|
return g_steal_pointer (&priv->accumulated_redraw_clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
clutter_stage_view_accumulate_redraw_clip (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
g_return_if_fail (priv->has_redraw_clip);
|
|
|
|
|
|
|
|
if (priv->redraw_clip && priv->accumulated_redraw_clip)
|
|
|
|
{
|
|
|
|
cairo_region_union (priv->accumulated_redraw_clip, priv->redraw_clip);
|
|
|
|
maybe_mark_full_redraw (view, &priv->accumulated_redraw_clip);
|
|
|
|
}
|
|
|
|
else if (priv->redraw_clip && !priv->has_accumulated_redraw_clip)
|
|
|
|
{
|
|
|
|
priv->accumulated_redraw_clip = g_steal_pointer (&priv->redraw_clip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_clear_pointer (&priv->accumulated_redraw_clip, cairo_region_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
|
|
|
|
priv->has_accumulated_redraw_clip = TRUE;
|
|
|
|
priv->has_redraw_clip = FALSE;
|
|
|
|
}
|
|
|
|
|
2016-08-01 02:44:57 +02:00
|
|
|
static void
|
2020-09-11 15:57:28 -03:00
|
|
|
clutter_stage_default_get_offscreen_transformation_matrix (ClutterStageView *view,
|
|
|
|
graphene_matrix_t *matrix)
|
2016-08-01 02:44:57 +02:00
|
|
|
{
|
2020-09-11 16:39:50 -03:00
|
|
|
graphene_matrix_init_identity (matrix);
|
2016-08-01 02:44:57 +02:00
|
|
|
}
|
|
|
|
|
2019-09-12 11:28:50 +02:00
|
|
|
void
|
|
|
|
clutter_stage_view_assign_next_scanout (ClutterStageView *view,
|
|
|
|
CoglScanout *scanout)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
2019-09-12 22:07:20 +02:00
|
|
|
g_set_object (&priv->next_scanout, scanout);
|
2019-09-12 11:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CoglScanout *
|
|
|
|
clutter_stage_view_take_scanout (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return g_steal_pointer (&priv->next_scanout);
|
|
|
|
}
|
|
|
|
|
2020-08-28 22:54:59 -03:00
|
|
|
/**
|
|
|
|
* clutter_stage_view_peek_scanout: (skip)
|
|
|
|
*/
|
|
|
|
CoglScanout *
|
|
|
|
clutter_stage_view_peek_scanout (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->next_scanout;
|
|
|
|
}
|
|
|
|
|
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-30 00:27:56 +02:00
|
|
|
void
|
|
|
|
clutter_stage_view_schedule_update (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
clutter_frame_clock_schedule_update (priv->frame_clock);
|
|
|
|
}
|
|
|
|
|
2020-05-22 22:59:57 +02:00
|
|
|
float
|
|
|
|
clutter_stage_view_get_refresh_rate (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->refresh_rate;
|
|
|
|
}
|
|
|
|
|
2020-05-26 22:21:37 +02:00
|
|
|
/**
|
|
|
|
* clutter_stage_view_get_frame_clock: (skip)
|
|
|
|
*/
|
2020-05-22 22:57:39 +02:00
|
|
|
ClutterFrameClock *
|
|
|
|
clutter_stage_view_get_frame_clock (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->frame_clock;
|
|
|
|
}
|
|
|
|
|
2022-09-01 21:03:12 +02:00
|
|
|
gboolean
|
|
|
|
clutter_stage_view_has_shadowfb (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
return priv->use_shadowfb;
|
|
|
|
}
|
|
|
|
|
2020-05-22 22:57:39 +02:00
|
|
|
static void
|
|
|
|
handle_frame_clock_before_frame (ClutterFrameClock *frame_clock,
|
|
|
|
int64_t frame_count,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
ClutterStageView *view = user_data;
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
_clutter_stage_process_queued_events (priv->stage);
|
|
|
|
}
|
|
|
|
|
2021-01-25 17:45:47 +08:00
|
|
|
static void
|
|
|
|
begin_frame_timing_measurement (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
priv->frame_timings.began_draw_time_us = g_get_monotonic_time ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
end_frame_timing_measurement (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
int64_t now_us = g_get_monotonic_time ();
|
|
|
|
int64_t draw_time_us;
|
|
|
|
|
|
|
|
draw_time_us = now_us - priv->frame_timings.began_draw_time_us;
|
|
|
|
|
|
|
|
priv->frame_timings.frame_count++;
|
|
|
|
priv->frame_timings.cumulative_draw_time_us += draw_time_us;
|
|
|
|
if (draw_time_us > priv->frame_timings.worst_draw_time_us)
|
|
|
|
priv->frame_timings.worst_draw_time_us = draw_time_us;
|
|
|
|
|
|
|
|
if (priv->frame_timings.frame_count && priv->frame_timings.last_print_time_us)
|
|
|
|
{
|
|
|
|
float time_since_last_print_s;
|
|
|
|
|
|
|
|
time_since_last_print_s =
|
|
|
|
(now_us - priv->frame_timings.last_print_time_us) /
|
|
|
|
(float) G_USEC_PER_SEC;
|
|
|
|
|
|
|
|
if (time_since_last_print_s >= 1.0)
|
|
|
|
{
|
|
|
|
float avg_fps, avg_draw_time_ms, worst_draw_time_ms;
|
|
|
|
|
|
|
|
avg_fps = priv->frame_timings.frame_count / time_since_last_print_s;
|
|
|
|
|
|
|
|
avg_draw_time_ms =
|
|
|
|
(priv->frame_timings.cumulative_draw_time_us / 1000.0) /
|
|
|
|
priv->frame_timings.frame_count;
|
|
|
|
|
|
|
|
worst_draw_time_ms = priv->frame_timings.worst_draw_time_us / 1000.0;
|
|
|
|
|
|
|
|
g_print ("*** %s frame timings over %.01fs: "
|
|
|
|
"%.02f FPS, average: %.01fms, peak: %.01fms\n",
|
|
|
|
priv->name,
|
|
|
|
time_since_last_print_s,
|
|
|
|
avg_fps,
|
|
|
|
avg_draw_time_ms,
|
|
|
|
worst_draw_time_ms);
|
|
|
|
|
|
|
|
priv->frame_timings.frame_count = 0;
|
|
|
|
priv->frame_timings.cumulative_draw_time_us = 0;
|
|
|
|
priv->frame_timings.worst_draw_time_us = 0;
|
|
|
|
priv->frame_timings.last_print_time_us = now_us;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!priv->frame_timings.last_print_time_us)
|
|
|
|
{
|
|
|
|
priv->frame_timings.last_print_time_us = now_us;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-22 22:57:39 +02:00
|
|
|
static ClutterFrameResult
|
|
|
|
handle_frame_clock_frame (ClutterFrameClock *frame_clock,
|
|
|
|
int64_t frame_count,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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-30 00:27:56 +02:00
|
|
|
ClutterStageView *view = user_data;
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
ClutterStage *stage = priv->stage;
|
2020-10-09 18:05:41 +02:00
|
|
|
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
|
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-30 00:27:56 +02:00
|
|
|
g_autoptr (GSList) devices = NULL;
|
2020-10-09 18:16:16 +02:00
|
|
|
ClutterFrame frame;
|
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-30 00:27:56 +02:00
|
|
|
|
|
|
|
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
|
|
|
return CLUTTER_FRAME_RESULT_IDLE;
|
|
|
|
|
|
|
|
if (!clutter_actor_is_realized (CLUTTER_ACTOR (stage)))
|
|
|
|
return CLUTTER_FRAME_RESULT_IDLE;
|
|
|
|
|
|
|
|
if (!clutter_actor_is_mapped (CLUTTER_ACTOR (stage)))
|
|
|
|
return CLUTTER_FRAME_RESULT_IDLE;
|
|
|
|
|
2021-01-25 17:45:47 +08:00
|
|
|
if (_clutter_context_get_show_fps ())
|
|
|
|
begin_frame_timing_measurement (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-30 00:27:56 +02:00
|
|
|
_clutter_run_repaint_functions (CLUTTER_REPAINT_FLAGS_PRE_PAINT);
|
|
|
|
clutter_stage_emit_before_update (stage, view);
|
|
|
|
|
|
|
|
clutter_stage_maybe_relayout (CLUTTER_ACTOR (stage));
|
|
|
|
clutter_stage_maybe_finish_queue_redraws (stage);
|
|
|
|
|
2021-03-13 20:43:13 +01:00
|
|
|
clutter_stage_finish_layout (stage);
|
|
|
|
|
2022-01-26 18:39:27 +01:00
|
|
|
if (priv->needs_update_devices)
|
|
|
|
devices = clutter_stage_find_updated_devices (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-30 00:27:56 +02:00
|
|
|
|
2020-10-09 18:16:16 +02:00
|
|
|
frame = CLUTTER_FRAME_INIT;
|
|
|
|
|
2020-10-10 01:02:28 +02:00
|
|
|
_clutter_stage_window_prepare_frame (stage_window, view, &frame);
|
2022-04-29 16:02:08 +02:00
|
|
|
clutter_stage_emit_prepare_frame (stage, view);
|
2020-10-10 01:02:28 +02: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-30 00:27:56 +02:00
|
|
|
if (clutter_stage_view_has_redraw_clip (view))
|
|
|
|
{
|
|
|
|
clutter_stage_emit_before_paint (stage, view);
|
|
|
|
|
2020-10-09 18:16:16 +02:00
|
|
|
_clutter_stage_window_redraw_view (stage_window, view, &frame);
|
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-30 00:27:56 +02:00
|
|
|
|
2020-11-27 20:48:11 +03:00
|
|
|
clutter_frame_clock_record_flip_time (frame_clock,
|
|
|
|
g_get_monotonic_time ());
|
|
|
|
|
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-30 00:27:56 +02:00
|
|
|
clutter_stage_emit_after_paint (stage, view);
|
2021-01-25 17:45:47 +08:00
|
|
|
|
|
|
|
if (_clutter_context_get_show_fps ())
|
|
|
|
end_frame_timing_measurement (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-30 00:27:56 +02:00
|
|
|
}
|
|
|
|
|
2020-10-09 18:16:16 +02:00
|
|
|
_clutter_stage_window_finish_frame (stage_window, view, &frame);
|
2020-10-09 18:05:41 +02: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-30 00:27:56 +02:00
|
|
|
clutter_stage_update_devices (stage, devices);
|
2022-01-26 18:39:27 +01:00
|
|
|
priv->needs_update_devices = FALSE;
|
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-30 00:27:56 +02:00
|
|
|
|
|
|
|
_clutter_run_repaint_functions (CLUTTER_REPAINT_FLAGS_POST_PAINT);
|
|
|
|
clutter_stage_emit_after_update (stage, view);
|
|
|
|
|
2020-10-09 18:16:16 +02:00
|
|
|
return clutter_frame_get_result (&frame);
|
2020-05-22 22:57:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const ClutterFrameListenerIface frame_clock_listener_iface = {
|
|
|
|
.before_frame = handle_frame_clock_before_frame,
|
|
|
|
.frame = handle_frame_clock_frame,
|
|
|
|
};
|
|
|
|
|
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-30 00:27:56 +02:00
|
|
|
void
|
|
|
|
clutter_stage_view_notify_presented (ClutterStageView *view,
|
|
|
|
ClutterFrameInfo *frame_info)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
clutter_stage_presented (priv->stage, view, frame_info);
|
|
|
|
clutter_frame_clock_notify_presented (priv->frame_clock, frame_info);
|
|
|
|
}
|
|
|
|
|
2020-10-10 00:37:05 +02:00
|
|
|
void
|
|
|
|
clutter_stage_view_notify_ready (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
clutter_frame_clock_notify_ready (priv->frame_clock);
|
|
|
|
}
|
|
|
|
|
2020-04-09 10:49:07 +02:00
|
|
|
static void
|
|
|
|
sanity_check_framebuffer (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
G_GNUC_UNUSED int fb_width, fb_height;
|
|
|
|
|
|
|
|
fb_width = cogl_framebuffer_get_width (priv->framebuffer);
|
|
|
|
fb_height = cogl_framebuffer_get_height (priv->framebuffer);
|
|
|
|
|
|
|
|
g_warn_if_fail (fabsf (roundf (fb_width / priv->scale) -
|
|
|
|
fb_width / priv->scale) < FLT_EPSILON);
|
|
|
|
g_warn_if_fail (fabsf (roundf (fb_height / priv->scale) -
|
|
|
|
fb_height / priv->scale) < FLT_EPSILON);
|
|
|
|
}
|
|
|
|
|
2020-04-09 10:36:28 +02:00
|
|
|
static void
|
|
|
|
clutter_stage_view_set_framebuffer (ClutterStageView *view,
|
|
|
|
CoglFramebuffer *framebuffer)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (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-30 00:27:56 +02:00
|
|
|
g_warn_if_fail (!priv->framebuffer);
|
|
|
|
if (framebuffer)
|
|
|
|
{
|
2020-10-13 11:35:47 +02:00
|
|
|
priv->framebuffer = g_object_ref (framebuffer);
|
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-30 00:27:56 +02:00
|
|
|
sanity_check_framebuffer (view);
|
|
|
|
}
|
2020-04-09 10:36:28 +02: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-27 11:09:24 +08:00
|
|
|
static void
|
|
|
|
clutter_stage_view_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2020-04-30 10:42:30 +02:00
|
|
|
case PROP_NAME:
|
|
|
|
g_value_set_string (value, priv->name);
|
|
|
|
break;
|
2020-03-30 17:34:43 +02:00
|
|
|
case PROP_STAGE:
|
|
|
|
g_value_set_boxed (value, &priv->stage);
|
|
|
|
break;
|
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-27 11:09:24 +08:00
|
|
|
case PROP_LAYOUT:
|
|
|
|
g_value_set_boxed (value, &priv->layout);
|
|
|
|
break;
|
|
|
|
case PROP_FRAMEBUFFER:
|
2020-10-13 11:35:47 +02:00
|
|
|
g_value_set_object (value, priv->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-27 11:09:24 +08:00
|
|
|
break;
|
2016-08-01 02:44:57 +02:00
|
|
|
case PROP_OFFSCREEN:
|
2020-10-13 11:35:47 +02:00
|
|
|
g_value_set_object (value, priv->offscreen);
|
2016-08-01 02:44:57 +02:00
|
|
|
break;
|
2020-04-30 17:53:30 +02:00
|
|
|
case PROP_USE_SHADOWFB:
|
|
|
|
g_value_set_boolean (value, priv->use_shadowfb);
|
2019-10-22 17:03:03 +02:00
|
|
|
break;
|
2017-02-24 17:38:47 +08:00
|
|
|
case PROP_SCALE:
|
2017-05-25 15:54:37 +08:00
|
|
|
g_value_set_float (value, priv->scale);
|
2017-02-24 17:38:47 +08:00
|
|
|
break;
|
2020-04-17 09:18:37 +02:00
|
|
|
case PROP_REFRESH_RATE:
|
|
|
|
g_value_set_float (value, priv->refresh_rate);
|
|
|
|
break;
|
2021-01-06 15:18:26 +03:00
|
|
|
case PROP_VBLANK_DURATION_US:
|
|
|
|
g_value_set_int64 (value, priv->vblank_duration_us);
|
|
|
|
break;
|
2016-08-01 02:44:57 +02:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
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-27 11:09:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_view_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
cairo_rectangle_int_t *layout;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2020-04-30 10:42:30 +02:00
|
|
|
case PROP_NAME:
|
|
|
|
priv->name = g_value_dup_string (value);
|
|
|
|
break;
|
2020-03-30 17:34:43 +02:00
|
|
|
case PROP_STAGE:
|
|
|
|
priv->stage = g_value_get_object (value);
|
|
|
|
break;
|
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-27 11:09:24 +08:00
|
|
|
case PROP_LAYOUT:
|
|
|
|
layout = g_value_get_boxed (value);
|
|
|
|
priv->layout = *layout;
|
|
|
|
break;
|
|
|
|
case PROP_FRAMEBUFFER:
|
2020-10-13 11:35:47 +02:00
|
|
|
clutter_stage_view_set_framebuffer (view, g_value_get_object (value));
|
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-27 11:09:24 +08:00
|
|
|
break;
|
2016-08-01 02:44:57 +02:00
|
|
|
case PROP_OFFSCREEN:
|
2020-10-13 11:35:47 +02:00
|
|
|
priv->offscreen = g_value_dup_object (value);
|
2016-08-01 02:44:57 +02:00
|
|
|
break;
|
2020-04-30 17:53:30 +02:00
|
|
|
case PROP_USE_SHADOWFB:
|
|
|
|
priv->use_shadowfb = g_value_get_boolean (value);
|
2019-10-22 17:03:03 +02:00
|
|
|
break;
|
2017-02-24 17:38:47 +08:00
|
|
|
case PROP_SCALE:
|
2017-05-25 15:54:37 +08:00
|
|
|
priv->scale = g_value_get_float (value);
|
2017-02-24 17:38:47 +08:00
|
|
|
break;
|
2020-04-17 09:18:37 +02:00
|
|
|
case PROP_REFRESH_RATE:
|
|
|
|
priv->refresh_rate = g_value_get_float (value);
|
|
|
|
break;
|
2021-01-06 15:18:26 +03:00
|
|
|
case PROP_VBLANK_DURATION_US:
|
|
|
|
priv->vblank_duration_us = g_value_get_int64 (value);
|
|
|
|
break;
|
2016-08-01 02:44:57 +02:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
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-27 11:09:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-30 17:53:30 +02:00
|
|
|
static void
|
|
|
|
clutter_stage_view_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
if (priv->use_shadowfb)
|
|
|
|
init_shadowfb (view);
|
|
|
|
|
2020-05-22 22:57:39 +02:00
|
|
|
priv->frame_clock = clutter_frame_clock_new (priv->refresh_rate,
|
2021-01-06 15:20:01 +03:00
|
|
|
priv->vblank_duration_us,
|
2020-05-22 22:57:39 +02:00
|
|
|
&frame_clock_listener_iface,
|
|
|
|
view);
|
|
|
|
|
2021-07-30 11:28:28 +02:00
|
|
|
clutter_stage_view_add_redraw_clip (view, NULL);
|
|
|
|
clutter_stage_view_schedule_update (view);
|
|
|
|
|
2020-04-30 17:53:30 +02:00
|
|
|
G_OBJECT_CLASS (clutter_stage_view_parent_class)->constructed (object);
|
|
|
|
}
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
static void
|
|
|
|
clutter_stage_view_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
int i;
|
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-27 11:09:24 +08:00
|
|
|
|
2020-04-30 10:42:30 +02:00
|
|
|
g_clear_pointer (&priv->name, g_free);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
|
2020-10-13 11:35:47 +02:00
|
|
|
g_clear_object (&priv->shadow.framebuffer);
|
clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.
This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-06 22:14:17 +02:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (priv->shadow.dma_buf.handles); i++)
|
|
|
|
{
|
|
|
|
g_clear_pointer (&priv->shadow.dma_buf.handles[i],
|
|
|
|
cogl_dma_buf_handle_free);
|
|
|
|
}
|
|
|
|
g_clear_pointer (&priv->shadow.dma_buf.damage_history,
|
|
|
|
clutter_damage_history_free);
|
|
|
|
|
2020-10-13 11:35:47 +02:00
|
|
|
g_clear_object (&priv->offscreen);
|
2019-10-22 17:03:03 +02:00
|
|
|
g_clear_pointer (&priv->offscreen_pipeline, cogl_object_unref);
|
2020-02-06 10:12:54 +01:00
|
|
|
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
|
2022-06-25 22:14:41 +02:00
|
|
|
g_clear_pointer (&priv->accumulated_redraw_clip, cairo_region_destroy);
|
2020-06-10 14:43:16 +02:00
|
|
|
g_clear_pointer (&priv->frame_clock, clutter_frame_clock_destroy);
|
2016-08-01 02:44:57 +02:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_stage_view_parent_class)->dispose (object);
|
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-27 11:09:24 +08:00
|
|
|
}
|
|
|
|
|
2020-08-16 21:36:38 +02:00
|
|
|
static void
|
|
|
|
clutter_stage_view_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
2020-10-13 11:35:47 +02:00
|
|
|
g_clear_object (&priv->framebuffer);
|
2020-08-16 21:36:38 +02:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_stage_view_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
static void
|
|
|
|
clutter_stage_view_init (ClutterStageView *view)
|
|
|
|
{
|
2016-07-25 15:39:44 +08:00
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
priv->dirty_viewport = TRUE;
|
|
|
|
priv->dirty_projection = TRUE;
|
2017-05-25 15:54:37 +08:00
|
|
|
priv->scale = 1.0;
|
2020-04-17 09:18:37 +02:00
|
|
|
priv->refresh_rate = 60.0;
|
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-27 11:09:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_stage_view_class_init (ClutterStageViewClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2016-08-01 02:44:57 +02:00
|
|
|
klass->get_offscreen_transformation_matrix =
|
|
|
|
clutter_stage_default_get_offscreen_transformation_matrix;
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
object_class->get_property = clutter_stage_view_get_property;
|
|
|
|
object_class->set_property = clutter_stage_view_set_property;
|
2020-04-30 17:53:30 +02:00
|
|
|
object_class->constructed = clutter_stage_view_constructed;
|
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-27 11:09:24 +08:00
|
|
|
object_class->dispose = clutter_stage_view_dispose;
|
2020-08-16 21:36:38 +02:00
|
|
|
object_class->finalize = clutter_stage_view_finalize;
|
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-27 11:09:24 +08:00
|
|
|
|
2020-04-30 10:42:30 +02:00
|
|
|
obj_props[PROP_NAME] =
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
"Name",
|
|
|
|
"Name of view",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2020-03-30 17:34:43 +02:00
|
|
|
|
|
|
|
obj_props[PROP_STAGE] =
|
|
|
|
g_param_spec_object ("stage",
|
|
|
|
"The stage",
|
|
|
|
"The ClutterStage",
|
|
|
|
CLUTTER_TYPE_STAGE,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
obj_props[PROP_LAYOUT] =
|
|
|
|
g_param_spec_boxed ("layout",
|
|
|
|
"View layout",
|
|
|
|
"The view layout on the screen",
|
|
|
|
CAIRO_GOBJECT_TYPE_RECTANGLE_INT,
|
|
|
|
G_PARAM_READWRITE |
|
2017-05-25 15:50:24 +08:00
|
|
|
G_PARAM_CONSTRUCT |
|
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-27 11:09:24 +08:00
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
obj_props[PROP_FRAMEBUFFER] =
|
2020-10-13 11:35:47 +02:00
|
|
|
g_param_spec_object ("framebuffer",
|
|
|
|
"View framebuffer",
|
|
|
|
"The front buffer of the view",
|
|
|
|
COGL_TYPE_FRAMEBUFFER,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2016-08-01 02:44:57 +02:00
|
|
|
|
|
|
|
obj_props[PROP_OFFSCREEN] =
|
2020-10-13 11:35:47 +02:00
|
|
|
g_param_spec_object ("offscreen",
|
|
|
|
"Offscreen buffer",
|
|
|
|
"Framebuffer used as intermediate buffer",
|
|
|
|
COGL_TYPE_OFFSCREEN,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
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-27 11:09:24 +08:00
|
|
|
|
2020-04-30 17:53:30 +02:00
|
|
|
obj_props[PROP_USE_SHADOWFB] =
|
|
|
|
g_param_spec_boolean ("use-shadowfb",
|
|
|
|
"Use shadowfb",
|
|
|
|
"Whether to use one or more shadow framebuffers",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2019-10-22 17:03:03 +02:00
|
|
|
|
2017-02-24 17:38:47 +08:00
|
|
|
obj_props[PROP_SCALE] =
|
2017-05-25 15:54:37 +08:00
|
|
|
g_param_spec_float ("scale",
|
|
|
|
"View scale",
|
|
|
|
"The view scale",
|
2017-06-07 17:35:23 +08:00
|
|
|
0.5, G_MAXFLOAT, 1.0,
|
2017-05-25 15:54:37 +08:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2017-02-24 17:38:47 +08:00
|
|
|
|
2020-04-17 09:18:37 +02:00
|
|
|
obj_props[PROP_REFRESH_RATE] =
|
|
|
|
g_param_spec_float ("refresh-rate",
|
|
|
|
"Refresh rate",
|
|
|
|
"Update refresh rate",
|
|
|
|
1.0, G_MAXFLOAT, 60.0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2021-01-06 15:18:26 +03:00
|
|
|
obj_props[PROP_VBLANK_DURATION_US] =
|
|
|
|
g_param_spec_int64 ("vblank-duration-us",
|
|
|
|
"Vblank duration (µs)",
|
|
|
|
"The vblank duration",
|
|
|
|
0, G_MAXINT64, 0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
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-27 11:09:24 +08:00
|
|
|
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
|
|
|
}
|
2022-01-26 18:39:27 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
clutter_stage_view_invalidate_input_devices (ClutterStageView *view)
|
|
|
|
{
|
|
|
|
ClutterStageViewPrivate *priv =
|
|
|
|
clutter_stage_view_get_instance_private (view);
|
|
|
|
|
|
|
|
priv->needs_update_devices = TRUE;
|
|
|
|
}
|