aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-01-12 18:33:34 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-11-15 15:50:19 +0000
commita541c9510a4cf544313bc9b0503d75820b42444e (patch)
treec500354bf7df22be93c69acfe03e3f8604568d6d
parent23540b557931bddc5053f363fa38d87e3254a78d (diff)
render: make wlr_renderer_begin return a bool
-rw-r--r--include/wlr/render/wlr_renderer.h4
-rw-r--r--render/wlr_renderer.c12
2 files changed, 12 insertions, 4 deletions
diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
index b9e83734..7d4e6720 100644
--- a/include/wlr/render/wlr_renderer.h
+++ b/include/wlr/render/wlr_renderer.h
@@ -49,8 +49,10 @@ struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend);
*
* This should be called after wlr_output_attach_render(). Compositors must call
* wlr_renderer_end() when they are done.
+ *
+ * Returns false on failure, in which case compositors shouldn't try rendering.
*/
-void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
+bool wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
/**
* Start a render pass on the provided struct wlr_buffer.
*
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 2d6481f0..b10b7513 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -70,12 +70,15 @@ bool renderer_bind_buffer(struct wlr_renderer *r, struct wlr_buffer *buffer) {
return r->impl->bind_buffer(r, buffer);
}
-void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height) {
+bool wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height) {
assert(!r->rendering);
- r->impl->begin(r, width, height);
+ if (!r->impl->begin(r, width, height)) {
+ return false;
+ }
r->rendering = true;
+ return true;
}
bool wlr_renderer_begin_with_buffer(struct wlr_renderer *r,
@@ -83,7 +86,10 @@ bool wlr_renderer_begin_with_buffer(struct wlr_renderer *r,
if (!renderer_bind_buffer(r, buffer)) {
return false;
}
- wlr_renderer_begin(r, buffer->width, buffer->height);
+ if (!wlr_renderer_begin(r, buffer->width, buffer->height)) {
+ renderer_bind_buffer(r, NULL);
+ return false;
+ }
r->rendering_with_buffer = true;
return true;
}