summaryrefslogtreecommitdiff
path: root/types/buffer/buffer.c
diff options
context:
space:
mode:
authorShinyzenith <[email protected]>2023-07-11 18:07:26 +0530
committerShinyzenith <[email protected]>2023-07-11 18:10:10 +0530
commit2388e30bd5ef01ab67d6be769743da3e830f59c4 (patch)
treeeeb9685137d95e888a6b98785109b9f3d9129a59 /types/buffer/buffer.c
parent9eaa07a4b141bc80a46cb7ab2dc94048f126fa8c (diff)
libscenefx and tinywl compilation success
Signed-off-by: Shinyzenith <[email protected]>
Diffstat (limited to 'types/buffer/buffer.c')
-rw-r--r--types/buffer/buffer.c29
1 files changed, 29 insertions, 0 deletions
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;
+}