mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-05-07 06:08:07 +02:00
render/texture: Emit signals on destroy and update
This allows compositors to track the texture life cycle. Allows e.g. compositors using the GLES2 renderer to know when the texture gotten via `wlr_gles2_texture_get_attribs()` changes. Signed-off-by: Guido Günther <agx@sigxcpu.org>
This commit is contained in:
parent
e8c03e9ce9
commit
eb2a36de69
2 changed files with 21 additions and 1 deletions
|
|
@ -24,6 +24,11 @@ struct wlr_texture {
|
|||
uint32_t width, height;
|
||||
|
||||
struct wlr_renderer *renderer;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
struct wl_signal updated;
|
||||
} events;
|
||||
};
|
||||
|
||||
struct wlr_texture_read_pixels_options {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,17 @@ void wlr_texture_init(struct wlr_texture *texture, struct wlr_renderer *renderer
|
|||
.width = width,
|
||||
.height = height,
|
||||
};
|
||||
|
||||
wl_signal_init(&texture->events.destroy);
|
||||
wl_signal_init(&texture->events.updated);
|
||||
}
|
||||
|
||||
void wlr_texture_destroy(struct wlr_texture *texture) {
|
||||
wl_signal_emit(&texture->events.destroy, NULL);
|
||||
|
||||
assert(wl_list_empty(&texture->events.destroy.listener_list));
|
||||
assert(wl_list_empty(&texture->events.updated.listener_list));
|
||||
|
||||
if (texture && texture->impl && texture->impl->destroy) {
|
||||
texture->impl->destroy(texture);
|
||||
} else {
|
||||
|
|
@ -133,5 +141,12 @@ bool wlr_texture_update_from_buffer(struct wlr_texture *texture,
|
|||
extents->y2 > buffer->height) {
|
||||
return false;
|
||||
}
|
||||
return texture->impl->update_from_buffer(texture, buffer, damage);
|
||||
|
||||
bool ret = texture->impl->update_from_buffer(texture, buffer, damage);
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wl_signal_emit (&texture->events.updated, NULL);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue