buffer: extract interface to separate header

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3389
master
Simon Ser 3 years ago
parent d0718a9b32
commit 39b68ea47a

@ -0,0 +1,48 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_INTERFACES_WLR_BUFFER_H
#define WLR_INTERFACES_WLR_BUFFER_H
#include <wlr/types/wlr_buffer.h>
struct wlr_buffer_impl {
void (*destroy)(struct wlr_buffer *buffer);
bool (*get_dmabuf)(struct wlr_buffer *buffer,
struct wlr_dmabuf_attributes *attribs);
bool (*get_shm)(struct wlr_buffer *buffer,
struct wlr_shm_attributes *attribs);
bool (*begin_data_ptr_access)(struct wlr_buffer *buffer, uint32_t flags,
void **data, uint32_t *format, size_t *stride);
void (*end_data_ptr_access)(struct wlr_buffer *buffer);
};
struct wlr_buffer_resource_interface {
const char *name;
bool (*is_instance)(struct wl_resource *resource);
struct wlr_buffer *(*from_resource)(struct wl_resource *resource);
};
/**
* Initialize a buffer. This function should be called by producers. The
* initialized buffer is referenced: once the producer is done with the buffer
* they should call wlr_buffer_drop.
*/
void wlr_buffer_init(struct wlr_buffer *buffer,
const struct wlr_buffer_impl *impl, int width, int height);
/**
* Allows the registration of a wl_resource implementation.
*
* The matching function will be called for the wl_resource when creating a
* wlr_buffer from a wl_resource.
*/
void wlr_buffer_register_resource_interface(
const struct wlr_buffer_resource_interface *iface);
#endif

@ -24,17 +24,6 @@ struct wlr_shm_attributes {
off_t offset; off_t offset;
}; };
struct wlr_buffer_impl {
void (*destroy)(struct wlr_buffer *buffer);
bool (*get_dmabuf)(struct wlr_buffer *buffer,
struct wlr_dmabuf_attributes *attribs);
bool (*get_shm)(struct wlr_buffer *buffer,
struct wlr_shm_attributes *attribs);
bool (*begin_data_ptr_access)(struct wlr_buffer *buffer, uint32_t flags,
void **data, uint32_t *format, size_t *stride);
void (*end_data_ptr_access)(struct wlr_buffer *buffer);
};
/** /**
* Buffer capabilities. * Buffer capabilities.
* *
@ -72,19 +61,6 @@ struct wlr_buffer {
struct wlr_addon_set addons; struct wlr_addon_set addons;
}; };
struct wlr_buffer_resource_interface {
const char *name;
bool (*is_instance)(struct wl_resource *resource);
struct wlr_buffer *(*from_resource)(struct wl_resource *resource);
};
/**
* Initialize a buffer. This function should be called by producers. The
* initialized buffer is referenced: once the producer is done with the buffer
* they should call wlr_buffer_drop.
*/
void wlr_buffer_init(struct wlr_buffer *buffer,
const struct wlr_buffer_impl *impl, int width, int height);
/** /**
* Unreference the buffer. This function should be called by producers when * Unreference the buffer. This function should be called by producers when
* they are done with the buffer. * they are done with the buffer.
@ -121,14 +97,6 @@ bool wlr_buffer_get_dmabuf(struct wlr_buffer *buffer,
*/ */
bool wlr_buffer_get_shm(struct wlr_buffer *buffer, bool wlr_buffer_get_shm(struct wlr_buffer *buffer,
struct wlr_shm_attributes *attribs); struct wlr_shm_attributes *attribs);
/**
* Allows the registration of a wl_resource implementation.
*
* The matching function will be called for the wl_resource when creating a
* wlr_buffer from a wl_resource.
*/
void wlr_buffer_register_resource_interface(
const struct wlr_buffer_resource_interface *iface);
/** /**
* Transforms a wl_resource into a wlr_buffer and locks it. Once the caller is * Transforms a wl_resource into a wlr_buffer and locks it. Once the caller is
* done with the buffer, they must call wlr_buffer_unlock. * done with the buffer, they must call wlr_buffer_unlock.

@ -3,6 +3,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xf86drm.h> #include <xf86drm.h>

@ -9,6 +9,7 @@
#include <unistd.h> #include <unistd.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>

@ -4,6 +4,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>

@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>

@ -1,6 +1,7 @@
#include <assert.h> #include <assert.h>
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <stdlib.h> #include <stdlib.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_buffer.h> #include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_drm.h> #include <wlr/types/wlr_drm.h>

@ -4,6 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_buffer.h> #include <wlr/types/wlr_buffer.h>

@ -4,6 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>

Loading…
Cancel
Save