mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
render: add wlr_renderer_begin_with_buffer
This allows compositors to choose a wlr_buffer to render to. This is a less awkward interface than having to call bind_buffer() before and after begin() and end(). Closes: https://github.com/swaywm/wlroots/issues/2618
This commit is contained in:
parent
b732f094c6
commit
6430230d1f
2 changed files with 18 additions and 0 deletions
|
@ -27,6 +27,7 @@ struct wlr_renderer {
|
||||||
const struct wlr_renderer_impl *impl;
|
const struct wlr_renderer_impl *impl;
|
||||||
|
|
||||||
bool rendering;
|
bool rendering;
|
||||||
|
bool rendering_with_buffer;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
|
@ -36,6 +37,8 @@ struct wlr_renderer {
|
||||||
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend);
|
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend);
|
||||||
|
|
||||||
void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
|
void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
|
||||||
|
bool wlr_renderer_begin_with_buffer(struct wlr_renderer *r,
|
||||||
|
struct wlr_buffer *buffer);
|
||||||
void wlr_renderer_end(struct wlr_renderer *r);
|
void wlr_renderer_end(struct wlr_renderer *r);
|
||||||
void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
|
void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,6 +66,16 @@ void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height)
|
||||||
r->rendering = true;
|
r->rendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wlr_renderer_begin_with_buffer(struct wlr_renderer *r,
|
||||||
|
struct wlr_buffer *buffer) {
|
||||||
|
if (!wlr_renderer_bind_buffer(r, buffer)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
wlr_renderer_begin(r, buffer->width, buffer->height);
|
||||||
|
r->rendering_with_buffer = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_renderer_end(struct wlr_renderer *r) {
|
void wlr_renderer_end(struct wlr_renderer *r) {
|
||||||
assert(r->rendering);
|
assert(r->rendering);
|
||||||
|
|
||||||
|
@ -74,6 +84,11 @@ void wlr_renderer_end(struct wlr_renderer *r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
r->rendering = false;
|
r->rendering = false;
|
||||||
|
|
||||||
|
if (r->rendering_with_buffer) {
|
||||||
|
wlr_renderer_bind_buffer(r, NULL);
|
||||||
|
r->rendering_with_buffer = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]) {
|
void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]) {
|
||||||
|
|
Loading…
Reference in a new issue