From 9bf51e744e257398baaf5c42dace7e933c1a780d Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sat, 24 Jun 2023 01:52:30 -0400 Subject: [PATCH] render/gles2: Don't attach texture as buffer addon Since wlr_gles2_buffer is now managing importing for us, there is no reason for us to continue doing this. --- include/render/gles2.h | 1 - render/gles2/texture.c | 41 ++++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/include/render/gles2.h b/include/render/gles2.h index f61f335d..58972675 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -131,7 +131,6 @@ struct wlr_gles2_texture { uint32_t drm_format; // used to interpret upload data // If imported from a wlr_buffer struct wlr_gles2_buffer *buffer; - struct wlr_addon buffer_addon; }; struct wlr_gles2_render_pass { diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 49412054..b8edf9cd 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -136,7 +136,7 @@ static bool gles2_texture_invalidate(struct wlr_gles2_texture *texture) { void gles2_texture_destroy(struct wlr_gles2_texture *texture) { wl_list_remove(&texture->link); if (texture->buffer != NULL) { - wlr_addon_finish(&texture->buffer_addon); + wlr_buffer_unlock(texture->buffer->buffer); } if (texture->owns_tex) { @@ -156,20 +156,13 @@ void gles2_texture_destroy(struct wlr_gles2_texture *texture) { free(texture); } -static void gles2_texture_unref(struct wlr_texture *wlr_texture) { - struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture); - if (texture->buffer != NULL) { - // Keep the texture around, in case the buffer is re-used later. We're - // still listening to the buffer's destroy event. - wlr_buffer_unlock(texture->buffer->buffer); - } else { - gles2_texture_destroy(texture); - } +static void handle_gles2_texture_destroy(struct wlr_texture *wlr_texture) { + gles2_texture_destroy(gles2_get_texture(wlr_texture)); } static const struct wlr_texture_impl texture_impl = { .update_from_buffer = gles2_texture_update_from_buffer, - .destroy = gles2_texture_unref, + .destroy = handle_gles2_texture_destroy, }; static struct wlr_gles2_texture *gles2_texture_create( @@ -251,17 +244,6 @@ static struct wlr_texture *gles2_texture_from_pixels( return &texture->wlr_texture; } -static void texture_handle_buffer_destroy(struct wlr_addon *addon) { - struct wlr_gles2_texture *texture = - wl_container_of(addon, texture, buffer_addon); - gles2_texture_destroy(texture); -} - -static const struct wlr_addon_interface texture_addon_impl = { - .name = "wlr_gles2_texture", - .destroy = texture_handle_buffer_destroy, -}; - static struct wlr_texture *gles2_texture_from_dmabuf( struct wlr_gles2_renderer *renderer, struct wlr_buffer *wlr_buffer, struct wlr_dmabuf_attributes *attribs) { @@ -269,19 +251,6 @@ static struct wlr_texture *gles2_texture_from_dmabuf( return NULL; } - struct wlr_addon *addon = - wlr_addon_find(&wlr_buffer->addons, renderer, &texture_addon_impl); - if (addon != NULL) { - struct wlr_gles2_texture *texture = - wl_container_of(addon, texture, buffer_addon); - if (!gles2_texture_invalidate(texture)) { - wlr_log(WLR_ERROR, "Failed to invalidate texture"); - return false; - } - wlr_buffer_lock(texture->buffer->buffer); - return &texture->wlr_texture; - } - struct wlr_gles2_buffer *buffer = gles2_buffer_get_or_create(renderer, wlr_buffer); if (!buffer) { return NULL; @@ -326,8 +295,6 @@ static struct wlr_texture *gles2_texture_from_dmabuf( wlr_egl_restore_context(&prev_ctx); wlr_buffer_lock(texture->buffer->buffer); - wlr_addon_init(&texture->buffer_addon, &wlr_buffer->addons, - renderer, &texture_addon_impl); return &texture->wlr_texture; }