1
0
Fork 0
Commit graph

37 commits

Author SHA1 Message Date
Jonas Ådahl
1d4e535e7a clutter/stage: Remove 'paint' argument in capture_into()
There are more suitable API when the stage needs to be actually painted
into something. Nothing actually used this anymore too, so remove this
functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Carlos Garnacho
d6f720497a backends: Move HW cursor inhibitors to MetaBackend
We are aiming for a split of HW and SW cursor rendering management.
Given the HW plane is a limited resource and the amount of cursor
renderers may be >1 (due to tablets, even though we currently use an
always-software cursor renderer there), it would ideally be able to
switch between renderers.

Being MetaCursorRenderer not really a singleton, having cursor
inhibitor accounting here doesn't pan out. Make it MetaBackend API
so all cursor renderers get the same picture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e218b00747 backends: Make MetaHwCursorInhibitor less about sprites
Remove the sprite argument from the vfunc, it's used in no implementations
and conceptually gets a bit in the middle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
00cbcb7ba1 core: Centralize cursor renderer and tracker updates
These use now more of a "pull" model, where they receive update
notifications and the relevant input position is queried, instead
of the coordinates being passed along.

This allows to treat cursor renderers all the same independently
of the device they track. This notifying of position changes should
ideally be more backend-y than core-y, a better location will be
figured out in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
247613d26d backends: Move away from meta_cursor_renderer_get_position()
We are moving onto relying fully on the seat cursor position. As
this focuses (thus far?) on mouse pointers only, use the cursor
tracker as a convenient shortcut.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
7a2a2445c3 backends: Remove x/y arguments from MetaCursorTracker::cursor-moved
Make this signal a hint, the actual coordinates should be queried to the
cursor tracker, the device, the seat... There's enough options.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Florian Zwoch
efb577efb0 screen-cast: Fix segfault when drawing cursor
Add a sanity check if the cursor is on screen and cursor texture data
is available. This prevents a potential segfault when trying to access
non-existing texture data.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1446
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1604>
2020-11-26 09:59:44 +01:00
Georges Basile Stavracas Neto
a00ab5fada stream: Remove cursor if it's invisible
The cursor tracker may give us a valid position, and a
valid cursor sprite, and yet the cursor can be hidden,
meaning we must hide the cursor on the stream as well.

Remove cursor from stream buffer if it's hidden.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1421
2020-09-01 13:05:29 -03:00
Georges Basile Stavracas Neto
e6a13e5d57 monitor-stream-src: Add before-paint watch to catch scanouts
Scanouts are taken away after painting. However, when we're
streaming, what we actually want is to capture whatever is
going to end up on screen - and that includes the scanout
if there's any.

Add a before-paint watch that only records new frames if a
scanout is set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1421
2020-09-01 13:05:29 -03:00
Georges Basile Stavracas Neto
aed286aa46 monitor-stream-src: Generalize function
We'll need to pass a custom callback to the stage views watcher.
Generalize and rename the add_view_painted_watches() function
to allow accepting custom callbacks.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1421
2020-09-01 13:05:29 -03:00
Georges Basile Stavracas Neto
b1648e75a8 monitor-stream-src: Blit scanout when available
When there's a direct scanout set in the stage view, we
have to use it instead of the view's regular onscreen
framebuffer.

Use the new CoglScanout API to implement blitting to the
stream framebuffer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1421
2020-09-01 13:05:28 -03:00
Georges Basile Stavracas Neto
2b67030dbb streams: Don't bail out when cursor is outside the stream
PipeWire reuses buffers, and buffer metadatas, when streaming. When
the cursor is moved to outside the stream, the cursor meta also needs
to be updated, otherwise it'll use the cursor position of whatever is
in the buffer.

Don't bail out when cursor is outside the stream, and ensure to record
a metadata-only frame. This only applies to metadata streams.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1417
2020-08-28 16:34:56 +00:00
Jonas Ådahl
b4a8247191 screen-cast: Track and always record cursors
Always force-track the cursor position (so that the X11 backend can keep
it up to date), and if the cursor wasn't part of the sampled
framebuffer when reading pixels into CPU memory, draw it in an extra
pass using cairo after the fact. The cairo based cursor painting only
happens on the X11 backend, as we otherwise inhibit the hw cursor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
2020-08-05 11:11:38 +02:00
Jonas Ådahl
9bab8e8751 screen-cast/src: Record follow up frame after timeout
During animation or other things that cause multiple frames in a row
being painted, we might skip recording frames if the max framerate is
reached.

Doing so means we might end up skipping the last frame in a series,
ending with the last frame we sent was not the last one, making things
appear to get stuck sometimes.

Handle this by creating a timeout if we ever throttle, and at the time
the timeout callback is triggered, make sure we eventually send an up to
date frame.

This is handle differently depending on the source type. A monitor
source type reports 1x1 pixel damage on each view its monitor overlaps,
while a window source type simply records a frame from the surface
directly, except without recording a timestamp, so that timestamps
always refer to when damage actually happened.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1361
2020-07-08 21:42:23 +02:00
Jonas Ådahl
047da80c3b screen-cast/src: Make record functions return an error when failing
Now that we don't use the record function to early out depending on
implicit state (don't record pixels if only cursor moved for example),
let it simply report an error when it fails, as we should no longer ever
return without pixels if nothing failed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1361
2020-07-08 21:42:23 +02:00
Jonas Ådahl
882967d3ce screen-cast: Let the reason for recording determine what to record
E.g. we'll have pointer movement that, if no painting is already
scheduled, should only send new cursor metadata without any new pixel
buffer. When this happens, tell next step to not record the pixels if
this was the case, instead of having it rediscover this itself.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1323
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1361
2020-07-08 21:42:23 +02:00
Jonas Ådahl
cea0722e72 screen-cast/src: Add flag to maybe_record()
Will later be used to make recording avoid recording actual pixel
content if e.g. only the cursor moved.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1361
2020-07-08 21:42:23 +02:00
Jonas Ådahl
7b35ed8c35 screen-cast-src: Make the two record vfuncs more similarly named
Both do more or less the same but with different methods - one puts
pixels into a buffer using the CPU, the other puts pixels into a buffer
using the GPU.

However, they are behaving slightly different, which they shouldn't.
Lets first address the misleading disconnect in naming, and later we'll
make them behave more similarly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1361
2020-07-08 21:42:22 +02:00
Jonas Ådahl
b9a52ecfdf screen-cast: Only check queued-redraw on the relevant views
We'd check if there was any queued redraw on the stage, but this is
inappropriate for two reasons:

1) A monitor and area screen cast source only cares about damage on a
   subset of the stage.
2) The global pending-redraw is going away when paint scheduling will be
   more view centric.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
424016d66c stage: Pass paint context in phase callbacks
If there is a paint context available (i.e. for the phases that are
during the actual stage paint), pass it along the callbacks, so that
the callback implementations can change their operation depending on the
paint context state.

This also means we can get the current view from the paint context,
instead of the temporarily used field in the instance struct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Georges Basile Stavracas Neto
09026e5f0e monitor-stream-src: Use cogl_framebuffer_finish()
Even though cogl_framebuffer_flush() was supposed to be enough,
it ends up creating streams with odd visual glitches that look
very much like unfinished frames.

Switch back to cogl_framebuffer_finish(), which is admittedly
an overkill, but it's what works for now. There is anedoctal
evidence showing it doesn't incur in worse performance.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:19 -03:00
Georges Basile Stavracas Neto
680a54aff6 monitor-stream-src: Implement blitting view framebuffers
Add the vfunc override that actually consume the new Cogl API. Every
view that fits into the logical monitor is rendered.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/639

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:03 -03:00
Jonas Ådahl
1c98f01a65 renderer-native: Draw stage separately per CRTC
Prior to this commit the stage was drawn separately for each logical
monitor. This allowed to draw different parts of the stage with
different transformations, e.g. with a different viewport to implement
HiDPI support.

Go even further and have one view per CRTC. This causes the stage to
e.g. draw two mirrored monitors twice, instead of using the same
framebuffer on both. This enables us to do two things: one is to support
tiled monitors and monitor mirroring using the EGLStreams backend; the
other is that it'll enable us to tie rendering directly to the CRTC it
will render for. It is also a requirement for rendering being affected
by CRTC state, such as gamma.

It'll be possible to still inhibit re-drawing of the same content
twice, but it should be implemented differently, so that it will still
be possible to implement features requiring the CRTC split.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
6e5ac0b585 Use G_GNUC_FALLTHROUGH instead of comments
Get the same task done in a bit more C:y way.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/998
2020-01-09 17:58:29 +01:00
Robert Mader
92375c75f8 cleanup: Use g_clear_signal_handler() where possible
This is inspired by 98892391d7 where the usage of
`g_signal_handler_disconnect()` without resetting the corresponding
handler id later resulted in a bug. Using `g_clear_signal_handler()`
makes sure we avoid similar bugs and is almost always the better
alternative. We use it for new code, let's clean up the old code to
also use it.

A further benefit is that it can get called even if the passed id is
0, allowing us to remove a lot of now unnessecary checks, and the fact
that `g_clear_signal_handler()` checks for the right type size, forcing us
to clean up all places where we used `guint` instead of `gulong`.

No functional changes intended here and all changes should be trivial,
thus bundled in one big commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/940
2019-11-21 15:02:27 +00:00
Georges Basile Stavracas Neto
94682e69aa Replace ClutterRect by graphene_rect_t
https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
160cc9182d Replace ClutterPoint by graphene_point_t
Remove the tests for ClutterPoint since it's
corresponding code moved to private ClutterStage
methods.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
2464f00902
screen-cast-monitor-stream-src: Watch monitors using MetaStageWatch
This uses the API introduced by the previous commit. By watching specific
monitors directly, and not whole stage views, we avoid showing artifacts
on multi-monitor setups.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/424

https://gitlab.gnome.org/GNOME/mutter/merge_requests/623
2019-06-19 13:12:18 -03:00
Jonas Ådahl
9be189daa7 screen-cast: Move cursor metadata setting to generic source
Make the monitor implementation do things strictly related to its own
source type, leaving the Spa related logic and cursor read back in the
generic layer, later to be reused by the window source type
implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/413
2019-02-26 13:39:11 +00:00
Jonas Ådahl
3fa6a92cc5 screen-cast: Fix monitor recording on HiDPI
It scaled the logical monitor rect with scale to get the stream
dimensions, but that is only valid when having
'scale-monitor-framebuffers' enabled. Even when it was, it didn't work
properly, as clutter_stage_capture_into() doesn't work properly with
scaled monitor framebuffers yet.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/415
2019-01-26 16:18:45 +00:00
Jonas Ådahl
56d260cfb3 screen-cast-monitor-stream-src: Only send cursor bitmap when it changes
To avoid unnecessary pixel copying, only send the cursor bitmap when it
changes. This also allows the receiver to know when the cursor bitmap
actually changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
4e402b3972 screen-cast: Add 'cursor-mode' to allow decoupled cursor updates
The 'cursor-mode', which currently is limited to RecordMonitor(), allows
the user to either do screen casts where the cursor is hidden, embedded
in the framebuffer, or sent as PipeWire stream metadata.

The latter allows the user to get cursor updates sent, including the
cursor sprite, without requiring a stage paint each frame. Currently
this is done by using the cursor sprite texture, and either reading
directly from, or drawing to an offscreen framebuffer which is read from
instead, in case the texture is scaled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
328eff7352 screen-cast/monitor-stream-src: Copy content before cursor is drawn
To get a consistent behaviour no matter whether HW cursors are in use or
not, make sure to copy the framebuffer content before the stage overlays
(cursor sprite textures) are painted.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-01-16 17:09:51 +00:00
Jonas Ådahl
2f4a68c8c3 Clean up include macros mess
The order and way include macros were structured was chaotic, with no
real common thread between files. Try to tidy up the mess with some
common scheme, to make things look less messy.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
53175e8788 ScreenCast: Pass PipeWire stream node ID directly
As of commit 5f5ef3de2cdc816dab82cb7eb5d7171bee0ad2c5 in pipewire the
stream creator can find out the node ID of the stream it created.

So instead of using a special purpose entry to the info property box to
let the application discover stream by monitoring added nodes searching
for the given special purpose entry, just pass the node directly.

https://bugzilla.gnome.org/show_bug.cgi?id=784199
2017-08-29 14:39:04 +08:00
Jonas Ådahl
920541fa26 screen-cast-stream-src: Only try to record frames when streaming
Only when the PipeWire stream state is 'PW_STREAM_STATE STREAMING'
should the signal be connected causing the src to maybe record a frame.

https://bugzilla.gnome.org/show_bug.cgi?id=784199
2017-08-29 14:39:04 +08:00
Jonas Ådahl
97f2c7c161 Add remote desktop and screen cast functionality
This commit adds basic screen casting and remote desktoping
functionalty. This works by exposing two D-Bus API services:
org.gnome.Mutter.ScreenCast and org.gnome.Mutter.RemoteDesktop.

The remote desktop API is used to create remote desktop sessions. For
each session, a D-Bus object is created, and an application can manage
the session by sending messages to the session object. A remote desktop
session the user to emit input events using the D-Bus methods on the
session object. To get framebuffer content, the application should
create an associated screen cast session.

The screen cast API is used to create screen cast sessions. One can so
far either create stand-alone screen cast sessions, or a screen cast
session associated with a remote desktop session. A remote desktop
associated screen cast session is managed by the remote desktop session.

So far only remote desktop managed screen cast sessions are implemented.

Each screen cast session may have one or more streams. A screen cast
stream is a stream of buffers of some part of the compositor content.
So far API exists for creating streams of monitors and windows, but
only monitor streams are implemented.

When a screen cast session is started, the one PipeWire stream is
created for each screen cast stream created for the session. When this
has happened, a PipeWireStreamAdded signal is emitted on the stream
object, passing a unique identifier. The application may use this
identifier to find the associated stream being advertised by the
PipeWire daemon.

The remote desktop and screen cast functionality must be explicitly be
enabled at ./configure time by passing --enable-remote-desktop to
./configure. Doing this will build both screen cast and remote desktop
support.

To actually enable the screen casting and remote desktop, the user must
enable the experimental feature. See
org.gnome.mutter.experimental-features.

https://bugzilla.gnome.org/show_bug.cgi?id=784199
2017-08-29 14:39:04 +08:00