Commit Graph

82 Commits

Author SHA1 Message Date
Alexander Orzechowski 94c31b824c screencopy: Add some logging 2024-03-22 11:36:12 -04:00
Alexander Orzechowski 3224fe6a51 screencopy: Remove dead code 2024-03-22 11:33:10 -04:00
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Paul Cercueil 220df2aa0f
Add more POSIX compliance macros to fix uClibc support
- Add POSIX 1993.09 compliance macro in source files that use
  "struct timespec";
- Add POSIX 2001.12 compliance macro in source files that use
  "struct sigaction" and the SA_SIGINFO macro, or the fchmod()
  function;
- Add POSIX 2008.09 compliance macro in source files that use the
  getline() function.

These compliance macros are enough for wlroots to compile with the
git-master version of uClibc-ng.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2024-02-12 17:41:45 +01:00
Alexander Orzechowski b3575fedbc screencopy_v1: Use new read pixels API 2023-11-30 20:01:12 -05:00
Simon Ser 56ec13596a Cleanup wlr_matrix.h includes
Many files used to require wlr_matrix but no longer do.
2023-11-25 08:37:43 +01:00
Simon Ser 9e702e9cfe util/transform: move over wl_output_transform helpers
These aren't really tied to wlr_output.
2023-11-23 11:03:57 +01:00
Alexander Orzechowski 515681503e screencopy: Use box size instead for shm copy
This doesn't change functionality, both the values are the same. Less
confusing to use the box size.
2023-11-20 11:33:11 -05:00
Alexander Orzechowski 7a22030071 screencopy: Move frame bounds sanity check into common code 2023-11-20 11:33:11 -05:00
Alexander Orzechowski c8861a2865 screencopy: Define proper destination for dmabuf copy
Leaving this empty would have it filled in with the size of the source
texture, but we want the destination size.

Fixes: #3758
2023-11-20 11:33:10 -05:00
eri 8ccbe45143
buffer: convert to try_from
References: wlroots/wlroots#884
2023-10-19 18:19:27 +02:00
Alexander Orzechowski 5fb0007e02 output_event_commit: Remove committed and buffer
The newly introduced state struct can be used to retrieve this.
2023-10-06 10:06:01 +00:00
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Manuel Stoeckl dbc7a5cada screencopy_v1: only bind, not render with, buffer in shm copy path
wlr_renderer_read_pixels does not need to be called inside a render
pass; rather, it only needs to have the correct buffer bound to
the renderer. This commit optimizes the implementation of
frame_shm_copy(...) by only binding the source buffer instead of
starting a no-op render pass with it.
2023-09-11 20:25:07 -04:00
Alexander Orzechowski aee31edaad screencopy_v1: Implement copy regions with gpu blit path 2023-08-12 10:16:51 +00:00
Alexander Orzechowski b4cbaa4549 screencopy_v1: Use new renderer API for gpu blit path 2023-08-12 10:16:51 +00:00
Rose Hudson 71daec9441 export-dmabuf, screencopy: schedule_frame -> needs_frame
needs_frame is for backends to trigger frames for reasons that
compositors couldn't see coming. schedule_frame is freaky and I want to
remove it. These protocols aren't backends but in this case they're
close enough, so switch to needs_frame.

CC #3664
2023-07-18 12:01:16 +01:00
Manuel Stoeckl bbd53b3b46 screencopy-v1: fix logical->physical region transform
This now matches the transformations used for e.g. cursor scissor
regions and damage.
2023-07-01 10:05:30 -04:00
Simon Ser 96f3f3c92e render/pixel-format: add support for block-based formats
Some formats like sub-sampled YCbCr use a block of bytes to
store the color values for more than one pixel. Update our format
table to be able to handle such formats.
2023-05-21 20:28:45 +00:00
Simon Ser d25ab03326 screencopy-v1: drop unnecessary pixman_region32_t casts
The Pixman API now accepts const parameters.
2023-02-21 09:37:59 +00:00
Simon Ser 6832ae14aa render: drop wlr_renderer_read_pixels() flags
These are unused.
2022-10-04 09:15:19 +02:00
Simon Ser 50cc1ef4d3 screencopy-v1: simplify frame_dma_copy() error path
Unify success and error code-paths.
2022-10-03 17:06:38 +00:00
Simon Ser 0af4affd0b screencopy-v1: fix frame_shm_copy() error path
Don't call wlr_renderer_end() if wlr_renderer_begin_with_buffer()
failed. This will result in an abort().
2022-10-03 17:06:38 +00:00
Simon Ser c153ae3c5d screencopy-v1: use wlr_buffer APIs
Instead of using low-level wl_shm_buffer and wlr_dmabuf_v1_buffer
APIs, use the unified wlr_buffer APIs. That way it doesn't matter
what the exact wlr_buffer implementation is used, any which provides
the necessary capabilities (data_ptr or dmabuf) would work.

Simplifies the logic a bit, and will make the transition to wlr_shm
easier.
2022-09-22 18:01:52 +00:00
Simon Ser f03da48491 screencopy-v1: rename wlr_screencopy_frame_v1.stride
Make it clear it's only about shm, not about DMA-BUFs.
2022-09-22 18:01:52 +00:00
Simon Ser 77b829e15f screencopy-v1: use DRM format code for shm buffers
Will allow us to simplify common shm/DMA-BUF logic later on.
2022-09-22 18:01:52 +00:00
Simon Ser 4885c08f38 screencopy-v1: rename wlr_screencopy_frame_v1.{format,fourcc}
Make it clear that one is for shm buffers only, and the other is
for DMA-BUF buffers only.
2022-09-22 18:01:52 +00:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Simon Ser b21c26a1c9 output: add wlr_output_event_precommit.state 2022-05-30 11:34:57 +02:00
Manuel Stoeckl 9cae874513 screencopy-v1: Fix frame stride for formats with bpp != 32 2022-05-23 07:37:24 +00:00
Simon Ser 45069fb623 screencopy-v1: use wlr_output_event_commit.buffer 2021-12-03 14:56:17 +00:00
Simon Zeni d07c87f668 types/wlr_screencopy_v1: use renderer from output 2021-11-18 09:37:57 -05:00
Simon Ser a04cfca4da Remove support for DMA-BUF flags
They are never used in practice, which makes all of our flag
handling effectively dead code. Also, APIs such as KMS don't
provide a good way to deal with the flags. Let's just fail the
DMA-BUF import when clients provide flags.
2021-11-17 16:12:59 +00:00
Simon Ser fa77aeb80e screencopy-v1: stop using wlr_output_export_dmabuf 2021-11-08 15:57:19 +00:00
Simon Ser 3b96aa04db sceeencopy-v1: listen to output destroy in capture_output
If the output is destroyed after capture_output but before
frame_handle_copy, it'll have a dangling output pointer. Add the
output destroy listener in capture_output.

Closes: https://github.com/swaywm/wlroots/issues/3284
2021-10-29 11:37:59 +02:00
Andri Yngvason 105fdecd0c screencopy: Handle shm copy in commit event handler
This simplifies the implementation considerably.
2021-09-10 10:37:18 +02:00
Andri Yngvason 04d234bac1 screencopy: Use output->front_buffer instead of wlr_output_export_dmabuf 2021-09-10 10:37:18 +02:00
Simon Zeni e192d87731 move wlr_box from /types to /util 2021-07-06 21:43:17 +02:00
Simon Ser a667175ec7 screencopy-v1: use wlr_renderer_begin_with_buffer 2021-06-09 10:26:09 +02:00
Simon Ser a8d7c2d4ea screencopy-v1: stop using wlr_client_buffer
We can just use the wlr_dmabuf_v1_buffer directly, no need to wrap
it in a wlr_client_buffer.
2021-05-17 16:22:43 +02:00
Simon Zeni ccbce0f0a6 types/wlr_screencopy_v1: log error on read pixels failure 2021-04-27 18:28:41 +02:00
Simon Ser e8df7c367a linux-dmabuf-v1: split params and buffer
Previously, the same struct was used for linux-dmabuf-v1 params
and buffer. This made the whole logic a little bit awkward, because
a wlr_dmabuf_v1_buffer could either be still being constructed, or
be a complete buffer.

Introduce a separate wlr_linux_buffer_params_v1 struct for buffer
params still being constructed. Once the params are complete (ie.
once the create request is sent), the params struct is destroyed
and the buffer struct is created.

This will help with [1] as well.

[1]: https://github.com/swaywm/wlroots/issues/2664
2021-04-19 18:09:13 +02:00
Simon Zeni 50d2985607 Move render/shm_format functions to render/pixel_format 2021-03-25 10:55:54 +01:00
Simon Ser c740fccc9d Fix buffer blit matrices
There was a missing wlr_matrix_scale call, so we ended up with black
frames.

Closes: https://github.com/swaywm/wlroots/issues/2780
2021-03-16 17:57:51 +01:00
Simon Ser 7720dde74d screencopy: stop using wlr_renderer_blit_dmabuf
The original motivation is the following crash:

    #0  0x00007f0ddeddeef5 in raise () at /usr/lib/libc.so.6
    #1  0x00007f0ddedc8862 in abort () at /usr/lib/libc.so.6
    #2  0x00007f0ddedc8747 in _nl_load_domain.cold () at /usr/lib/libc.so.6
    #3  0x00007f0ddedd7646 in  () at /usr/lib/libc.so.6
    #4  0x00007f0de033f8de in gles2_get_renderer_in_context (wlr_renderer=0x612000003640) at ../subprojects/wlroots/render/gles2/renderer.c:38
    #5  0x00007f0de0341675 in gles2_begin (wlr_renderer=0x612000003640, width=3840, height=2160) at ../subprojects/wlroots/render/gles2/renderer.c:186
    #6  0x00007f0de033b100 in wlr_renderer_begin (r=0x612000003640, width=3840, height=2160) at ../subprojects/wlroots/render/wlr_renderer.c:56
    #7  0x00007f0de03466ed in gles2_blit_dmabuf (wlr_renderer=0x612000003640, dst_attr=0x60b000150148, src_attr=0x7fff9f9bfde0) at ../subprojects/wlroots/render/gles2/renderer.c:591
    #8  0x00007f0de033d717 in wlr_renderer_blit_dmabuf (r=0x612000003640, dst=0x60b000150148, src=0x7fff9f9bfde0) at ../subprojects/wlroots/render/wlr_renderer.c:210
    #9  0x00007f0de04cbc3b in frame_handle_output_commit (listener=0x611000220bc8, data=0x7fff9f9c0050) at ../subprojects/wlroots/types/wlr_screencopy_v1.c:303

The GLES2 renderer assumes it'll have a wlr_buffer to render to.

Instead of accomodating for the edge-case of rendering without a
wlr_buffer, drop wlr_renderer_blit_dmabuf calls and instead use
wlr_renderer_bind_buffer just like the rest of the wlr_renderer users.
wlr_renderer_blit_dmabuf is now unused in wlroots.

The upside is that the new blit_dmabuf function in screencopy is
renderer-agnostic.
2021-03-16 17:57:51 +01:00
Simon Ser b54ef3372d render: use DRM formats in wlr_renderer_read_pixels 2021-02-23 16:09:26 +01:00
Simon Ser 00bf6674b3 output: use DRM format in wlr_output_preferred_read_format 2021-02-23 16:09:26 +01:00
Isaac Freund baf2319fd3 screencopy: don't use output transform for damage copy
Only wlr_output_damage works in transformed coordinates,
wlr_output->damage is in output-buffer-local coordinates.

This essentially reverts 1ecc1b5 and fixes 1477401.
2020-12-07 11:16:45 +01:00
Isaac Freund 37cb3eb8dd screencopy: check if damage committed before copy
This check avoids copying stale state from output->pending.damage.
2020-12-06 17:11:46 +01:00
Isaac Freund 1ecc1b5987 screencopy: use output transform for damage copy 2020-12-06 17:11:46 +01:00