aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/wlr/render/drm_format_set.h27
-rw-r--r--include/wlr/render/egl.h11
-rw-r--r--include/wlr/render/interface.h5
-rw-r--r--include/wlr/render/meson.build3
-rw-r--r--include/wlr/render/wlr_renderer.h12
5 files changed, 39 insertions, 19 deletions
diff --git a/include/wlr/render/drm_format_set.h b/include/wlr/render/drm_format_set.h
new file mode 100644
index 00000000..588914ae
--- /dev/null
+++ b/include/wlr/render/drm_format_set.h
@@ -0,0 +1,27 @@
+#ifndef WLR_RENDER_DRM_FORMAT_SET_H
+#define WLR_RENDER_DRM_FORMAT_SET_H
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+struct wlr_drm_format {
+ uint32_t format;
+ size_t len, cap;
+ uint64_t modifiers[];
+};
+
+struct wlr_drm_format_set {
+ size_t len, cap;
+ struct wlr_drm_format **formats;
+};
+
+void wlr_drm_format_set_finish(struct wlr_drm_format_set *set);
+
+const struct wlr_drm_format *wlr_drm_format_set_get(
+ const struct wlr_drm_format_set *set, uint32_t format);
+
+bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
+ uint64_t modifier);
+
+#endif
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h
index 269af7e2..fb473ba8 100644
--- a/include/wlr/render/egl.h
+++ b/include/wlr/render/egl.h
@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <wayland-server.h>
#include <wlr/render/dmabuf.h>
+#include <wlr/render/drm_format_set.h>
struct wlr_egl {
EGLenum platform;
@@ -42,6 +43,8 @@ struct wlr_egl {
} exts;
struct wl_display *wl_display;
+
+ struct wlr_drm_format_set dmabuf_formats;
};
// TODO: Allocate and return a wlr_egl
@@ -88,13 +91,7 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
/**
* Get the available dmabuf formats
*/
-int wlr_egl_get_dmabuf_formats(struct wlr_egl *egl, int **formats);
-
-/**
- * Get the available dmabuf modifiers for a given format
- */
-int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl, int format,
- uint64_t **modifiers);
+const struct wlr_drm_format_set *wlr_egl_get_dmabuf_formats(struct wlr_egl *egl);
bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image,
int32_t width, int32_t height, uint32_t flags,
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index c98a7cda..088b1efa 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -46,9 +46,8 @@ struct wlr_renderer_impl {
struct wl_resource *resource);
void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer,
struct wl_resource *buffer, int *width, int *height);
- int (*get_dmabuf_formats)(struct wlr_renderer *renderer, int **formats);
- int (*get_dmabuf_modifiers)(struct wlr_renderer *renderer, int format,
- uint64_t **modifiers);
+ const struct wlr_drm_format_set *(*get_dmabuf_formats)(
+ struct wlr_renderer *renderer);
enum wl_shm_format (*preferred_read_format)(struct wlr_renderer *renderer);
bool (*read_pixels)(struct wlr_renderer *renderer, enum wl_shm_format fmt,
uint32_t *flags, uint32_t stride, uint32_t width, uint32_t height,
diff --git a/include/wlr/render/meson.build b/include/wlr/render/meson.build
index 05127bb7..06ebcc37 100644
--- a/include/wlr/render/meson.build
+++ b/include/wlr/render/meson.build
@@ -1,9 +1,10 @@
install_headers(
'dmabuf.h',
'egl.h',
+ 'drm_format_set.h',
'gles2.h',
'interface.h',
'wlr_renderer.h',
'wlr_texture.h',
- subdir: 'wlr/render'
+ subdir: 'wlr/render',
)
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
index 9c031b7f..33f96b68 100644
--- a/include/wlr/render/wlr_renderer.h
+++ b/include/wlr/render/wlr_renderer.h
@@ -20,6 +20,7 @@ enum wlr_renderer_read_pixels_flags {
};
struct wlr_renderer_impl;
+struct wlr_drm_format_set;
struct wlr_renderer {
const struct wlr_renderer_impl *impl;
@@ -87,15 +88,10 @@ bool wlr_renderer_resource_is_wl_drm_buffer(struct wlr_renderer *renderer,
void wlr_renderer_wl_drm_buffer_get_size(struct wlr_renderer *renderer,
struct wl_resource *buffer, int *width, int *height);
/**
- * Get the available dmabuf formats
+ * Get the available DMA-BUF formats.
*/
-int wlr_renderer_get_dmabuf_formats(struct wlr_renderer *renderer,
- int **formats);
-/**
- * Get the available dmabuf modifiers for a given format
- */
-int wlr_renderer_get_dmabuf_modifiers(struct wlr_renderer *renderer, int format,
- uint64_t **modifiers);
+const struct wlr_drm_format_set *wlr_renderer_get_dmabuf_formats(
+ struct wlr_renderer *renderer);
/**
* Reads out of pixels of the currently bound surface into data. `stride` is in
* bytes.