opengl: move renderer clean up to DeleteRenderer()
authorRomain Vimont <rom1v@videolabs.io>
Mon, 27 Jan 2020 14:13:19 +0000 (15:13 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 13 Feb 2020 22:11:21 +0000 (23:11 +0100)
Some renderer clean up was done after the call to DeleteRenderer().
Move it to DeleteRenderer to simplify further refactorings.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/video_output/opengl/vout_helper.c

index a161c4b..98be8f9 100644 (file)
@@ -359,7 +359,18 @@ error:
 static void
 DeleteRenderer(struct vlc_gl_renderer *renderer)
 {
 static void
 DeleteRenderer(struct vlc_gl_renderer *renderer)
 {
-    vlc_gl_interop_Delete(renderer->interop);
+    const opengl_vtable_t *vt = renderer->vt;
+    struct vlc_gl_interop *interop = renderer->interop;
+
+    vt->DeleteBuffers(1, &renderer->vertex_buffer_object);
+    vt->DeleteBuffers(1, &renderer->index_buffer_object);
+    vt->DeleteBuffers(interop->tex_count, renderer->texture_buffer_object);
+
+    if (!interop->handle_texs_gen)
+        vt->DeleteTextures(interop->tex_count, renderer->textures);
+
+    vlc_gl_interop_Delete(interop);
+
     if (renderer->program_id != 0)
         renderer->vt->DeleteProgram(renderer->program_id);
 
     if (renderer->program_id != 0)
         renderer->vt->DeleteProgram(renderer->program_id);
 
@@ -703,21 +714,9 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
     vgl->vt.Finish();
     vgl->vt.Flush();
 
     vgl->vt.Finish();
     vgl->vt.Flush();
 
-    struct vlc_gl_renderer *renderer = vgl->renderer;
-    const struct vlc_gl_interop *interop = renderer->interop;
-    const size_t main_tex_count = interop->tex_count;
-    const bool main_del_texs = !interop->handle_texs_gen;
-
     vlc_gl_sub_renderer_Delete(vgl->sub_renderer);
     DeleteRenderer(vgl->renderer);
 
     vlc_gl_sub_renderer_Delete(vgl->sub_renderer);
     DeleteRenderer(vgl->renderer);
 
-    vgl->vt.DeleteBuffers(1, &renderer->vertex_buffer_object);
-    vgl->vt.DeleteBuffers(1, &renderer->index_buffer_object);
-    vgl->vt.DeleteBuffers(main_tex_count, renderer->texture_buffer_object);
-
-    if (main_del_texs)
-        vgl->vt.DeleteTextures(main_tex_count, renderer->textures);
-
     GL_ASSERT_NOERROR();
 
     free(vgl);
     GL_ASSERT_NOERROR();
 
     free(vgl);