From 6bbf50708263dbda2a61a7c882d841f0b7b65ad6 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 29 Mar 2018 19:44:57 -0400 Subject: [PATCH] surface: fix texture not updated on commit When a client attaches a wl_drm or a linux_dmabuf buffer, we only update it if the size is different from the one of the old buffer. This means that if the client attaches a new, updated buffer with the same size as the old buffer, the texture won't get updated. This commit changes this behavior and re-creates the texture if the client attaches a new buffer, without requiring the size to be different. --- types/wlr_surface.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 3be7bdfc..672e6fea 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -331,7 +331,7 @@ static void wlr_surface_damage_subsurfaces(struct wlr_subsurface *subsurface) { } static void wlr_surface_apply_damage(struct wlr_surface *surface, - bool reupload_buffer) { + bool invalid_buffer, bool reupload_buffer) { struct wl_resource *resource = surface->current->buffer; if (resource == NULL) { return; @@ -374,7 +374,7 @@ static void wlr_surface_apply_damage(struct wlr_surface *surface, } wl_shm_buffer_end_access(buf); - } else if (!surface->texture || reupload_buffer) { + } else if (invalid_buffer || reupload_buffer) { wlr_texture_destroy(surface->texture); if (wlr_renderer_resource_is_wl_drm_buffer(surface->renderer, resource)) { @@ -398,9 +398,8 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) { int32_t oldw = surface->current->buffer_width; int32_t oldh = surface->current->buffer_height; - bool null_buffer_commit = - (surface->pending->invalid & WLR_SURFACE_INVALID_BUFFER && - surface->pending->buffer == NULL); + bool invalid_buffer = surface->pending->invalid & WLR_SURFACE_INVALID_BUFFER; + bool null_buffer_commit = invalid_buffer && surface->pending->buffer == NULL; wlr_surface_move_state(surface, surface->pending, surface->current); @@ -411,7 +410,7 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) { bool reupload_buffer = oldw != surface->current->buffer_width || oldh != surface->current->buffer_height; - wlr_surface_apply_damage(surface, reupload_buffer); + wlr_surface_apply_damage(surface, invalid_buffer, reupload_buffer); // commit subsurface order struct wlr_subsurface *subsurface;