diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/vulkan/renderer.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c index 8649ff14..4d134877 100644 --- a/render/vulkan/renderer.c +++ b/render/vulkan/renderer.c @@ -386,7 +386,7 @@ struct wlr_vk_format_props *vulkan_format_props_from_drm( // buffer import static void destroy_render_buffer(struct wlr_vk_render_buffer *buffer) { wl_list_remove(&buffer->link); - wl_list_remove(&buffer->buffer_destroy.link); + wlr_addon_finish(&buffer->addon); assert(buffer->renderer->current_render_buffer != buffer); @@ -403,23 +403,16 @@ static void destroy_render_buffer(struct wlr_vk_render_buffer *buffer) { free(buffer); } -static struct wlr_vk_render_buffer *get_render_buffer( - struct wlr_vk_renderer *renderer, struct wlr_buffer *wlr_buffer) { - struct wlr_vk_render_buffer *buffer; - wl_list_for_each(buffer, &renderer->render_buffers, link) { - if (buffer->wlr_buffer == wlr_buffer) { - return buffer; - } - } - return NULL; -} - -static void handle_render_buffer_destroy(struct wl_listener *listener, void *data) { - struct wlr_vk_render_buffer *buffer = - wl_container_of(listener, buffer, buffer_destroy); +static void handle_render_buffer_destroy(struct wlr_addon *addon) { + struct wlr_vk_render_buffer *buffer = wl_container_of(addon, buffer, addon); destroy_render_buffer(buffer); } +static struct wlr_addon_interface render_buffer_addon_impl = { + .name = "wlr_vk_render_buffer", + .destroy = handle_render_buffer_destroy, +}; + static struct wlr_vk_render_buffer *create_render_buffer( struct wlr_vk_renderer *renderer, struct wlr_buffer *wlr_buffer) { VkResult res; @@ -496,8 +489,8 @@ static struct wlr_vk_render_buffer *create_render_buffer( goto error_view; } - buffer->buffer_destroy.notify = handle_render_buffer_destroy; - wl_signal_add(&wlr_buffer->events.destroy, &buffer->buffer_destroy); + wlr_addon_init(&buffer->addon, &wlr_buffer->addons, renderer, + &render_buffer_addon_impl); wl_list_insert(&renderer->render_buffers, &buffer->link); return buffer; @@ -515,6 +508,18 @@ error_buffer: return NULL; } +static struct wlr_vk_render_buffer *get_render_buffer( + struct wlr_vk_renderer *renderer, struct wlr_buffer *wlr_buffer) { + struct wlr_addon *addon = + wlr_addon_find(&wlr_buffer->addons, renderer, &render_buffer_addon_impl); + if (addon == NULL) { + return NULL; + } + + struct wlr_vk_render_buffer *buffer = wl_container_of(addon, buffer, addon); + return buffer; +} + // interface implementation static bool vulkan_bind_buffer(struct wlr_renderer *wlr_renderer, struct wlr_buffer *wlr_buffer) { |