aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-03-22 20:06:53 -0400
committerTony Crisci <tony@dubstepdish.com>2018-03-22 20:06:53 -0400
commit30b8fb5572cd59c096b00a26c7a41cd674e9337b (patch)
tree2a7de55685259200422f2bf23cab909fa788db54 /include/wlr
parent8836b167bf0ff152de951f7fdabb1deae85f6e93 (diff)
parent77d3be66eaabca4309794536984c54a5e94e9eb5 (diff)
Merge branch 'master' into xdg-positioner
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/backend.h23
-rw-r--r--include/wlr/backend/drm.h7
-rw-r--r--include/wlr/backend/headless.h14
-rw-r--r--include/wlr/backend/interface.h4
-rw-r--r--include/wlr/backend/libinput.h4
-rw-r--r--include/wlr/backend/multi.h10
-rw-r--r--include/wlr/render.h149
-rw-r--r--include/wlr/render/egl.h31
-rw-r--r--include/wlr/render/gles2.h2
-rw-r--r--include/wlr/render/interface.h32
-rw-r--r--include/wlr/render/matrix.h22
-rw-r--r--include/wlr/render/wlr_renderer.h75
-rw-r--r--include/wlr/render/wlr_texture.h69
-rw-r--r--include/wlr/types/wlr_compositor.h2
-rw-r--r--include/wlr/types/wlr_linux_dmabuf.h84
-rw-r--r--include/wlr/types/wlr_matrix.h22
-rw-r--r--include/wlr/types/wlr_output.h2
-rw-r--r--include/wlr/types/wlr_surface.h17
-rw-r--r--include/wlr/types/wlr_xdg_shell.h34
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h34
20 files changed, 388 insertions, 249 deletions
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index 00dc9fdc..e3b14add 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -11,16 +11,39 @@ struct wlr_backend {
const struct wlr_backend_impl *impl;
struct {
+ /** Raised when destroyed, passed the wlr_backend reference */
struct wl_signal destroy;
+ /** Raised when new inputs are added, passed the wlr_input_device */
struct wl_signal new_input;
+ /** Raised when new outputs are added, passed the wlr_output */
struct wl_signal new_output;
} events;
};
+/**
+ * Automatically initializes the most suitable backend given the environment.
+ * Will always return a multibackend. The backend is created but not started.
+ * Returns NULL on failure.
+ */
struct wlr_backend *wlr_backend_autocreate(struct wl_display *display);
+/**
+ * Start the backend. This may signal new_input or new_output immediately, but
+ * may also wait until the display's event loop begins. Returns false on
+ * failure.
+ */
bool wlr_backend_start(struct wlr_backend *backend);
+/**
+ * Destroy the backend and clean up all of its resources. Normally called
+ * automatically when the wl_display is destroyed.
+ */
void wlr_backend_destroy(struct wlr_backend *backend);
+/**
+ * Obtains the wlr_egl reference this backend is using.
+ */
struct wlr_egl *wlr_backend_get_egl(struct wlr_backend *backend);
+/**
+ * Obtains the wlr_renderer reference this backend is using.
+ */
struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend);
uint32_t usec_to_msec(uint64_t usec);
diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h
index 90460647..0c9e5c8b 100644
--- a/include/wlr/backend/drm.h
+++ b/include/wlr/backend/drm.h
@@ -6,6 +6,13 @@
#include <wlr/backend/session.h>
#include <wlr/types/wlr_output.h>
+/**
+ * Creates a DRM backend using the specified GPU file descriptor (typically from
+ * a device node in /dev/dri).
+ *
+ * To slave this to another DRM backend, pass it as the parent (which _must_ be
+ * a DRM backend, other kinds of backends raise SIGABRT).
+ */
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session, int gpu_fd, struct wlr_backend *parent);
diff --git a/include/wlr/backend/headless.h b/include/wlr/backend/headless.h
index 8995f7cb..ee784a0d 100644
--- a/include/wlr/backend/headless.h
+++ b/include/wlr/backend/headless.h
@@ -5,9 +5,23 @@
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_output.h>
+/**
+ * Creates a headless backend. A headless backend has no outputs or inputs by
+ * default.
+ */
struct wlr_backend *wlr_headless_backend_create(struct wl_display *display);
+/**
+ * Create a new headless output backed by an in-memory EGL framebuffer. You can
+ * read pixels from this framebuffer via wlr_renderer_read_pixels but it is
+ * otherwise not displayed.
+ */
struct wlr_output *wlr_headless_add_output(struct wlr_backend *backend,
unsigned int width, unsigned int height);
+/**
+ * Creates a new input device. The caller is responsible for manually raising
+ * any event signals on the new input device if it wants to simulate input
+ * events.
+ */
struct wlr_input_device *wlr_headless_add_input_device(
struct wlr_backend *backend, enum wlr_input_device_type type);
bool wlr_backend_is_headless(struct wlr_backend *backend);
diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h
index d9212795..f03e95d9 100644
--- a/include/wlr/backend/interface.h
+++ b/include/wlr/backend/interface.h
@@ -12,6 +12,10 @@ struct wlr_backend_impl {
struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend);
};
+/**
+ * Initializes common state on a wlr_backend and sets the implementation to the
+ * provided wlr_backend_impl reference.
+ */
void wlr_backend_init(struct wlr_backend *backend,
const struct wlr_backend_impl *impl);
diff --git a/include/wlr/backend/libinput.h b/include/wlr/backend/libinput.h
index c7cfe894..92d31415 100644
--- a/include/wlr/backend/libinput.h
+++ b/include/wlr/backend/libinput.h
@@ -9,7 +9,9 @@
struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
struct wlr_session *session);
-struct libinput_device *wlr_libinput_get_device_handle(struct wlr_input_device *dev);
+/** Gets the underlying libinput_device handle for the given wlr_input_device */
+struct libinput_device *wlr_libinput_get_device_handle(
+ struct wlr_input_device *dev);
bool wlr_backend_is_libinput(struct wlr_backend *backend);
bool wlr_input_device_is_libinput(struct wlr_input_device *device);
diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h
index 2dee7403..842eed67 100644
--- a/include/wlr/backend/multi.h
+++ b/include/wlr/backend/multi.h
@@ -4,11 +4,21 @@
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+/**
+ * Creates a multi-backend. Multi-backends wrap an arbitrary number of backends
+ * and aggregate their new_output/new_input signals.
+ */
struct wlr_backend *wlr_multi_backend_create(struct wl_display *display);
+/**
+ * Adds the given backend to the multi backend. This should be done before the
+ * new backend is started.
+ */
void wlr_multi_backend_add(struct wlr_backend *multi,
struct wlr_backend *backend);
+
void wlr_multi_backend_remove(struct wlr_backend *multi,
struct wlr_backend *backend);
+
bool wlr_backend_is_multi(struct wlr_backend *backend);
struct wlr_session *wlr_multi_get_session(struct wlr_backend *base);
bool wlr_multi_is_empty(struct wlr_backend *backend);
diff --git a/include/wlr/render.h b/include/wlr/render.h
deleted file mode 100644
index 747603da..00000000
--- a/include/wlr/render.h
+++ /dev/null
@@ -1,149 +0,0 @@
-#ifndef WLR_RENDER_H
-#define WLR_RENDER_H
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <stdint.h>
-#include <wayland-server-protocol.h>
-#include <wlr/types/wlr_box.h>
-#include <wlr/types/wlr_output.h>
-
-struct wlr_texture;
-struct wlr_renderer;
-
-void wlr_renderer_begin(struct wlr_renderer *r, struct wlr_output *output);
-void wlr_renderer_end(struct wlr_renderer *r);
-void wlr_renderer_clear(struct wlr_renderer *r, const float (*color)[4]);
-/**
- * Defines a scissor box. Only pixels that lie within the scissor box can be
- * modified by drawing functions. Providing a NULL `box` disables the scissor
- * box.
- */
-void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box);
-/**
- * Requests a texture handle from this renderer.
- */
-struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r);
-/**
- * Renders the requested texture using the provided matrix. A typical texture
- * rendering goes like so:
- *
- * struct wlr_renderer *renderer;
- * struct wlr_texture *texture;
- * float projection[16];
- * float matrix[16];
- * wlr_texture_get_matrix(texture, &matrix, &projection, 123, 321);
- * wlr_render_with_matrix(renderer, texture, &matrix, 0.5f);
- *
- * This will render the texture at <123, 321> with an alpha channel of 0.5.
- */
-bool wlr_render_with_matrix(struct wlr_renderer *r,
- struct wlr_texture *texture, const float (*matrix)[16], float alpha);
-
-/**
- * Renders a solid quad in the specified color.
- */
-void wlr_render_colored_quad(struct wlr_renderer *r,
- const float (*color)[4], const float (*matrix)[16]);
-/**
- * Renders a solid ellipse in the specified color.
- */
-void wlr_render_colored_ellipse(struct wlr_renderer *r,
- const float (*color)[4], const float (*matrix)[16]);
-/**
- * Returns a list of pixel formats supported by this renderer.
- */
-const enum wl_shm_format *wlr_renderer_get_formats(
- struct wlr_renderer *r, size_t *len);
-/**
- * Returns true if this wl_buffer is a DRM buffer.
- */
-bool wlr_renderer_buffer_is_drm(struct wlr_renderer *renderer,
- struct wl_resource *buffer);
-/**
- * Reads out of pixels of the currently bound surface into data. `stride` is in
- * bytes.
- */
-bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format 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, void *data);
-/**
- * Checks if a format is supported.
- */
-bool wlr_renderer_format_supported(struct wlr_renderer *r,
- enum wl_shm_format fmt);
-/**
- * Destroys this wlr_renderer. Textures must be destroyed separately.
- */
-void wlr_renderer_destroy(struct wlr_renderer *renderer);
-
-struct wlr_texture_impl;
-
-struct wlr_texture {
- struct wlr_texture_impl *impl;
-
- bool valid;
- uint32_t format;
- int width, height;
- struct wl_signal destroy_signal;
- struct wl_resource *resource;
-};
-
-/**
- * Copies pixels to this texture. The buffer is not accessed after this function
- * returns.
- */
-bool wlr_texture_upload_pixels(struct wlr_texture *tex,
- enum wl_shm_format format, int stride, int width, int height,
- const unsigned char *pixels);
-/**
- * Copies pixels to this texture. The buffer is not accessed after this function
- * returns. Under some circumstances, this function may re-upload the entire
- * buffer - therefore, the entire buffer must be valid.
- */
-bool wlr_texture_update_pixels(struct wlr_texture *surf,
- enum wl_shm_format format, int stride, int x, int y,
- int width, int height, const unsigned char *pixels);
-/**
- * Copies pixels from a wl_shm_buffer into this texture. The buffer is not
- * accessed after this function returns.
- */
-bool wlr_texture_upload_shm(struct wlr_texture *tex, uint32_t format,
- struct wl_shm_buffer *shm);
-
-/**
- * Attaches the contents from the given wl_drm wl_buffer resource onto the
- * texture. The wl_resource is not used after this call.
- * Will fail (return false) if the given resource is no drm buffer.
- */
-bool wlr_texture_upload_drm(struct wlr_texture *tex,
- struct wl_resource *drm_buffer);
-
-bool wlr_texture_upload_eglimage(struct wlr_texture *tex,
- EGLImageKHR image, uint32_t width, uint32_t height);
-
-/**
- * Copies a rectangle of pixels from a wl_shm_buffer onto the texture. The
- * buffer is not accessed after this function returns. Under some circumstances,
- * this function may re-upload the entire buffer - therefore, the entire buffer
- * must be valid.
- */
-bool wlr_texture_update_shm(struct wlr_texture *surf, uint32_t format,
- int x, int y, int width, int height, struct wl_shm_buffer *shm);
-/**
- * Prepares a matrix with the appropriate scale for the given texture and
- * multiplies it with the projection, producing a matrix that the shader can
- * muptlipy vertex coordinates with to get final screen coordinates.
- *
- * The projection matrix is assumed to be an orthographic projection of [0,
- * width) and [0, height], and the x and y coordinates provided are used as
- * such.
- */
-void wlr_texture_get_matrix(struct wlr_texture *texture,
- float (*matrix)[16], const float (*projection)[16], int x, int y);
-/**
- * Destroys this wlr_texture.
- */
-void wlr_texture_destroy(struct wlr_texture *texture);
-
-#endif
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h
index 97a28016..aa429e8e 100644
--- a/include/wlr/render/egl.h
+++ b/include/wlr/render/egl.h
@@ -6,6 +6,7 @@
#include <pixman.h>
#include <stdbool.h>
#include <wayland-server.h>
+#include <wlr/types/wlr_linux_dmabuf.h>
struct wlr_egl {
EGLDisplay display;
@@ -18,6 +19,8 @@ struct wlr_egl {
struct {
bool buffer_age;
bool swap_buffers_with_damage;
+ bool dmabuf_import;
+ bool dmabuf_import_modifiers;
} egl_exts;
struct wl_display *wl_display;
@@ -62,14 +65,34 @@ EGLImageKHR wlr_egl_create_image(struct wlr_egl *egl,
EGLenum target, EGLClientBuffer buffer, const EGLint *attribs);
/**
- * Destroys an egl image created with the given wlr_egl.
+ * Creates an egl image from the given dmabuf attributes. Check usability
+ * of the dmabuf with wlr_egl_check_import_dmabuf once first.
*/
-bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image);
+EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
+ struct wlr_dmabuf_buffer_attribs *attributes);
/**
- * Returns a string for the last error ocurred with egl.
+ * Try to import the given dmabuf. On success return true false otherwise.
+ * If this succeeds the dmabuf can be used for rendering on a texture
*/
-const char *egl_error(void);
+bool wlr_egl_check_import_dmabuf(struct wlr_egl *egl,
+ struct wlr_dmabuf_buffer *dmabuf);
+
+/**
+ * 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);
+
+/**
+ * Destroys an egl image created with the given wlr_egl.
+ */
+bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image);
bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface,
int *buffer_age);
diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h
index a924a065..b3b43ab2 100644
--- a/include/wlr/render/gles2.h
+++ b/include/wlr/render/gles2.h
@@ -2,7 +2,7 @@
#define WLR_RENDER_GLES2_H
#include <wlr/backend.h>
-#include <wlr/render.h>
+#include <wlr/render/wlr_renderer.h>
struct wlr_egl;
struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend);
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index eda5af1c..7f25c0ff 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -5,28 +5,32 @@
#include <EGL/eglext.h>
#include <stdbool.h>
#include <wayland-server-protocol.h>
-#include <wlr/render.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/render/wlr_texture.h>
#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_linux_dmabuf.h>
#include <wlr/types/wlr_output.h>
struct wlr_renderer_impl;
struct wlr_renderer {
- struct wlr_renderer_impl *impl;
+ const struct wlr_renderer_impl *impl;
};
struct wlr_renderer_impl {
- void (*begin)(struct wlr_renderer *renderer, struct wlr_output *output);
+ void (*begin)(struct wlr_renderer *renderer, uint32_t width,
+ uint32_t height);
void (*end)(struct wlr_renderer *renderer);
- void (*clear)(struct wlr_renderer *renderer, const float (*color)[4]);
+ void (*clear)(struct wlr_renderer *renderer, const float color[static 4]);
void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box);
struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer);
- bool (*render_with_matrix)(struct wlr_renderer *renderer,
- struct wlr_texture *texture, const float (*matrix)[16], float alpha);
+ bool (*render_texture_with_matrix)(struct wlr_renderer *renderer,
+ struct wlr_texture *texture, const float matrix[static 9],
+ float alpha);
void (*render_quad)(struct wlr_renderer *renderer,
- const float (*color)[4], const float (*matrix)[16]);
+ const float color[static 4], const float matrix[static 9]);
void (*render_ellipse)(struct wlr_renderer *renderer,
- const float (*color)[4], const float (*matrix)[16]);
+ const float color[static 4], const float matrix[static 9]);
const enum wl_shm_format *(*formats)(
struct wlr_renderer *renderer, size_t *len);
bool (*buffer_is_drm)(struct wlr_renderer *renderer,
@@ -41,7 +45,7 @@ struct wlr_renderer_impl {
};
void wlr_renderer_init(struct wlr_renderer *renderer,
- struct wlr_renderer_impl *impl);
+ const struct wlr_renderer_impl *impl);
struct wlr_texture_impl {
bool (*upload_pixels)(struct wlr_texture *texture,
@@ -58,18 +62,16 @@ struct wlr_texture_impl {
struct wl_resource *drm_buf);
bool (*upload_eglimage)(struct wlr_texture *texture, EGLImageKHR image,
uint32_t width, uint32_t height);
- void (*get_matrix)(struct wlr_texture *state,
- float (*matrix)[16], const float (*projection)[16], int x, int y);
+ bool (*upload_dmabuf)(struct wlr_texture *texture,
+ struct wl_resource *dmabuf_resource);
void (*get_buffer_size)(struct wlr_texture *texture,
struct wl_resource *resource, int *width, int *height);
- void (*bind)(struct wlr_texture *texture);
void (*destroy)(struct wlr_texture *texture);
};
void wlr_texture_init(struct wlr_texture *texture,
- struct wlr_texture_impl *impl);
-void wlr_texture_bind(struct wlr_texture *texture);
+ const struct wlr_texture_impl *impl);
void wlr_texture_get_buffer_size(struct wlr_texture *texture,
- struct wl_resource *resource, int *width, int *height);
+ struct wl_resource *resource, int *width, int *height);
#endif
diff --git a/include/wlr/render/matrix.h b/include/wlr/render/matrix.h
deleted file mode 100644
index a333bf0f..00000000
--- a/include/wlr/render/matrix.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef WLR_RENDER_MATRIX_H
-#define WLR_RENDER_MATRIX_H
-
-#include <stdint.h>
-#include <wlr/types/wlr_box.h>
-
-void wlr_matrix_identity(float (*output)[16]);
-void wlr_matrix_translate(float (*output)[16], float x, float y, float z);
-void wlr_matrix_scale(float (*output)[16], float x, float y, float z);
-void wlr_matrix_rotate(float (*output)[16], float radians);
-void wlr_matrix_mul(const float (*x)[16], const float (*y)[16], float (*product)[16]);
-
-enum wl_output_transform;
-void wlr_matrix_transform(float mat[static 16],
- enum wl_output_transform transform);
-void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
- enum wl_output_transform transform);
-void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
- enum wl_output_transform transform, float rotation, float
- (*projection)[16]);
-
-#endif
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
new file mode 100644
index 00000000..6f0d2ecc
--- /dev/null
+++ b/include/wlr/render/wlr_renderer.h
@@ -0,0 +1,75 @@
+#ifndef WLR_RENDER_WLR_RENDERER_H
+#define WLR_RENDER_WLR_RENDERER_H
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <stdint.h>
+#include <wayland-server-protocol.h>
+#include <wlr/render/wlr_texture.h>
+#include <wlr/types/wlr_box.h>
+
+struct wlr_output;
+
+struct wlr_renderer;
+
+void wlr_renderer_begin(struct wlr_renderer *r, int width, int height);
+void wlr_renderer_end(struct wlr_renderer *r);
+void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
+/**
+ * Defines a scissor box. Only pixels that lie within the scissor box can be
+ * modified by drawing functions. Providing a NULL `box` disables the scissor
+ * box.
+ */
+void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box);
+/**
+ * Requests a texture handle from this renderer.
+ */
+struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r);
+/**
+ * Renders the requested texture.
+ */
+bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
+ const float projection[static 9], int x, int y, float alpha);
+/**
+ * Renders the requested texture using the provided matrix.
+ */
+bool wlr_render_texture_with_matrix(struct wlr_renderer *r,
+ struct wlr_texture *texture, const float matrix[static 9], float alpha);
+/**
+ * Renders a solid quad in the specified color.
+ */
+void wlr_render_colored_quad(struct wlr_renderer *r,
+ const float color[static 4], const float matrix[static 9]);
+/**
+ * Renders a solid ellipse in the specified color.
+ */
+void wlr_render_colored_ellipse(struct wlr_renderer *r,
+ const float color[static 4], const float matrix[static 9]);
+/**
+ * Returns a list of pixel formats supported by this renderer.
+ */
+const enum wl_shm_format *wlr_renderer_get_formats(struct wlr_renderer *r,
+ size_t *len);
+/**
+ * Returns true if this wl_buffer is a DRM buffer.
+ */
+bool wlr_renderer_buffer_is_drm(struct wlr_renderer *renderer,
+ struct wl_resource *buffer);
+/**
+ * Reads out of pixels of the currently bound surface into data. `stride` is in
+ * bytes.
+ */
+bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format 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, void *data);
+/**
+ * Checks if a format is supported.
+ */
+bool wlr_renderer_format_supported(struct wlr_renderer *r,
+ enum wl_shm_format fmt);
+/**
+ * Destroys this wlr_renderer. Textures must be destroyed separately.
+ */
+void wlr_renderer_destroy(struct wlr_renderer *renderer);
+
+#endif
diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h
new file mode 100644
index 00000000..095097e6
--- /dev/null
+++ b/include/wlr/render/wlr_texture.h
@@ -0,0 +1,69 @@
+#ifndef WLR_RENDER_WLR_TEXTURE_H
+#define WLR_RENDER_WLR_TEXTURE_H
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <stdint.h>
+#include <wayland-server-protocol.h>
+
+struct wlr_texture_impl;
+
+struct wlr_texture {
+ const struct wlr_texture_impl *impl;
+
+ bool valid;
+ uint32_t format;
+ int width, height;
+ bool inverted_y;
+ struct wl_signal destroy_signal;
+ struct wl_resource *resource;
+};
+
+/**
+ * Copies pixels to this texture. The buffer is not accessed after this function
+ * returns.
+ */
+bool wlr_texture_upload_pixels(struct wlr_texture *tex,
+ enum wl_shm_format format, int stride, int width, int height,
+ const unsigned char *pixels);
+/**
+ * Copies pixels to this texture. The buffer is not accessed after this function
+ * returns. Under some circumstances, this function may re-upload the entire
+ * buffer - therefore, the entire buffer must be valid.
+ */
+bool wlr_texture_update_pixels(struct wlr_texture *surf,
+ enum wl_shm_format format, int stride, int x, int y,
+ int width, int height, const unsigned char *pixels);
+/**
+ * Copies pixels from a wl_shm_buffer into this texture. The buffer is not
+ * accessed after this function returns.
+ */
+bool wlr_texture_upload_shm(struct wlr_texture *tex, uint32_t format,
+ struct wl_shm_buffer *shm);
+/**
+ * Attaches the contents from the given wl_drm wl_buffer resource onto the
+ * texture. The wl_resource is not used after this call.
+ * Will fail (return false) if the given resource is no drm buffer.
+ */
+bool wlr_texture_upload_drm(struct wlr_texture *tex,
+ struct wl_resource *drm_buffer);
+
+bool wlr_texture_upload_eglimage(struct wlr_texture *tex,
+ EGLImageKHR image, uint32_t width, uint32_t height);
+
+bool wlr_texture_upload_dmabuf(struct wlr_texture *tex,
+ struct wl_resource *dmabuf_resource);
+/**
+ * Copies a rectangle of pixels from a wl_shm_buffer onto the texture. The
+ * buffer is not accessed after this function returns. Under some circumstances,
+ * this function may re-upload the entire buffer - therefore, the entire buffer
+ * must be valid.
+ */
+bool wlr_texture_update_shm(struct wlr_texture *surf, uint32_t format,
+ int x, int y, int width, int height, struct wl_shm_buffer *shm);
+/**
+ * Destroys this wlr_texture.
+ */
+void wlr_texture_destroy(struct wlr_texture *texture);
+
+#endif
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h
index 5919b934..11bfac71 100644
--- a/include/wlr/types/wlr_compositor.h
+++ b/include/wlr/types/wlr_compositor.h
@@ -2,7 +2,7 @@
#define WLR_TYPES_WLR_COMPOSITOR_H
#include <wayland-server.h>
-#include <wlr/render.h>
+#include <wlr/render/wlr_renderer.h>
struct wlr_compositor {
struct wl_global *wl_global;
diff --git a/include/wlr/types/wlr_linux_dmabuf.h b/include/wlr/types/wlr_linux_dmabuf.h
new file mode 100644
index 00000000..9d71e598
--- /dev/null
+++ b/include/wlr/types/wlr_linux_dmabuf.h
@@ -0,0 +1,84 @@
+#ifndef WLR_TYPES_WLR_LINUX_DMABUF_H
+#define WLR_TYPES_WLR_LINUX_DMABUF_H
+
+#define WLR_LINUX_DMABUF_MAX_PLANES 4
+
+#include <stdint.h>
+#include <wayland-server-protocol.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)
+#endif
+
+struct wlr_dmabuf_buffer_attribs {
+ /* set via params_add */
+ int n_planes;
+ uint32_t offset[WLR_LINUX_DMABUF_MAX_PLANES];
+ uint32_t stride[WLR_LINUX_DMABUF_MAX_PLANES];
+ uint64_t modifier[WLR_LINUX_DMABUF_MAX_PLANES];
+ int fd[WLR_LINUX_DMABUF_MAX_PLANES];
+ /* set via params_create */
+ int32_t width;
+ int32_t height;
+ uint32_t format;
+ uint32_t flags; /* enum zlinux_buffer_params_flags */
+};
+
+struct wlr_dmabuf_buffer {
+ struct wlr_egl *egl;
+ struct wl_resource *buffer_resource;
+ struct wl_resource *params_resource;
+ struct wlr_dmabuf_buffer_attribs attributes;
+};
+
+/**
+ * Returns true if the given resource was created via the linux-dmabuf
+ * buffer protocol, false otherwise
+ */
+bool wlr_dmabuf_resource_is_buffer(struct wl_resource *buffer_resource);
+
+/**
+ * Returns the wlr_dmabuf_buffer if the given resource was created
+ * via the linux-dmabuf buffer protocol
+ */
+struct wlr_dmabuf_buffer *wlr_dmabuf_buffer_from_buffer_resource(
+ struct wl_resource *buffer_resource);
+
+/**
+ * Returns the wlr_dmabuf_buffer if the given resource was created
+ * via the linux-dmabuf params protocol
+ */
+struct wlr_dmabuf_buffer *wlr_dmabuf_buffer_from_params_resource(
+ struct wl_resource *params_resource);
+
+/**
+ * Returns true if the given dmabuf has y-axis inverted, false otherwise
+ */
+bool wlr_dmabuf_buffer_has_inverted_y(struct wlr_dmabuf_buffer *dmabuf);
+
+/* the protocol interface */
+struct wlr_linux_dmabuf {
+ struct wl_global *wl_global;
+ struct wl_listener display_destroy;
+ struct wlr_egl *egl;
+};
+
+/**
+ * Create linux-dmabuf interface
+ */
+struct wlr_linux_dmabuf *wlr_linux_dmabuf_create(struct wl_display *display,
+ struct wlr_egl *egl);
+/**
+ * Destroy the linux-dmabuf interface
+ */
+void wlr_linux_dmabuf_destroy(struct wlr_linux_dmabuf *linux_dmabuf);
+
+/**
+ * Returns the wlr_linux_dmabuf if the given resource was created
+ * via the linux_dmabuf protocol
+ */
+struct wlr_linux_dmabuf *wlr_linux_dmabuf_from_resource(
+ struct wl_resource *resource);
+
+#endif
diff --git a/include/wlr/types/wlr_matrix.h b/include/wlr/types/wlr_matrix.h
new file mode 100644
index 00000000..02111db8
--- /dev/null
+++ b/include/wlr/types/wlr_matrix.h
@@ -0,0 +1,22 @@
+#ifndef WLR_TYPES_WLR_MATRIX_H
+#define WLR_TYPES_WLR_MATRIX_H
+
+#include <wayland-server.h>
+#include <wlr/types/wlr_box.h>
+
+void wlr_matrix_identity(float mat[static 9]);
+void wlr_matrix_multiply(float mat[static 9], const float a[static 9],
+ const float b[static 9]);
+void wlr_matrix_transpose(float mat[static 9], const float a[static 9]);
+void wlr_matrix_translate(float mat[static 9], float x, float y);
+void wlr_matrix_scale(float mat[static 9], float x, float y);
+void wlr_matrix_rotate(float mat[static 9], float rad);
+void wlr_matrix_transform(float mat[static 9],
+ enum wl_output_transform transform);
+void wlr_matrix_projection(float mat[static 9], int width, int height,
+ enum wl_output_transform transform);
+void wlr_matrix_project_box(float mat[static 9], const struct wlr_box *box,
+ enum wl_output_transform transform, float rotation,
+ const float projection[static 9]);
+
+#endif
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index a8138a80..b838a737 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -76,7 +76,7 @@ struct wlr_output {
// damage for cursors and fullscreen surface, in output-local coordinates
pixman_region32_t damage;
bool frame_pending;
- float transform_matrix[16];
+ float transform_matrix[9];
struct {
struct wl_signal frame;
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 203345bd..5c5b012f 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -70,8 +70,8 @@ struct wlr_surface {
struct wlr_surface_state *current, *pending;
const char *role; // the lifetime-bound role or null
- float buffer_to_surface_matrix[16];
- float surface_to_buffer_matrix[16];
+ float buffer_to_surface_matrix[9];
+ float surface_to_buffer_matrix[9];
struct {
struct wl_signal commit;
@@ -99,19 +99,6 @@ struct wlr_surface {
struct wlr_renderer;
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
struct wlr_renderer *renderer);
-/**
- * Gets a matrix you can pass into wlr_render_with_matrix to display this
- * surface. `matrix` is the output matrix, `projection` is the wlr_output
- * projection matrix, and `transform` is any additional transformations you want
- * to perform on the surface (or NULL/the identity matrix if you don't).
- * `transform` is used before the surface is scaled, so its geometry extends
- * from 0 to 1 in both dimensions.
- */
-void wlr_surface_get_matrix(struct wlr_surface *surface,
- float (*matrix)[16],
- const float (*projection)[16],
- const float (*transform)[16]);
-
/**
* Set the lifetime role for this surface. Returns 0 on success or -1 if the
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h
index 8422863c..a5fa093b 100644
--- a/include/wlr/types/wlr_xdg_shell.h
+++ b/include/wlr/types/wlr_xdg_shell.h
@@ -53,6 +53,7 @@ struct wlr_xdg_popup_grab {
struct wlr_seat *seat;
struct wl_list popups;
struct wl_list link; // wlr_xdg_shell::popup_grabs
+ struct wl_listener seat_destroy;
};
enum wlr_xdg_surface_role {
@@ -62,19 +63,10 @@ enum wlr_xdg_surface_role {
};
struct wlr_xdg_toplevel_state {
- bool maximized;
- bool fullscreen;
- bool resizing;
- bool activated;
-
- uint32_t width;
- uint32_t height;
-
- uint32_t max_width;
- uint32_t max_height;
-
- uint32_t min_width;
- uint32_t min_height;
+ bool maximized, fullscreen, resizing, activated;
+ uint32_t width, height;
+ uint32_t max_width, max_height;
+ uint32_t min_width, min_height;
};
struct wlr_xdg_toplevel {
@@ -90,7 +82,8 @@ struct wlr_xdg_toplevel {
struct wlr_xdg_surface_configure {
struct wl_list link; // wlr_xdg_surface::configure_list
uint32_t serial;
- struct wlr_xdg_toplevel_state state;
+
+ struct wlr_xdg_toplevel_state *toplevel_state;
};
struct wlr_xdg_surface {
@@ -101,14 +94,13 @@ struct wlr_xdg_surface {
enum wlr_xdg_surface_role role;
union {
- struct wlr_xdg_toplevel *toplevel_state;
- struct wlr_xdg_popup *popup_state;
+ struct wlr_xdg_toplevel *toplevel;
+ struct wlr_xdg_popup *popup;
};
struct wl_list popups; // wlr_xdg_popup::link
- bool configured;
- bool added;
+ bool added, configured, mapped;
uint32_t configure_serial;
struct wl_event_source *configure_idle;
uint32_t configure_next_serial;
@@ -118,8 +110,8 @@ struct wlr_xdg_surface {
char *app_id;
bool has_next_geometry;
- struct wlr_box *next_geometry;
- struct wlr_box *geometry;
+ struct wlr_box next_geometry;
+ struct wlr_box geometry;
struct wl_listener surface_destroy_listener;
@@ -127,6 +119,8 @@ struct wlr_xdg_surface {
struct wl_signal destroy;
struct wl_signal ping_timeout;
struct wl_signal new_popup;
+ struct wl_signal map;
+ struct wl_signal unmap;
struct wl_signal request_maximize;
struct wl_signal request_fullscreen;
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h
index 42eb332a..75570127 100644
--- a/include/wlr/types/wlr_xdg_shell_v6.h
+++ b/include/wlr/types/wlr_xdg_shell_v6.h
@@ -113,6 +113,7 @@ struct wlr_xdg_popup_grab_v6 {
struct wlr_seat *seat;
struct wl_list popups;
struct wl_list link; // wlr_xdg_shell_v6::popup_grabs
+ struct wl_listener seat_destroy;
};
enum wlr_xdg_surface_v6_role {
@@ -122,19 +123,10 @@ enum wlr_xdg_surface_v6_role {
};
struct wlr_xdg_toplevel_v6_state {
- bool maximized;
- bool fullscreen;
- bool resizing;
- bool activated;
-
- uint32_t width;
- uint32_t height;
-
- uint32_t max_width;
- uint32_t max_height;
-
- uint32_t min_width;
- uint32_t min_height;
+ bool maximized, fullscreen, resizing, activated;
+ uint32_t width, height;
+ uint32_t max_width, max_height;
+ uint32_t min_width, min_height;
};
struct wlr_xdg_toplevel_v6 {
@@ -150,7 +142,8 @@ struct wlr_xdg_toplevel_v6 {
struct wlr_xdg_surface_v6_configure {
struct wl_list link; // wlr_xdg_surface_v6::configure_list
uint32_t serial;
- struct wlr_xdg_toplevel_v6_state state;
+
+ struct wlr_xdg_toplevel_v6_state *toplevel_state;
};
struct wlr_xdg_surface_v6 {
@@ -161,14 +154,13 @@ struct wlr_xdg_surface_v6 {
enum wlr_xdg_surface_v6_role role;
union {
- struct wlr_xdg_toplevel_v6 *toplevel_state;
- struct wlr_xdg_popup_v6 *popup_state;
+ struct wlr_xdg_toplevel_v6 *toplevel;
+ struct wlr_xdg_popup_v6 *popup;
};
struct wl_list popups; // wlr_xdg_popup_v6::link
- bool configured;
- bool added;
+ bool added, configured, mapped;
uint32_t configure_serial;
struct wl_event_source *configure_idle;
uint32_t configure_next_serial;
@@ -178,8 +170,8 @@ struct wlr_xdg_surface_v6 {
char *app_id;
bool has_next_geometry;
- struct wlr_box *next_geometry;
- struct wlr_box *geometry;
+ struct wlr_box next_geometry;
+ struct wlr_box geometry;
struct wl_listener surface_destroy_listener;
@@ -187,6 +179,8 @@ struct wlr_xdg_surface_v6 {
struct wl_signal destroy;
struct wl_signal ping_timeout;
struct wl_signal new_popup;
+ struct wl_signal map;
+ struct wl_signal unmap;
struct wl_signal request_maximize;
struct wl_signal request_fullscreen;