diff options
author | emersion <contact@emersion.fr> | 2018-04-02 15:57:04 -0400 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-04-02 15:57:04 -0400 |
commit | 8836b4f024f957971cae28a0fdc567ff16c8fbc8 (patch) | |
tree | 23be1fc669c4fc721a521691ce182041cc7c5237 /include/wlr/render | |
parent | cadfccf1fde164646b175401a3fb1d3108b4af9a (diff) | |
parent | d466cc117f95d34e239049a5af701b7ba696d336 (diff) |
Merge branch 'master' into xwayland-dnd
Diffstat (limited to 'include/wlr/render')
-rw-r--r-- | include/wlr/render/egl.h | 36 | ||||
-rw-r--r-- | include/wlr/render/gles2.h | 11 | ||||
-rw-r--r-- | include/wlr/render/interface.h | 41 | ||||
-rw-r--r-- | include/wlr/render/wlr_renderer.h | 15 | ||||
-rw-r--r-- | include/wlr/render/wlr_texture.h | 63 |
5 files changed, 76 insertions, 90 deletions
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index aa429e8e..51f63b20 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -13,14 +13,14 @@ struct wlr_egl { EGLConfig config; EGLContext context; - const char *egl_exts_str; - const char *gl_exts_str; + const char *exts_str; struct { bool buffer_age; bool swap_buffers_with_damage; bool dmabuf_import; bool dmabuf_import_modifiers; + bool bind_wayland_display; } egl_exts; struct wl_display *wl_display; @@ -28,55 +28,51 @@ struct wlr_egl { // TODO: Allocate and return a wlr_egl /** - * Initializes an egl context for the given platform and remote display. + * Initializes an EGL context for the given platform and remote display. * Will attempt to load all possibly required api functions. */ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, EGLint *config_attribs, EGLint visual_id); /** - * Frees all related egl resources, makes the context not-current and + * Frees all related EGL resources, makes the context not-current and * unbinds a bound wayland display. */ void wlr_egl_finish(struct wlr_egl *egl); /** - * Binds the given display to the egl instance. - * This will allow clients to create egl surfaces from wayland ones and render to it. + * Binds the given display to the EGL instance. + * This will allow clients to create EGL surfaces from wayland ones and render + * to it. */ 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. + * Creates an EGL image from the given wl_drm buffer resource. */ -EGLImageKHR wlr_egl_create_image(struct wlr_egl *egl, - EGLenum target, EGLClientBuffer buffer, const EGLint *attribs); +EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl, + struct wl_resource *data, EGLint *fmt, int *width, int *height, + bool *inverted_y); /** - * Creates an egl image from the given dmabuf attributes. Check usability + * 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 @@ -90,13 +86,15 @@ 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. + * 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); +bool wlr_egl_is_current(struct wlr_egl *egl); + bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, pixman_region32_t *damage); diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index b3b43ab2..65bb36c1 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -5,6 +5,15 @@ #include <wlr/render/wlr_renderer.h> struct wlr_egl; -struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend); + +struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl); + +struct wlr_texture *wlr_gles2_texture_from_pixels(struct wlr_egl *egl, + enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height, + const void *data); +struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl, + struct wl_resource *data); +struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl, + struct wlr_dmabuf_buffer_attribs *attribs); #endif 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..239fc51b 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 wl_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. */ |