fix: may memory issue on linux

This commit is contained in:
Kingtous 2023-02-18 19:17:07 +08:00
parent 3e42db31d1
commit 35e480aa73
2 changed files with 5 additions and 1 deletions

View file

@ -54,12 +54,13 @@ static gboolean texture_rgba_populate(FlTextureGL *texture,
// Note that Flutter only accepts textures in GL_RGBA8 format. // Note that Flutter only accepts textures in GL_RGBA8 format.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, self->video_width, self->video_height, 0, GL_RGBA, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, self->video_width, self->video_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, self->buffer); GL_UNSIGNED_BYTE, self->buffer);
self->buffer = nullptr;
g_mutex_unlock(&self->mutex); g_mutex_unlock(&self->mutex);
*target = GL_TEXTURE_2D; *target = GL_TEXTURE_2D;
*name = self->texture_id; *name = self->texture_id;
*width = self->video_width; *width = self->video_width;
*height = self->video_height; *height = self->video_height;
return TRUE; return TRUE;
} }

View file

@ -82,6 +82,9 @@ static void texture_rgba_renderer_plugin_handle_method_call(
auto texture_rgba = (*self->g_renderer_map)[key]; auto texture_rgba = (*self->g_renderer_map)[key];
auto texture_rgba_private = (TextureRgbaPrivate *)texture_rgba_get_instance_private((*self->g_renderer_map)[key]); auto texture_rgba_private = (TextureRgbaPrivate *)texture_rgba_get_instance_private((*self->g_renderer_map)[key]);
g_mutex_lock(&texture_rgba_private->mutex); g_mutex_lock(&texture_rgba_private->mutex);
if (texture_rgba_private->buffer != nullptr) {
delete[] texture_rgba_private->buffer;
}
texture_rgba_private->buffer = buffer; texture_rgba_private->buffer = buffer;
texture_rgba_private->video_height = height; texture_rgba_private->video_height = height;
texture_rgba_private->video_width = width; texture_rgba_private->video_width = width;