aboutsummaryrefslogtreecommitdiff
path: root/render/pass.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-05-02 21:32:51 +0200
committerSimon Ser <contact@emersion.fr>2023-05-02 21:32:51 +0200
commita93fc8afd60646243ee635b443fc2a17e2d97a18 (patch)
treef0336118d0f2b2312bf0886c836ca82a718d2c96 /render/pass.c
parent6b7d1d732ab5c548480729ef3c227a71c7b18a89 (diff)
render: introduce blend mode
Allow callers to pick the blend mode when rendering a rect. The "none" mode can be used to disable blending and clear rects.
Diffstat (limited to 'render/pass.c')
-rw-r--r--render/pass.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/render/pass.c b/render/pass.c
index 17c5d247..026e807b 100644
--- a/render/pass.c
+++ b/render/pass.c
@@ -134,6 +134,8 @@ static void legacy_add_rect(struct wlr_render_pass *wlr_pass,
pixman_region32_t clip;
get_clip_region(pass, options->clip, &clip);
+ pixman_region32_intersect_rect(&clip, &clip,
+ options->box.x, options->box.y, options->box.width, options->box.height);
float color[4] = {
options->color.r,
@@ -146,7 +148,14 @@ static void legacy_add_rect(struct wlr_render_pass *wlr_pass,
const pixman_box32_t *rects = pixman_region32_rectangles(&clip, &rects_len);
for (int i = 0; i < rects_len; i++) {
scissor(pass->renderer, &rects[i]);
- wlr_render_quad_with_matrix(pass->renderer, color, matrix);
+ switch (options->blend_mode) {
+ case WLR_RENDER_BLEND_MODE_PREMULTIPLIED:
+ wlr_render_quad_with_matrix(pass->renderer, color, matrix);
+ break;
+ case WLR_RENDER_BLEND_MODE_NONE:
+ wlr_renderer_clear(pass->renderer, color);
+ break;
+ }
}
wlr_renderer_scissor(pass->renderer, NULL);