mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-17 22:05:56 -05:00
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:
parent
7cb4e30bfd
commit
eeecb382cc
8 changed files with 120 additions and 8 deletions
|
|
@ -275,10 +275,41 @@ static void render_pass_add_rect(struct wlr_render_pass *wlr_pass,
|
|||
pop_gles2_debug(renderer);
|
||||
}
|
||||
|
||||
static void render_pass_clear(struct wlr_render_pass *wlr_pass,
|
||||
const struct wlr_render_clear_options *options) {
|
||||
struct wlr_gles2_render_pass *pass = get_render_pass(wlr_pass);
|
||||
struct wlr_gles2_renderer *renderer = pass->buffer->renderer;
|
||||
|
||||
push_gles2_debug(renderer);
|
||||
|
||||
const struct wlr_render_color *color = &options->color;
|
||||
glClearColor(color->r, color->g, color->b, color->a);
|
||||
|
||||
if (options->clip) {
|
||||
int rects_len;
|
||||
const pixman_box32_t *rects = pixman_region32_rectangles(options->clip, &rects_len);
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
for (int i = 0; i < rects_len; i++) {
|
||||
const pixman_box32_t *rect = &rects[i];
|
||||
int height = pass->buffer->buffer->height;
|
||||
glScissor(rect->x1, height - rect->y2,
|
||||
rect->x2 - rect->x1, rect->y2 - rect->y1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
} else {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
pop_gles2_debug(renderer);
|
||||
}
|
||||
|
||||
static const struct wlr_render_pass_impl render_pass_impl = {
|
||||
.submit = render_pass_submit,
|
||||
.add_texture = render_pass_add_texture,
|
||||
.add_rect = render_pass_add_rect,
|
||||
.clear = render_pass_clear,
|
||||
};
|
||||
|
||||
static const char *reset_status_str(GLenum status) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue