render: add support for clearing render passes

introduces a new `wlr_render_pass_clear` function, allowing
render passes to be cleared with a solid color.
This commit is contained in:
YaoBing Xiao 2026-01-31 21:45:12 +08:00
parent 7cb4e30bfd
commit eeecb382cc
8 changed files with 120 additions and 8 deletions

View file

@ -62,6 +62,8 @@ struct wlr_render_pass_impl {
/* Implementers are also guaranteed that options->box is nonempty */
void (*add_rect)(struct wlr_render_pass *pass,
const struct wlr_render_rect_options *options);
void (*clear)(struct wlr_render_pass *pass,
const struct wlr_render_clear_options *options);
};
struct wlr_render_timer {

View file

@ -157,4 +157,20 @@ struct wlr_render_rect_options {
void wlr_render_pass_add_rect(struct wlr_render_pass *render_pass,
const struct wlr_render_rect_options *options);
struct wlr_render_clear_options {
/* Clear color */
struct wlr_render_color color;
/* Clip region, leave NULL to disable clipping */
const pixman_region32_t *clip;
};
/**
* Clear the render target with a solid color.
*
* This is optimized for GPU hardware (e.g., glClear + glScissor) and is more
* efficient than drawing a rectangle.
*/
void wlr_render_pass_clear(struct wlr_render_pass *render_pass,
const struct wlr_render_clear_options *options);
#endif