mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 14:35:57 +01:00
screencast: pipewire add import_wl_shm_buffer function
This function lets us create a wl_buffer from any shared memory filedescriptor.
This commit is contained in:
parent
9bf7367320
commit
566fb7c1a0
2 changed files with 19 additions and 0 deletions
|
@ -123,6 +123,8 @@ struct xdpw_wlr_output {
|
|||
|
||||
void randname(char *buf);
|
||||
int anonymous_shm_open(void);
|
||||
struct wl_buffer *import_wl_shm_buffer(struct xdpw_screencast_instance *cast, int fd,
|
||||
enum wl_shm_format fmt, int width, int height, int stride);
|
||||
enum spa_video_format xdpw_format_pw_from_wl_shm(enum wl_shm_format format);
|
||||
enum spa_video_format xdpw_format_pw_strip_alpha(enum spa_video_format format);
|
||||
|
||||
|
|
|
@ -36,6 +36,23 @@ int anonymous_shm_open(void) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
struct wl_buffer *import_wl_shm_buffer(struct xdpw_screencast_instance *cast, int fd,
|
||||
enum wl_shm_format fmt, int width, int height, int stride) {
|
||||
struct xdpw_screencast_context *ctx = cast->ctx;
|
||||
int size = stride * height;
|
||||
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wl_shm_pool *pool = wl_shm_create_pool(ctx->shm, fd, size);
|
||||
struct wl_buffer *buffer =
|
||||
wl_shm_pool_create_buffer(pool, 0, width, height, stride, fmt);
|
||||
wl_shm_pool_destroy(pool);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
enum spa_video_format xdpw_format_pw_from_wl_shm(enum wl_shm_format format) {
|
||||
switch (format) {
|
||||
case WL_SHM_FORMAT_ARGB8888:
|
||||
|
|
Loading…
Reference in a new issue