@@ -34,24 +34,12 @@ EVAS_GL_GLOBAL_GLES3_DECLARE();
3434
3535namespace flutter {
3636
37- static void OnCollectTexture (void * textureGL) {
38- auto * weak_texture =
39- reinterpret_cast <std::weak_ptr<ExternalTexture>*>(textureGL);
40- auto strong_texture = weak_texture->lock ();
41- delete weak_texture;
42- if (strong_texture) {
43- strong_texture->OnDestruction ();
44- }
45- }
46-
4737ExternalTextureSurfaceGL::ExternalTextureSurfaceGL (
4838 ExternalTextureExtensionType gl_extension,
4939 FlutterDesktopGpuBufferTextureCallback texture_callback,
50- FlutterDesktopGpuBufferDestructionCallback destruction_callback,
5140 void * user_data)
5241 : ExternalTexture(gl_extension),
5342 texture_callback_ (texture_callback),
54- destruction_callback_(destruction_callback),
5543 user_data_(user_data) {}
5644
5745ExternalTextureSurfaceGL::~ExternalTextureSurfaceGL () {
@@ -77,6 +65,9 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
7765
7866 if (!gpu_buffer->buffer ) {
7967 FT_LOG (Info) << " tbm_surface is null for texture ID: " << texture_id_;
68+ if (gpu_buffer->release_callback ) {
69+ gpu_buffer->release_callback (gpu_buffer->release_context );
70+ }
8071 return false ;
8172 }
8273 const tbm_surface_h tbm_surface =
@@ -85,6 +76,9 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
8576 tbm_surface_info_s info;
8677 if (tbm_surface_get_info (tbm_surface, &info) != TBM_SURFACE_ERROR_NONE) {
8778 FT_LOG (Info) << " tbm_surface is invalid for texture ID: " << texture_id_;
79+ if (gpu_buffer->release_callback ) {
80+ gpu_buffer->release_callback (gpu_buffer->release_context );
81+ }
8882 return false ;
8983 }
9084
@@ -98,9 +92,15 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
9892 } else if (state_->gl_extension == ExternalTextureExtensionType::kDmaBuffer ) {
9993 FT_LOG (Error)
10094 << " EGL_EXT_image_dma_buf_import is not supported this renderer." ;
95+ if (gpu_buffer->release_callback ) {
96+ gpu_buffer->release_callback (gpu_buffer->release_context );
97+ }
10198 return false ;
10299 }
103100 if (!egl_src_image) {
101+ if (gpu_buffer->release_callback ) {
102+ gpu_buffer->release_callback (gpu_buffer->release_context );
103+ }
104104 return false ;
105105 }
106106 if (state_->gl_texture == 0 ) {
@@ -179,6 +179,9 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
179179 FT_LOG (Error) << " Either EGL_TIZEN_image_native_surface or "
180180 " EGL_EXT_image_dma_buf_import shoule be supported." ;
181181 }
182+ if (gpu_buffer->release_callback ) {
183+ gpu_buffer->release_callback (gpu_buffer->release_context );
184+ }
182185 return false ;
183186 }
184187 if (state_->gl_texture == 0 ) {
@@ -206,22 +209,17 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
206209 n_eglDestroyImageKHR (eglGetCurrentDisplay (), egl_src_image);
207210 }
208211#endif
209-
210212 opengl_texture->target = GL_TEXTURE_EXTERNAL_OES;
211213 opengl_texture->name = state_->gl_texture ;
212214 opengl_texture->format = GL_RGBA8;
213- opengl_texture->destruction_callback = OnCollectTexture;
214- auto * weak_texture = new std::weak_ptr<ExternalTexture>(shared_from_this ());
215- opengl_texture->user_data = weak_texture;
215+ opengl_texture->destruction_callback = nullptr ;
216+ opengl_texture->user_data = nullptr ;
216217 opengl_texture->width = width;
217218 opengl_texture->height = height;
218- return true ;
219- }
220-
221- void ExternalTextureSurfaceGL::OnDestruction () {
222- if (destruction_callback_) {
223- destruction_callback_ (user_data_);
219+ if (gpu_buffer->release_callback ) {
220+ gpu_buffer->release_callback (gpu_buffer->release_context );
224221 }
222+ return true ;
225223}
226224
227225} // namespace flutter
0 commit comments