diff options
author | Simon Ser <contact@emersion.fr> | 2019-12-28 11:53:11 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-12-31 08:07:44 -0700 |
commit | 346b43e937340423901502fccb30f397e93efd5f (patch) | |
tree | 675e511a061edd82ba901757c6a6a1047c28c2dd | |
parent | a9b1d9e83854eb589978e4d8bea9198f1198a45f (diff) |
render: guard rendering operations between begin() and end()
Add a wlr_renderer.rendering bool, set it to true between
wlr_renderer_begin() and wlr_renderer_end(). Assert we're rendering when
calling functions that render.
-rw-r--r-- | include/wlr/render/wlr_renderer.h | 2 | ||||
-rw-r--r-- | render/wlr_renderer.c | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h index 522ce738..54e6506e 100644 --- a/include/wlr/render/wlr_renderer.h +++ b/include/wlr/render/wlr_renderer.h @@ -25,6 +25,8 @@ struct wlr_drm_format_set; struct wlr_renderer { const struct wlr_renderer_impl *impl; + bool rendering; + struct { struct wl_signal destroy; } events; diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 802cbdbd..eaf630c3 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -39,20 +39,30 @@ void wlr_renderer_destroy(struct wlr_renderer *r) { } void wlr_renderer_begin(struct wlr_renderer *r, int width, int height) { + assert(!r->rendering); + r->impl->begin(r, width, height); + + r->rendering = true; } void wlr_renderer_end(struct wlr_renderer *r) { + assert(r->rendering); + if (r->impl->end) { r->impl->end(r); } + + r->rendering = false; } void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]) { + assert(r->rendering); r->impl->clear(r, color); } void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box) { + assert(r->rendering); r->impl->scissor(r, box); } @@ -71,6 +81,7 @@ bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture, bool wlr_render_texture_with_matrix(struct wlr_renderer *r, struct wlr_texture *texture, const float matrix[static 9], float alpha) { + assert(r->rendering); return r->impl->render_texture_with_matrix(r, texture, matrix, alpha); } @@ -85,6 +96,7 @@ void wlr_render_rect(struct wlr_renderer *r, const struct wlr_box *box, void wlr_render_quad_with_matrix(struct wlr_renderer *r, const float color[static 4], const float matrix[static 9]) { + assert(r->rendering); r->impl->render_quad_with_matrix(r, color, matrix); } @@ -99,6 +111,7 @@ void wlr_render_ellipse(struct wlr_renderer *r, const struct wlr_box *box, void wlr_render_ellipse_with_matrix(struct wlr_renderer *r, const float color[static 4], const float matrix[static 9]) { + assert(r->rendering); r->impl->render_ellipse_with_matrix(r, color, matrix); } |