Skip to content

Commit 602a947

Browse files
authored
Fix texture being not released issue (flutter-tizen#9)
If tbm_surface is not valid, we need to release tbm_surface when the flutter engine acquire external texture. If tbm_surface is not released, the next frame cannot be rendered.
1 parent 48a5982 commit 602a947

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

shell/platform/tizen/external_texture_gl.cc

+13-12
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ ExternalTextureGL::~ExternalTextureGL() {
3232
glDeleteTextures(1, &state_->gl_texture);
3333
}
3434
state_.release();
35-
if (texture_tbm_surface_) {
36-
tbm_surface_internal_unref(texture_tbm_surface_);
37-
texture_tbm_surface_ = NULL;
38-
}
35+
DestructionTbmSurface();
3936
mutex_.unlock();
4037
}
4138

@@ -47,12 +44,12 @@ bool ExternalTextureGL::OnFrameAvailable(tbm_surface_h tbm_surface) {
4744
return false;
4845
}
4946
if (texture_tbm_surface_) {
50-
LoggerE("texture_tbm_surface_ does not destruction, discard");
47+
LoggerD("texture_tbm_surface_ does not destruction, discard");
5148
mutex_.unlock();
5249
return false;
5350
}
5451
if (!tbm_surface_internal_is_valid(tbm_surface)) {
55-
LoggerE("tbm_surface not valid, pass");
52+
LoggerD("tbm_surface not valid, pass");
5653
mutex_.unlock();
5754
return false;
5855
}
@@ -66,12 +63,13 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
6663
size_t width, size_t height, FlutterOpenGLTexture* opengl_texture) {
6764
mutex_.lock();
6865
if (!texture_tbm_surface_) {
69-
LoggerE("texture_tbm_surface_ is NULL");
66+
LoggerD("texture_tbm_surface_ is NULL");
7067
mutex_.unlock();
7168
return false;
7269
}
7370
if (!tbm_surface_internal_is_valid(texture_tbm_surface_)) {
74-
LoggerE("tbm_surface not valid");
71+
LoggerD("tbm_surface not valid");
72+
DestructionTbmSurface();
7573
mutex_.unlock();
7674
return false;
7775
}
@@ -122,20 +120,23 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
122120
return true;
123121
}
124122

125-
void ExternalTextureGL::DestructionTbmSurface() {
123+
void ExternalTextureGL::DestructionTbmSurfaceWithLock() {
126124
mutex_.lock();
125+
DestructionTbmSurface();
126+
mutex_.unlock();
127+
}
128+
129+
void ExternalTextureGL::DestructionTbmSurface() {
127130
if (!texture_tbm_surface_) {
128131
LoggerE("tbm_surface_h is NULL");
129-
mutex_.unlock();
130132
return;
131133
}
132134
tbm_surface_internal_unref(texture_tbm_surface_);
133135
texture_tbm_surface_ = NULL;
134-
mutex_.unlock();
135136
}
136137

137138
void ExternalTextureGL::destructionCallback(void* user_data) {
138139
ExternalTextureGL* externalTextureGL =
139140
reinterpret_cast<ExternalTextureGL*>(user_data);
140-
externalTextureGL->DestructionTbmSurface();
141+
externalTextureGL->DestructionTbmSurfaceWithLock();
141142
}

shell/platform/tizen/external_texture_gl.h

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ExternalTextureGL {
4343
FlutterOpenGLTexture* opengl_texture);
4444
bool OnFrameAvailable(tbm_surface_h tbm_surface);
4545
void DestructionTbmSurface();
46+
void DestructionTbmSurfaceWithLock();
4647

4748
private:
4849
std::unique_ptr<ExternalTextureGLState> state_;

0 commit comments

Comments
 (0)