aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/backend/drm/renderer.h1
-rw-r--r--include/render/gles2.h26
-rw-r--r--include/rootston/desktop.h1
-rw-r--r--include/wlr/backend/session.h6
-rw-r--r--include/wlr/interfaces/wlr_output.h2
-rw-r--r--include/wlr/render/dmabuf.h7
-rw-r--r--include/wlr/render/egl.h9
-rw-r--r--include/wlr/render/interface.h2
-rw-r--r--include/wlr/render/wlr_texture.h3
-rw-r--r--include/wlr/types/wlr_buffer.h63
-rw-r--r--include/wlr/types/wlr_export_dmabuf_v1.h37
-rw-r--r--include/wlr/types/wlr_output.h11
-rw-r--r--include/wlr/types/wlr_surface.h23
13 files changed, 173 insertions, 18 deletions
diff --git a/include/backend/drm/renderer.h b/include/backend/drm/renderer.h
index 510abe43..575758de 100644
--- a/include/backend/drm/renderer.h
+++ b/include/backend/drm/renderer.h
@@ -52,5 +52,6 @@ struct gbm_bo *get_drm_surface_front(struct wlr_drm_surface *surf);
void post_drm_surface(struct wlr_drm_surface *surf);
struct gbm_bo *copy_drm_surface_mgpu(struct wlr_drm_surface *dest,
struct gbm_bo *src);
+bool export_drm_bo(struct gbm_bo *bo, struct wlr_dmabuf_attributes *attribs);
#endif
diff --git a/include/render/gles2.h b/include/render/gles2.h
index 99beff29..67d4e9f5 100644
--- a/include/render/gles2.h
+++ b/include/render/gles2.h
@@ -25,6 +25,14 @@ struct wlr_gles2_pixel_format {
bool has_alpha;
};
+struct wlr_gles2_tex_shader {
+ GLuint program;
+ GLint proj;
+ GLint invert_y;
+ GLint tex;
+ GLint alpha;
+};
+
struct wlr_gles2_renderer {
struct wlr_renderer wlr_renderer;
@@ -32,11 +40,19 @@ struct wlr_gles2_renderer {
const char *exts_str;
struct {
- GLuint quad;
- GLuint ellipse;
- GLuint tex_rgba;
- GLuint tex_rgbx;
- GLuint tex_ext;
+ struct {
+ GLuint program;
+ GLint proj;
+ GLint color;
+ } quad;
+ struct {
+ GLuint program;
+ GLint proj;
+ GLint color;
+ } ellipse;
+ struct wlr_gles2_tex_shader tex_rgba;
+ struct wlr_gles2_tex_shader tex_rgbx;
+ struct wlr_gles2_tex_shader tex_ext;
} shaders;
uint32_t viewport_width, viewport_height;
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h
index bb7d2084..dfe070ca 100644
--- a/include/rootston/desktop.h
+++ b/include/rootston/desktop.h
@@ -45,6 +45,7 @@ struct roots_desktop {
struct wlr_xdg_shell *xdg_shell;
struct wlr_gamma_control_manager *gamma_control_manager;
struct wlr_screenshooter *screenshooter;
+ struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1;
struct wlr_server_decoration_manager *server_decoration_manager;
struct wlr_primary_selection_device_manager *primary_selection_device_manager;
struct wlr_idle *idle;
diff --git a/include/wlr/backend/session.h b/include/wlr/backend/session.h
index 4d04b363..1cf41939 100644
--- a/include/wlr/backend/session.h
+++ b/include/wlr/backend/session.h
@@ -25,8 +25,12 @@ struct wlr_session {
struct wl_signal session_signal;
bool active;
+ /*
+ * 0 if virtual terminals are not supported
+ * i.e. seat != "seat0"
+ */
unsigned vtnr;
- char seat[8];
+ char seat[256];
struct udev *udev;
struct udev_monitor *mon;
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index 7ecc7551..8f87408a 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -23,6 +23,8 @@ struct wlr_output_impl {
void (*set_gamma)(struct wlr_output *output,
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
uint32_t (*get_gamma_size)(struct wlr_output *output);
+ bool (*export_dmabuf)(struct wlr_output *output,
+ struct wlr_dmabuf_attributes *attribs);
};
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
diff --git a/include/wlr/render/dmabuf.h b/include/wlr/render/dmabuf.h
index 2e13fe75..78f8c2eb 100644
--- a/include/wlr/render/dmabuf.h
+++ b/include/wlr/render/dmabuf.h
@@ -1,6 +1,8 @@
#ifndef WLR_RENDER_DMABUF_H
#define WLR_RENDER_DMABUF_H
+#include <stdint.h>
+
// So we don't have to pull in linux specific drm headers
#ifndef DRM_FORMAT_MOD_INVALID
#define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
@@ -26,4 +28,9 @@ struct wlr_dmabuf_attributes {
int fd[WLR_DMABUF_MAX_PLANES];
};
+/**
+ * Closes all file descriptors in the DMA-BUF attributes.
+ */
+void wlr_dmabuf_attributes_finish(struct wlr_dmabuf_attributes *attribs);
+
#endif
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h
index 0f591d60..6b887f4f 100644
--- a/include/wlr/render/egl.h
+++ b/include/wlr/render/egl.h
@@ -18,9 +18,10 @@ struct wlr_egl {
struct {
bool bind_wayland_display_wl;
bool buffer_age_ext;
- bool image_dmabuf_import_modifiers_ext;
- bool image_dmabuf_import_ext;
bool image_base_khr;
+ bool image_dma_buf_export_mesa;
+ bool image_dmabuf_import_ext;
+ bool image_dmabuf_import_modifiers_ext;
bool swap_buffers_with_damage_ext;
bool swap_buffers_with_damage_khr;
} exts;
@@ -80,6 +81,10 @@ int wlr_egl_get_dmabuf_formats(struct wlr_egl *egl, int **formats);
int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl, int format,
uint64_t **modifiers);
+bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image,
+ int32_t width, int32_t height, uint32_t flags,
+ struct wlr_dmabuf_attributes *attribs);
+
/**
* Destroys an EGL image created with the given wlr_egl.
*/
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index 80788858..fb427c89 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -60,6 +60,8 @@ struct wlr_texture_impl {
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width,
uint32_t height, uint32_t src_x, uint32_t src_y, uint32_t dst_x,
uint32_t dst_y, const void *data);
+ bool (*to_dmabuf)(struct wlr_texture *texture,
+ struct wlr_dmabuf_attributes *attribs);
void (*destroy)(struct wlr_texture *texture);
};
diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h
index c1633820..785f4fc6 100644
--- a/include/wlr/render/wlr_texture.h
+++ b/include/wlr/render/wlr_texture.h
@@ -48,6 +48,9 @@ bool wlr_texture_write_pixels(struct wlr_texture *texture,
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y,
const void *data);
+bool wlr_texture_to_dmabuf(struct wlr_texture *texture,
+ struct wlr_dmabuf_attributes *attribs);
+
/**
* Destroys this wlr_texture.
*/
diff --git a/include/wlr/types/wlr_buffer.h b/include/wlr/types/wlr_buffer.h
new file mode 100644
index 00000000..eabc8b51
--- /dev/null
+++ b/include/wlr/types/wlr_buffer.h
@@ -0,0 +1,63 @@
+#ifndef WLR_TYPES_WLR_BUFFER_H
+#define WLR_TYPES_WLR_BUFFER_H
+
+#include <pixman.h>
+#include <wayland-server.h>
+
+/**
+ * A client buffer.
+ */
+struct wlr_buffer {
+ /**
+ * The buffer resource, if any. Will be NULL if the client destroys it.
+ */
+ struct wl_resource *resource;
+ /**
+ * The buffer's texture, if any. A buffer will not have a texture if the
+ * client destroys the buffer before it has been released.
+ */
+ struct wlr_texture *texture;
+ bool released;
+ size_t n_refs;
+
+ struct wl_listener resource_destroy;
+};
+
+struct wlr_renderer;
+
+/**
+ * Check if a resource is a wl_buffer resource.
+ */
+bool wlr_resource_is_buffer(struct wl_resource *resource);
+/**
+ * Get the size of a wl_buffer resource.
+ */
+bool wlr_buffer_get_resource_size(struct wl_resource *resource,
+ struct wlr_renderer *renderer, int *width, int *height);
+
+/**
+ * Upload a buffer to the GPU and reference it.
+ */
+struct wlr_buffer *wlr_buffer_create(struct wlr_renderer *renderer,
+ struct wl_resource *resource);
+/**
+ * Reference the buffer.
+ */
+struct wlr_buffer *wlr_buffer_ref(struct wlr_buffer *buffer);
+/**
+ * Unreference the buffer. After this call, `buffer` may not be accessed
+ * anymore.
+ */
+void wlr_buffer_unref(struct wlr_buffer *buffer);
+/**
+ * Try to update the buffer's content. On success, returns the updated buffer
+ * and destroys the provided `buffer`. On error, `buffer` is intact and NULL is
+ * returned.
+ *
+ * Fails if there's more than one reference to the buffer or if the texture
+ * isn't mutable.
+ */
+struct wlr_buffer *wlr_buffer_apply_damage(struct wlr_buffer *buffer,
+ struct wl_resource *resource, pixman_region32_t *damage);
+
+#endif
diff --git a/include/wlr/types/wlr_export_dmabuf_v1.h b/include/wlr/types/wlr_export_dmabuf_v1.h
new file mode 100644
index 00000000..a094b3de
--- /dev/null
+++ b/include/wlr/types/wlr_export_dmabuf_v1.h
@@ -0,0 +1,37 @@
+#ifndef WLR_TYPES_WLR_EXPORT_DMABUF_V1_H
+#define WLR_TYPES_WLR_EXPORT_DMABUF_V1_H
+
+#include <wayland-server.h>
+#include <wlr/render/dmabuf.h>
+
+struct wlr_export_dmabuf_manager_v1;
+
+struct wlr_export_dmabuf_frame_v1 {
+ struct wl_resource *resource;
+ struct wlr_export_dmabuf_manager_v1 *manager;
+ struct wl_list link;
+
+ struct wlr_dmabuf_attributes attribs;
+ struct wlr_output *output;
+
+ struct wl_listener output_swap_buffers;
+};
+
+struct wlr_export_dmabuf_manager_v1 {
+ struct wl_global *global;
+ struct wl_list resources;
+ struct wl_list frames;
+
+ struct wl_listener display_destroy;
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+};
+
+struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(
+ struct wl_display *display);
+void wlr_export_dmabuf_manager_v1_destroy(
+ struct wlr_export_dmabuf_manager_v1 *manager);
+
+#endif
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index cef3fc5d..158d174e 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -6,6 +6,7 @@
#include <time.h>
#include <wayland-server.h>
#include <wayland-util.h>
+#include <wlr/types/wlr_linux_dmabuf.h>
struct wlr_output_mode {
uint32_t flags; // enum wl_output_mode
@@ -81,7 +82,7 @@ struct wlr_output {
struct {
struct wl_signal frame;
struct wl_signal needs_swap;
- struct wl_signal swap_buffers;
+ struct wl_signal swap_buffers; // wlr_output_event_swap_buffers
struct wl_signal enable;
struct wl_signal mode;
struct wl_signal scale;
@@ -107,6 +108,12 @@ struct wlr_output {
void *data;
};
+struct wlr_output_event_swap_buffers {
+ struct wlr_output *output;
+ struct timespec *when;
+ pixman_region32_t *damage;
+};
+
struct wlr_surface;
void wlr_output_enable(struct wlr_output *output, bool enable);
@@ -162,6 +169,8 @@ void wlr_output_schedule_frame(struct wlr_output *output);
void wlr_output_set_gamma(struct wlr_output *output,
uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b);
uint32_t wlr_output_get_gamma_size(struct wlr_output *output);
+bool wlr_output_export_dmabuf(struct wlr_output *output,
+ struct wlr_dmabuf_attributes *attribs);
void wlr_output_set_fullscreen_surface(struct wlr_output *output,
struct wlr_surface *surface);
struct wlr_output *wlr_output_from_resource(struct wl_resource *resource);
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 526e4e2c..46588f0a 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -8,11 +8,6 @@
#include <wayland-server.h>
#include <wlr/types/wlr_output.h>
-struct wlr_frame_callback {
- struct wl_resource *resource;
- struct wl_list link;
-};
-
#define WLR_SURFACE_INVALID_BUFFER 1
#define WLR_SURFACE_INVALID_SURFACE_DAMAGE 2
#define WLR_SURFACE_INVALID_BUFFER_DAMAGE 4
@@ -69,13 +64,16 @@ struct wlr_subsurface {
struct wlr_surface {
struct wl_resource *resource;
struct wlr_renderer *renderer;
- struct wlr_texture *texture;
+ /**
+ * The surface's buffer, if any. A surface has an attached buffer when it
+ * commits with a non-null buffer in its pending state. A surface will not
+ * have a buffer if it has never committed one, has committed a null buffer,
+ * or something went wrong with uploading the buffer.
+ */
+ struct wlr_buffer *buffer;
struct wlr_surface_state *current, *pending;
const char *role; // the lifetime-bound role or null
- float buffer_to_surface_matrix[9];
- float surface_to_buffer_matrix[9];
-
struct {
struct wl_signal commit;
struct wl_signal new_subsurface;
@@ -125,6 +123,13 @@ int wlr_surface_set_role(struct wlr_surface *surface, const char *role,
bool wlr_surface_has_buffer(struct wlr_surface *surface);
/**
+ * Get the texture of the buffer currently attached to this surface. Returns
+ * NULL if no buffer is currently attached or if something went wrong with
+ * uploading the buffer.
+ */
+struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface);
+
+/**
* Create a new subsurface resource with the provided new ID. If `resource_list`
* is non-NULL, adds the subsurface's resource to the list.
*/