From 2388e30bd5ef01ab67d6be769743da3e830f59c4 Mon Sep 17 00:00:00 2001 From: Shinyzenith Date: Tue, 11 Jul 2023 18:07:26 +0530 Subject: libscenefx and tinywl compilation success Signed-off-by: Shinyzenith --- types/buffer/buffer.c | 29 +++++++++++++++++++++++++++++ types/meson.build | 1 + 2 files changed, 30 insertions(+) create mode 100644 types/buffer/buffer.c (limited to 'types') diff --git a/types/buffer/buffer.c b/types/buffer/buffer.c new file mode 100644 index 0000000..d4c47bc --- /dev/null +++ b/types/buffer/buffer.c @@ -0,0 +1,29 @@ +#include "render/pixel_format.h" +#include "types/wlr_buffer.h" + +bool buffer_is_opaque(struct wlr_buffer *buffer) { + void *data; + uint32_t format; + size_t stride; + struct wlr_dmabuf_attributes dmabuf; + struct wlr_shm_attributes shm; + if (wlr_buffer_get_dmabuf(buffer, &dmabuf)) { + format = dmabuf.format; + } else if (wlr_buffer_get_shm(buffer, &shm)) { + format = shm.format; + } else if (wlr_buffer_begin_data_ptr_access(buffer, + WLR_BUFFER_DATA_PTR_ACCESS_READ, + &data, &format, &stride)) { + wlr_buffer_end_data_ptr_access(buffer); + } else { + return false; + } + + const struct wlr_pixel_format_info *format_info = + drm_get_pixel_format_info(format); + if (format_info == NULL) { + return false; + } + + return !format_info->has_alpha; +} diff --git a/types/meson.build b/types/meson.build index 0654669..fa37bda 100644 --- a/types/meson.build +++ b/types/meson.build @@ -5,4 +5,5 @@ wlr_files += files( 'scene/output_layout.c', 'scene/xdg_shell.c', 'scene/layer_shell_v1.c', + 'buffer/buffer.c', ) -- cgit v1.2.3