mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
scene: listen to renderer destroy in wlr_scene_buffer
When a renderer is destroyed, so are all textures. Reset the texture in that case.
This commit is contained in:
parent
3d9f330ee0
commit
859373b253
2 changed files with 16 additions and 0 deletions
|
@ -191,6 +191,7 @@ struct wlr_scene_buffer {
|
||||||
bool buffer_is_opaque;
|
bool buffer_is_opaque;
|
||||||
|
|
||||||
struct wl_listener buffer_release;
|
struct wl_listener buffer_release;
|
||||||
|
struct wl_listener renderer_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A viewport for an output in the scene-graph */
|
/** A viewport for an output in the scene-graph */
|
||||||
|
|
|
@ -637,10 +637,24 @@ static void scene_buffer_set_buffer(struct wlr_scene_buffer *scene_buffer,
|
||||||
wl_signal_add(&buffer->events.release, &scene_buffer->buffer_release);
|
wl_signal_add(&buffer->events.release, &scene_buffer->buffer_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void scene_buffer_handle_renderer_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_scene_buffer *scene_buffer = wl_container_of(listener, scene_buffer, renderer_destroy);
|
||||||
|
scene_buffer_set_texture(scene_buffer, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void scene_buffer_set_texture(struct wlr_scene_buffer *scene_buffer,
|
static void scene_buffer_set_texture(struct wlr_scene_buffer *scene_buffer,
|
||||||
struct wlr_texture *texture) {
|
struct wlr_texture *texture) {
|
||||||
|
wl_list_remove(&scene_buffer->renderer_destroy.link);
|
||||||
wlr_texture_destroy(scene_buffer->texture);
|
wlr_texture_destroy(scene_buffer->texture);
|
||||||
scene_buffer->texture = texture;
|
scene_buffer->texture = texture;
|
||||||
|
|
||||||
|
if (texture != NULL) {
|
||||||
|
scene_buffer->renderer_destroy.notify = scene_buffer_handle_renderer_destroy;
|
||||||
|
wl_signal_add(&texture->renderer->events.destroy, &scene_buffer->renderer_destroy);
|
||||||
|
} else {
|
||||||
|
wl_list_init(&scene_buffer->renderer_destroy.link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||||
|
@ -659,6 +673,7 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||||
wl_signal_init(&scene_buffer->events.frame_done);
|
wl_signal_init(&scene_buffer->events.frame_done);
|
||||||
pixman_region32_init(&scene_buffer->opaque_region);
|
pixman_region32_init(&scene_buffer->opaque_region);
|
||||||
wl_list_init(&scene_buffer->buffer_release.link);
|
wl_list_init(&scene_buffer->buffer_release.link);
|
||||||
|
wl_list_init(&scene_buffer->renderer_destroy.link);
|
||||||
scene_buffer->opacity = 1;
|
scene_buffer->opacity = 1;
|
||||||
|
|
||||||
scene_buffer_set_buffer(scene_buffer, buffer);
|
scene_buffer_set_buffer(scene_buffer, buffer);
|
||||||
|
|
Loading…
Reference in a new issue