mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
Merge pull request #744 from emersion/texture-redesign
Redesign wlr_texture
This commit is contained in:
commit
330ee08126
24 changed files with 579 additions and 650 deletions
|
|
@ -46,37 +46,25 @@ 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -21,10 +19,6 @@ void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
|
|||
* 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.
|
||||
*/
|
||||
|
|
@ -61,10 +55,15 @@ 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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
/**
|
||||
* 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);
|
||||
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);
|
||||
|
||||
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.
|
||||
* Create a new texture from a wayland DRM resource. The returned texture is
|
||||
* immutable.
|
||||
*/
|
||||
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);
|
||||
struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer,
|
||||
struct wl_resource *data);
|
||||
|
||||
/**
|
||||
* Create a new texture from a DMA-BUF. The returned texture is immutable.
|
||||
*/
|
||||
struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer,
|
||||
struct wlr_dmabuf_buffer_attribs *attribs);
|
||||
|
||||
/**
|
||||
* Get the texture width and height.
|
||||
*/
|
||||
void wlr_texture_get_size(struct wlr_texture *texture, int *width, int *height);
|
||||
|
||||
/**
|
||||
* Update a texture with raw pixels. The texture must be mutable.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue