aboutsummaryrefslogtreecommitdiff
path: root/include/wlr/render
diff options
context:
space:
mode:
Diffstat (limited to 'include/wlr/render')
-rw-r--r--include/wlr/render/egl.h16
-rw-r--r--include/wlr/render/interface.h41
-rw-r--r--include/wlr/render/wlr_renderer.h15
-rw-r--r--include/wlr/render/wlr_texture.h63
4 files changed, 51 insertions, 84 deletions
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h
index aa429e8e..c214f127 100644
--- a/include/wlr/render/egl.h
+++ b/include/wlr/render/egl.h
@@ -47,36 +47,24 @@ void wlr_egl_finish(struct wlr_egl *egl);
bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display);
/**
- * Refer to the eglQueryWaylandBufferWL extension function.
- */
-bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf,
- EGLint attrib, EGLint *value);
-
-/**
* Returns a surface for the given native window
* The window must match the remote display the wlr_egl was created with.
*/
EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window);
/**
- * Creates an egl image from the given client buffer and attributes.
- */
-EGLImageKHR wlr_egl_create_image(struct wlr_egl *egl,
- EGLenum target, EGLClientBuffer buffer, const EGLint *attribs);
-
-/**
* Creates an egl image from the given dmabuf attributes. Check usability
* of the dmabuf with wlr_egl_check_import_dmabuf once first.
*/
EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
- struct wlr_dmabuf_buffer_attribs *attributes);
+ struct wlr_dmabuf_buffer_attribs *attributes);
/**
* 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
*/
bool wlr_egl_check_import_dmabuf(struct wlr_egl *egl,
- struct wlr_dmabuf_buffer *dmabuf);
+ struct wlr_dmabuf_buffer *dmabuf);
/**
* Get the available dmabuf formats
diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h
index d4cd35f8..597e4b39 100644
--- a/include/wlr/render/interface.h
+++ b/include/wlr/render/interface.h
@@ -23,7 +23,6 @@ struct wlr_renderer_impl {
void (*end)(struct wlr_renderer *renderer);
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_texture_with_matrix)(struct wlr_renderer *renderer,
struct wlr_texture *texture, const float matrix[static 9],
float alpha);
@@ -33,45 +32,39 @@ struct wlr_renderer_impl {
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,
- struct wl_resource *buffer);
+ bool (*resource_is_wl_drm_buffer)(struct wlr_renderer *renderer,
+ struct wl_resource *resource);
+ void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer,
+ struct wl_resource *buffer, int *width, int *height);
bool (*read_pixels)(struct wlr_renderer *renderer, 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);
bool (*format_supported)(struct wlr_renderer *renderer,
enum wl_shm_format fmt);
+ struct wlr_texture *(*texture_from_pixels)(struct wlr_renderer *renderer,
+ enum wl_shm_format fmt, uint32_t stride, uint32_t width,
+ uint32_t height, const void *data);
+ struct wlr_texture *(*texture_from_wl_drm)(struct wlr_renderer *renderer,
+ struct wl_resource *data);
+ struct wlr_texture *(*texture_from_dmabuf)(struct wlr_renderer *renderer,
+ struct wlr_dmabuf_buffer_attribs *attribs);
void (*destroy)(struct wlr_renderer *renderer);
};
void wlr_renderer_init(struct wlr_renderer *renderer,
- const struct wlr_renderer_impl *impl);
+ const struct wlr_renderer_impl *impl);
struct wlr_texture_impl {
- bool (*upload_pixels)(struct wlr_texture *texture,
- enum wl_shm_format format, int stride, int width, int height,
- const unsigned char *pixels);
- bool (*update_pixels)(struct wlr_texture *texture,
- enum wl_shm_format format, int stride, int x, int y,
- int width, int height, const unsigned char *pixels);
- bool (*upload_shm)(struct wlr_texture *texture, uint32_t format,
- struct wl_shm_buffer *shm);
- bool (*update_shm)(struct wlr_texture *texture, uint32_t format,
- int x, int y, int width, int height, struct wl_shm_buffer *shm);
- bool (*upload_drm)(struct wlr_texture *texture,
- struct wl_resource *drm_buf);
- bool (*upload_eglimage)(struct wlr_texture *texture, EGLImageKHR image,
- uint32_t width, uint32_t height);
- 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 (*get_size)(struct wlr_texture *texture, int *width, int *height);
+ bool (*write_pixels)(struct wlr_texture *texture,
+ 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);
void (*destroy)(struct wlr_texture *texture);
};
void wlr_texture_init(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);
#endif
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
index 5c78089e..65fc7b19 100644
--- a/include/wlr/render/wlr_renderer.h
+++ b/include/wlr/render/wlr_renderer.h
@@ -1,8 +1,6 @@
#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>
@@ -22,10 +20,6 @@ void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
*/
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,
@@ -61,11 +55,16 @@ void wlr_render_ellipse_with_matrix(struct wlr_renderer *r,
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.
+ * Returns true if this wl_buffer is a wl_drm buffer.
*/
-bool wlr_renderer_buffer_is_drm(struct wlr_renderer *renderer,
+bool wlr_renderer_resource_is_wl_drm_buffer(struct wlr_renderer *renderer,
struct wl_resource *buffer);
/**
+ * Gets the width and height of a wl_drm buffer.
+ */
+void wlr_renderer_wl_drm_buffer_get_size(struct wlr_renderer *renderer,
+ struct wl_resource *buffer, int *width, int *height);
+/**
* Reads out of pixels of the currently bound surface into data. `stride` is in
* bytes.
*/
diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h
index 095097e6..ab361298 100644
--- a/include/wlr/render/wlr_texture.h
+++ b/include/wlr/render/wlr_texture.h
@@ -5,62 +5,49 @@
#include <EGL/eglext.h>
#include <stdint.h>
#include <wayland-server-protocol.h>
+#include <wlr/types/wlr_linux_dmabuf.h>
+struct wlr_renderer;
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.
+ * Create a new texture from raw pixel data. `stride` is in bytes. The returned
+ * texture is mutable.
*/
-bool wlr_texture_upload_pixels(struct wlr_texture *tex,
- enum wl_shm_format format, int stride, int width, int height,
- const unsigned char *pixels);
+struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer,
+ enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height,
+ const void *data);
+
/**
- * 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.
+ * Create a new texture from a wayland DRM resource. The returned texture is
+ * immutable.
*/
-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);
+struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer,
+ struct wl_resource *data);
+
/**
- * Copies pixels from a wl_shm_buffer into this texture. The buffer is not
- * accessed after this function returns.
+ * Create a new texture from a DMA-BUF. The returned texture is immutable.
*/
-bool wlr_texture_upload_shm(struct wlr_texture *tex, uint32_t format,
- struct wl_shm_buffer *shm);
+struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer,
+ struct wlr_dmabuf_buffer_attribs *attribs);
+
/**
- * 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.
+ * Get the texture width and height.
*/
-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);
+void wlr_texture_get_size(struct wlr_texture *texture, int *width, int *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.
+ * Update a texture with raw pixels. The texture must be mutable.
*/
-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);
+bool wlr_texture_write_pixels(struct wlr_texture *texture,
+ 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);
+
/**
* Destroys this wlr_texture.
*/