From 4fa90b05119720a67ccb63cd89246abdb4abf4ea Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 23 Jan 2018 22:06:54 +0100 Subject: Backport screenshooter fixes from the renderer redesign v1 This backports some changes to #319 to fix the screenshooter data format. This also adds wlr_backend_get_renderer which will be useful to support multiple renderers. --- include/wlr/backend.h | 1 + include/wlr/backend/interface.h | 1 + include/wlr/render.h | 13 ++++++++++--- include/wlr/render/interface.h | 8 ++++++-- include/wlr/types/wlr_screenshooter.h | 4 +--- 5 files changed, 19 insertions(+), 8 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/backend.h b/include/wlr/backend.h index 4632dcbf..d4b1f773 100644 --- a/include/wlr/backend.h +++ b/include/wlr/backend.h @@ -23,6 +23,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display); bool wlr_backend_start(struct wlr_backend *backend); void wlr_backend_destroy(struct wlr_backend *backend); struct wlr_egl *wlr_backend_get_egl(struct wlr_backend *backend); +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/interface.h b/include/wlr/backend/interface.h index 3f0aaadb..d9212795 100644 --- a/include/wlr/backend/interface.h +++ b/include/wlr/backend/interface.h @@ -9,6 +9,7 @@ struct wlr_backend_impl { bool (*start)(struct wlr_backend *backend); void (*destroy)(struct wlr_backend *backend); struct wlr_egl *(*get_egl)(struct wlr_backend *backend); + struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend); }; void wlr_backend_init(struct wlr_backend *backend, diff --git a/include/wlr/render.h b/include/wlr/render.h index 5027064d..00088b52 100644 --- a/include/wlr/render.h +++ b/include/wlr/render.h @@ -52,10 +52,17 @@ const enum wl_shm_format *wlr_renderer_get_formats( bool wlr_renderer_buffer_is_drm(struct wlr_renderer *renderer, struct wl_resource *buffer); /** - * Reads pixels and stores them in out_data as ARGB8888. + * Reads out of pixels of the currently bound surface into data. `stride` is in + * bytes. */ -void wlr_renderer_read_pixels(struct wlr_renderer *r, int x, int y, - int width, int height, void *out_data); +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. */ diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index bbc5acb4..bb337409 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -28,8 +28,12 @@ struct wlr_renderer_impl { struct wlr_renderer *renderer, size_t *len); bool (*buffer_is_drm)(struct wlr_renderer *renderer, struct wl_resource *buffer); - void (*read_pixels)(struct wlr_renderer *renderer, int x, int y, int width, - int height, void *out_data); + 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); void (*destroy)(struct wlr_renderer *renderer); }; diff --git a/include/wlr/types/wlr_screenshooter.h b/include/wlr/types/wlr_screenshooter.h index 4c66be3f..cfe7742d 100644 --- a/include/wlr/types/wlr_screenshooter.h +++ b/include/wlr/types/wlr_screenshooter.h @@ -4,7 +4,6 @@ struct wlr_screenshooter { struct wl_global *wl_global; - struct wlr_renderer *renderer; struct wl_list screenshots; // wlr_screenshot::link struct wl_listener display_destroy; @@ -23,8 +22,7 @@ struct wlr_screenshot { void* data; }; -struct wlr_screenshooter *wlr_screenshooter_create(struct wl_display *display, - struct wlr_renderer *renderer); +struct wlr_screenshooter *wlr_screenshooter_create(struct wl_display *display); void wlr_screenshooter_destroy(struct wlr_screenshooter *screenshooter); #endif -- cgit v1.2.3