Commit Graph

23312 Commits

Author SHA1 Message Date
Ray Strode
4d5869f6e9 backends/native: emit gl-video-memory-purged when becoming active
The proprietary NVIDIA driver garbles memory on suspend.  In order
to work around that limitation, mutter needs to refresh all its
textures on resuem.

This commit lays the way toward doing that by emitting the
"gl-video-memory-purged" signal when the compositor becomes active
by logind (which happens on VT switch and on resume).
2019-02-11 17:45:42 -05:00
Ray Strode
214aced750 wayland: force X clients to redraw on resume
On nvidia, the textures backing Xwayland client window contents get
corrupted on suspend.  Xwayland currently doesn't handle this situation
itself.

For now, in order to work around this issue, send an empty output
change event to Xwayland.  This will cause it to force Expose events
to get sent to all clients and get them to redraw.
2019-02-11 17:45:42 -05:00
Ray Strode
4ac2899576 backend: add signals for reporting suspend and resume
This commit adds "suspending" and "resuming" signals
to MetaBackend.

It's preliminary work needed for tracking when to purge
and recreate all textures (needed by nvidia).
2019-02-11 17:45:42 -05:00
Ray Strode
76c34858d1 backend: switch to using generated logind proxy
Right now we listen to prepare-for-sleep using
raw gdbus calls.

This commit switches it over to use a generated
proxy, which will become useful in a future commit,
for adding suspending inhibitors.
2019-02-11 17:45:42 -05:00
Ray Strode
ea6535c639 cogl: add new UNSTABLE_TEXTURES feature
The proprietary nvidia driver garbles texture memory on suspend.

Before we can address that, we need to be able to detect it.

This commit adds a new UNSTABLE_TEXTURES feature that gets set if
the proprietary nvidia driver is in use.
2019-02-11 13:40:19 -05:00
Jonas Ådahl
18b68e3a84 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-02-11 13:40:19 -05:00
Olivier Fourdan
3bdfbf97b9 window-actor: Use actual image size for capture
Previously, the clipping rectangle passed to
`meta_surface_actor_get_image()` was updated with the actual texture
size, but recent changes in `meta_shaped_texture_get_image()` now keep
the caller's clipping rectangle unchanged.

The implementation of `meta_window_actor_capture_into()` was relying on
the old behavior of updating the passed clipping rectangle, but now that
it's kept unchanged, the actual clipping rectangle used to copy the data
is wrong, which causes either a distorded image or worse, a crash of
mutter.

Use the resulting cairo image size to copy the data instead of the
clipping rectangle to avoid the issue and get the expected size.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/442
2019-02-11 13:40:19 -05:00
Jonas Ådahl
a7f2145965 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-02-11 13:40:19 -05:00
Jonas Ådahl
ffa30f50f2 cursor-tracker: Emit cursor-changed after renderer was updated
Otherwise the cursor retrieved via meta_cursor_renderer_get_cursor() is
out of date.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:19 -05:00
Jonas Ådahl
0ec335395d 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-02-11 13:40:19 -05:00
Jonas Ådahl
46dccd898e cursor-renderer: Add API to allow inhibiting HW cursor
There may be reasons to temporarly inhibit the HW cursor under certain
circumstances. Allow adding such inhibitations by adding API to the
cursor renderer to allow API users to add generic inhibitors with
whatever logic is deemed necessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
fcd55e6f59 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-02-11 13:40:18 -05:00
Jonas Ådahl
c5f0fc1276 backends/stage: Emit signal between painting actors and overlays
Will be used by screen casting for embedding the cursor separately, or
not including at all.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
7ca0fee437 backends/stage: Fix minor style issue
https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
1d8384372a renderer: Add API to get view from logical monitor
Will be used to get the view scale for a logical monitor, which is
necessary for passing cursor sprites via PipeWire.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
851954b7ed screen-cast: Add getters to fetch object owners
MetaBackend owns MetaScreenCast which owns MetaScreenCastSession which
owns MetaScreenCastStream. Make it possible to fetch objects in the
oppositev direction too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
fef2ecd1e2 screen-cast-monitor-stream: Don't pass monitor manager when creating
It can be fetched indirectly from the monitor already.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
c74dc7ce45 clutter/stage: Add clutter_stage_is_redraw_queued() API
This will be used by the screen casting code to check whether it should
wait for a frame before reading cursor state, or send only the cursor
update, if no redraw is queued.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
63cee05c65 cursor-tracker: Add 'cursor-moved' signal
https://gitlab.gnome.org/GNOME/mutter/merge_requests/357
2019-02-11 13:40:18 -05:00
Jonas Ådahl
6628d12f3c renderer/native: Make the EGLStreams operate in mailbox mode
This means eglSwapBuffers() wont dead lock if there is an old buffer pending
page flip. This could happen after e.g. mode changes or for other reasons.
2019-02-11 13:40:18 -05:00
Jonas Ådahl
3e8364d11d renderer/native: Make EGLStream page flip errors non-fatal
Just continue rendering; we don't care if we were busy once, as it'll most
likely work when we flip the next time.
2019-02-11 13:40:18 -05:00
Jonas Ådahl
58c2c2c444 shaped-texture: Draw external textures via offscreen
EGLStream textures are imported as GL_TEXTURE_EXTERNAL_OES and reading
pixels directly from them is not supported. To make it possible to get
pixels, create an offscreen framebuffer and paint the actor to it, then
read pixels from the framebuffer instead of the texture directly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
1fe3adcd95 shaped-texture: Don't change the callers clip rect
We intersected the callers clip rect. That is probably not a good idea,
and easily avoided, so lets avoid it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
a53eb8dcbd shaped-texture: Add priv pointer to _get_image()
The MetaShapedTexturePrivate is accessed more than once, so keep a
pointer to it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
06be60bc72 shaped-texture: Stop using gdk rect helper
We have our own version, just use that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
e8a3341700 boxes: Add helper to scale rectangles by a double
And change the similar region scaling helper to use this one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
847d37b4f1 shaped-texture: Put actual texture painting in helper
This is so that it can be reused later by meta_shaped_texture_get_image() for
drawing via an offscreen framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
01d147a2d7 compositor: Make meta_actor_painting_untransformed take a framebuffer
Stop using the cogl draw framebuffer implicitly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
e27c63e41b cogl/texture: Add API to check whether _get_data() will work
Currently, GL_TEXTURE_EXTERNAL_OES textures doesn't support getting pixel data.
Make it possible for texture users to know this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
6dc7bacf08 cogl/texture-2d-gl: Bind correct target when getting data
While for normal textures, GL_TEXTURE_2D should be used, when it's an external
texture, binding it using GL_TEXTURE_2D results in an error.

Reading the specification for GL_TEXTURE_EXTERNAL_OES it is unclear whether
getting pixel data from a texture is possible, and tests show it doesn't result
in any data, but in case it would eventually start working, at least bind the
correct target for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
29e7a69729 cogl/texture-2d-gl: Try to determine format for external textures
Don't just set the internal format to the dummy format "any", as that causes
code intended to be unreachable code to be reached. It's not possible to
actually know the internal format of an external texture, however, so it might
not actually correspond to the real format.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-02-11 13:40:18 -05:00
Jonas Ådahl
68337774fc window: Fix introspection warnings
(transfer none) was added for fundamental types, which can't be
transfered.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/356
(cherry picked from commit 781ec74fd2)
2019-02-11 13:40:17 -05:00
Olivier Fourdan
0c9eb18b06 window: Expose the client type in the API
We already have the enum exposed, but no accessor function.

Add `meta_window_get_client_type()` which returns the
`MetaWindowClientType` of a window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit 7a5e0c7824)
2019-02-11 13:40:17 -05:00
Olivier Fourdan
e19a294e44 screen-cast-session: Add window-id support
Use the "window-id" property to select the window to cast using
RecordWindow.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit c786b6c13c)
2019-02-11 13:40:17 -05:00
Olivier Fourdan
b0267c1a4e window: Add window id
Generate a unique 64bit window-id which is unrelated to any windowing
backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit bbcb66ddf4)
2019-02-11 13:40:17 -05:00
Olivier Fourdan
c60c2f997c screen-cast-session: Add support for RecordWindow
Add support for the RecordWindow screencast method, casting the
currently focused window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit ec25f3a6b7)
2019-02-11 13:40:17 -05:00
Olivier Fourdan
591e7c5760 screen-cast-session: Add screen-cast window mode
Window mode will cast the content of a single window using the
`MetaScreenCastWindow` interface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit dbe7279c7f)
2019-02-11 13:40:16 -05:00
Olivier Fourdan
acca2962f1 window-actor: Implement MetaScreenCastWindow interface
Implements the `MetaScreenCastWindow` interface for screen-cast
`RecordWindow` mode.

`meta_window_actor_capture_into()` implementation is still pretty crude
and doesn't take into account subsurfaces and O-R windows so menus,
popups and other tooltips won't show in the capture.

This is left as a future improvement for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit 931934511c)
2019-02-11 13:40:16 -05:00
Olivier Fourdan
c94ee761af screen-cast: Add screen-cast-window interface
Typically, to stream the content of a window, we need a way to copy the
content of its window-actor into a buffer, transform relative input
coordinates to relative position within the window-actor and a mean to
get the window bounds within the buffer.

For this purpose, add a new GType interface `MetaScreenCastWindow` with
the methods needed for screen-cast window mode:

 * meta_screen_cast_window_get_buffer_bounds()
 * meta_screen_cast_window_get_frame_bounds()
 * meta_screen_cast_window_transform_relative_position()
 * meta_screen_cast_window_capture_into()

This interface is meant to be implemented by `MetaWindowActor` which has
access to all the necessary bits to implement them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit 20c9ca25c0)
2019-02-11 13:40:16 -05:00
Olivier Fourdan
9cde0a78d8 screen-cast-src: Add VideoCrop support
To be able to cast windows, which by definition can change in size
dynamically, we need a way to specify the video crop meta to adjust to
the window size whenever it changes.

Add VideoCrop support with a new optional hook `get_videocrop()` in the
`ScreenCastStreamSrcClass` which, if defined, can let the child specify
a rectangle for the video cropping area.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
(cherry picked from commit f64eba57ce)
2019-02-11 13:40:16 -05:00
Olivier Fourdan
a96f057ff1 remote-desktop: Do not leak the virtual touchscreen
Virtual keyboard and pointer are freed on session close, but the
virtual touchscreen isn't.

Avoid a leak by freeing the virtual touchscreen along with the rest of
virtual devices.
2019-02-11 13:40:15 -05:00
Olivier Fourdan
d165eb90a1 clutter: Keep a device reference with events
If a device (virtual or real) is removed while there are remaining
events queued for that device, the event loop may try to access the
event freed memory.

To avoid the issue, add a reference to the device when the event is
created or copied, and remove the reference once the device is freed.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/393
2019-02-11 13:40:15 -05:00
Olivier Fourdan
53a5c6a14a clutter/evdev: Use clutter_event_set_device()
Use the relevant clutter device API `clutter_event_set_device()` instead
of setting the device directly in the event field.
2019-02-11 13:40:15 -05:00
Jonas Ådahl
71288b22ba renderer/native: Use shadow fb on software GL if preferred
If a KMS device has the DRM_CAP_DUMB_PREFER_SHADOW and a software based
GL driver is used, always use a shadow fb. This will speed up read backs
in the llvmpipe OpenGL implementation, making blend operations faster.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/106
2019-02-11 13:40:15 -05:00
Jonas Ådahl
988f6e72fe renderer/native: Also wrap flip closures for EGLStreams
When using the EGLStream backend, the MetaRendererNative passed a
GClosure to KMS when using EGLStreams, but KMS flip callback event
handler in meta-gpu-kms.c expected a closure wrapped in a closure
container, meaning it'd instead crash when using EGLStreams. Make the
flip handler get what it expects also when using EGLStreams by wrapping
the flip closure in the container before handing it over to EGL.

https://bugzilla.gnome.org/show_bug.cgi?id=790316
(cherry picked from commit 8ee14a7cb7)
2019-02-11 13:40:15 -05:00
Miguel A. Vico
8eccb68687 wayland: Create EGLStream-backed buffers through wl_eglstream_controller
One of the current limitations of EGLStreams is that there's no way to
resize a surface consumer without re-creating the entire stream.

Therefore, while resizing, clients will send wl_surface::attach requests
so the compositor can re-create its endpoint of the stream, but no
buffer will be available actually. If we proceed with the rest of the
attach operation we'll be presenting an empty buffer.

In order to fix this, a separate wl_eglstream_controller protocol has
been introduced that clients can use to request a stream re-creation
without overloading wl_surface::attach for that purpose.

This change adds the required logic to create the corresponding
wl_eglstream_controller global interface that clients can bind to.

Whenever a client requests a stream to be created, we just need to
create and realize the new EGLStream buffer. The same buffer resource
will be given at a later time to wl_surface::attach, whenever new
content is made available by the application, so we can proceed to
acquire the stream buffer and update the surface state.

https://bugzilla.gnome.org/show_bug.cgi?id=782575

(cherry picked from commit 435b3c4bdb)
2019-02-11 13:40:14 -05:00
Miguel A. Vico
b2a035348b wayland: Realize dmabuf buffers before trying to attach them
Commit 22723ca37 moved buffer realization to
meta_wayland_surface_commit() so that it wouldn't be part of
meta_wayland_buffer_attach().

However, creation of dmabuf buffers would call into
meta_wayland_buffer_attach() directly without realizing the buffer
first. attach() would then fail and mutter would effectively shut down
any clients using the zwp_linux_dmabuf protocol (note that if such
client was Xwayland, mutter itself would shut down as well).

Add the missing bit in order to make zwp_linux_dmabuf protocol work
again.

(cherry picked from commit 54709c16b5)
2019-02-11 13:40:14 -05:00
Miguel A. Vico
d820815472 wayland: Always realize buffers at surface commit time
Clients using EGLStream-backed buffers will expect the stream to be
functional after wl_surface::attach(). That means the compositor-side
stream must be created and a consumer attached to it.

To resolve the above, this change realizes buffers even when the attach
operation is deferred (e.g. synchronized subsurfaces).

https://bugzilla.gnome.org/show_bug.cgi?id=782575

(cherry picked from commit 22723ca371)
2019-02-11 13:40:14 -05:00
Miguel A. Vico
f459cd37ff wayland-buffer: Create EGLStream texture at buffer_realize time
When dealing with synchronized subsurfaces, we defer buffer attachments
until the parent surface state is applied.

That causes interaction issues with EGLStream backed buffers, as the
client expects the compositor-side stream to be functional after it
requests a wl_surface::attach.

By allowing the compositor to realize buffers without attaching them, we
could resolve the issue above if we define a realized EGLStream buffer
as a functional EGLStream (EGLStream + attached consumer).

This change moves the texture consumer creation part from the attach
function to the realize one.

https://bugzilla.gnome.org/show_bug.cgi?id=782575

(cherry picked from commit edd3634bb5)
2019-02-11 13:40:14 -05:00
Miguel A. Vico
0f93452488 renderer/native: Choose first EGL config for non-GBM backends
Commit 712ec30cd9 added the logic to only
choose EGL configs that match the GBM_FORMAT_XRGB8888 pixel format.
However, there won't be any EGL config satisfying such criteria for
non-GBM backends, such as EGLDevice.

This change will let us choose the first EGL config for the EGLDevice
backend, while still forcing GBM_FORMAT_XRGB8888 configs for the GBM
one.

Related to: https://gitlab.gnome.org/GNOME/mutter/issues/2

(cherry picked from commit 1bf2eb95b5)
2019-02-11 13:40:13 -05:00