render: introduce wlr_render_rect_pass

Split rectangle rendering out of wlr_render_pass and add a dedicated
wlr_render_rect_pass interface.

Remove the add_rect hook from wlr_render_pass_impl and implement
rectangle rendering separately in the pixman, GLES2 and Vulkan
renderers.
This commit is contained in:
YaoBing Xiao 2026-03-13 10:49:41 +08:00
parent fd870f6d27
commit 33a27b055c
13 changed files with 258 additions and 9 deletions

View file

@ -50,6 +50,7 @@ void wlr_texture_init(struct wlr_texture *texture, struct wlr_renderer *rendener
struct wlr_render_pass {
const struct wlr_render_pass_impl *impl;
struct wlr_renderer *renderer;
};
void wlr_render_pass_init(struct wlr_render_pass *pass,
@ -59,9 +60,6 @@ struct wlr_render_pass_impl {
bool (*submit)(struct wlr_render_pass *pass);
void (*add_texture)(struct wlr_render_pass *pass,
const struct wlr_render_texture_options *options);
/* Implementers are also guaranteed that options->box is nonempty */
void (*add_rect)(struct wlr_render_pass *pass,
const struct wlr_render_rect_options *options);
};
struct wlr_render_timer {
@ -87,4 +85,29 @@ void wlr_texture_read_pixels_options_get_src_box(
void *wlr_texture_read_pixel_options_get_data(
const struct wlr_texture_read_pixels_options *options);
struct wlr_render_rect_pass;
struct wlr_render_rect_pass_impl {
void (*destroy)(struct wlr_render_rect_pass *pass);
void (*render)(struct wlr_render_pass *pass,
const struct wlr_render_rect_options *options);
};
struct wlr_render_rect_pass {
const struct wlr_render_rect_pass_impl *impl;
struct {
struct wl_signal destroy;
} events;
};
void wlr_render_rect_pass_init(struct wlr_render_rect_pass *pass,
const struct wlr_render_rect_pass_impl *impl);
void wlr_render_rect_pass_destroy(struct wlr_render_rect_pass *pass);
struct wlr_render_rect_pass *get_or_create_render_rect_pass(
struct wlr_renderer *renderer);
struct wlr_render_rect_pass *wlr_pixman_render_rect_pass_create(void);
struct wlr_render_rect_pass *wlr_gles2_render_rect_pass_create(void);
struct wlr_render_rect_pass *wlr_vk_render_rect_pass_create(void);
#endif

View file

@ -26,6 +26,10 @@ struct wlr_fbox;
* A renderer for basic 2D operations.
*/
struct wlr_renderer {
struct wlr_render_rect_pass *rect_pass;
void *data;
// Capabilities required for the buffer used as a render target (bitmask of
// enum wlr_buffer_cap)
uint32_t render_buffer_caps;

View file

@ -250,6 +250,8 @@ struct wlr_output {
struct wl_signal description;
struct wl_signal request_state; // struct wlr_output_event_request_state
struct wl_signal destroy;
// Emitted when the output's rendering subsystem is initialized or reinitialized
struct wl_signal render_inited;
} events;
struct wl_event_source *idle_frame;