From 92e88776279884c48a0d7c4123505bc104f5390f Mon Sep 17 00:00:00 2001 From: Taekyun Kim Date: Tue, 13 Oct 2015 15:36:08 +0900 Subject: [PATCH] pepper: Release buffer when damage has been flushed Reference to the buffer should be hold by the backend if required. Change-Id: Id9eaaaed10c95ffd3cfe9e32a0e788e0b19680c1 --- src/lib/pepper/surface.c | 7 +++++++ src/lib/render/gl-renderer.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/pepper/surface.c b/src/lib/pepper/surface.c index bbcd61a..4987da0 100644 --- a/src/lib/pepper/surface.c +++ b/src/lib/pepper/surface.c @@ -526,4 +526,11 @@ pepper_surface_flush_damage(pepper_surface_t *surface) output->backend->flush_surface_damage(output->data, surface); pixman_region32_clear(&surface->damage_region); + + if (surface->buffer.buffer) + { + pepper_buffer_unreference(surface->buffer.buffer); + pepper_event_listener_remove(surface->buffer.destroy_listener); + surface->buffer.buffer = NULL; + } } diff --git a/src/lib/render/gl-renderer.c b/src/lib/render/gl-renderer.c index 0454ec0..b41e108 100644 --- a/src/lib/render/gl-renderer.c +++ b/src/lib/render/gl-renderer.c @@ -690,8 +690,11 @@ gl_renderer_flush_surface_damage(pepper_renderer_t *renderer, pepper_surface_t * gl_renderer_t *gr = (gl_renderer_t *)renderer; gl_surface_state_t *state = get_surface_state(renderer, surface); + if (!state->buffer) + goto done; + if (state->buffer_type != BUFFER_TYPE_SHM) - return PEPPER_TRUE; + goto done; glBindTexture(GL_TEXTURE_2D, state->textures[0]); @@ -703,7 +706,7 @@ gl_renderer_flush_surface_damage(pepper_renderer_t *renderer, pepper_surface_t * state->shm.format, state->shm.pixel_format, wl_shm_buffer_get_data(state->shm.buffer)); wl_shm_buffer_end_access(state->shm.buffer); - return PEPPER_TRUE; + goto done; } /* Texture upload. */ @@ -744,6 +747,11 @@ gl_renderer_flush_surface_damage(pepper_renderer_t *renderer, pepper_surface_t * wl_shm_buffer_end_access(state->shm.buffer); } +done: + pepper_buffer_unreference(state->buffer); + pepper_event_listener_remove(state->buffer_destroy_listener); + state->buffer = NULL; + return PEPPER_TRUE; } -- 2.7.4