diff --git a/shell/platform/tizen/external_texture_gl.cc b/shell/platform/tizen/external_texture_gl.cc index 3f826d9c74cbb..a423220869d77 100644 --- a/shell/platform/tizen/external_texture_gl.cc +++ b/shell/platform/tizen/external_texture_gl.cc @@ -32,10 +32,7 @@ ExternalTextureGL::~ExternalTextureGL() { glDeleteTextures(1, &state_->gl_texture); } state_.release(); - if (texture_tbm_surface_) { - tbm_surface_internal_unref(texture_tbm_surface_); - texture_tbm_surface_ = NULL; - } + DestructionTbmSurface(); mutex_.unlock(); } @@ -47,12 +44,12 @@ bool ExternalTextureGL::OnFrameAvailable(tbm_surface_h tbm_surface) { return false; } if (texture_tbm_surface_) { - LoggerE("texture_tbm_surface_ does not destruction, discard"); + LoggerD("texture_tbm_surface_ does not destruction, discard"); mutex_.unlock(); return false; } if (!tbm_surface_internal_is_valid(tbm_surface)) { - LoggerE("tbm_surface not valid, pass"); + LoggerD("tbm_surface not valid, pass"); mutex_.unlock(); return false; } @@ -66,12 +63,13 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( size_t width, size_t height, FlutterOpenGLTexture* opengl_texture) { mutex_.lock(); if (!texture_tbm_surface_) { - LoggerE("texture_tbm_surface_ is NULL"); + LoggerD("texture_tbm_surface_ is NULL"); mutex_.unlock(); return false; } if (!tbm_surface_internal_is_valid(texture_tbm_surface_)) { - LoggerE("tbm_surface not valid"); + LoggerD("tbm_surface not valid"); + DestructionTbmSurface(); mutex_.unlock(); return false; } @@ -122,20 +120,23 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( return true; } -void ExternalTextureGL::DestructionTbmSurface() { +void ExternalTextureGL::DestructionTbmSurfaceWithLock() { mutex_.lock(); + DestructionTbmSurface(); + mutex_.unlock(); +} + +void ExternalTextureGL::DestructionTbmSurface() { if (!texture_tbm_surface_) { LoggerE("tbm_surface_h is NULL"); - mutex_.unlock(); return; } tbm_surface_internal_unref(texture_tbm_surface_); texture_tbm_surface_ = NULL; - mutex_.unlock(); } void ExternalTextureGL::destructionCallback(void* user_data) { ExternalTextureGL* externalTextureGL = reinterpret_cast(user_data); - externalTextureGL->DestructionTbmSurface(); + externalTextureGL->DestructionTbmSurfaceWithLock(); } diff --git a/shell/platform/tizen/external_texture_gl.h b/shell/platform/tizen/external_texture_gl.h index 2defe2800b382..e6fb8d1ed222b 100644 --- a/shell/platform/tizen/external_texture_gl.h +++ b/shell/platform/tizen/external_texture_gl.h @@ -43,6 +43,7 @@ class ExternalTextureGL { FlutterOpenGLTexture* opengl_texture); bool OnFrameAvailable(tbm_surface_h tbm_surface); void DestructionTbmSurface(); + void DestructionTbmSurfaceWithLock(); private: std::unique_ptr state_;