From: Steinar H. Gunderson Date: Tue, 28 Jan 2014 20:34:36 +0000 (+0100) Subject: Remove the glsl_texture freelist. X-Git-Url: https://git.sesse.net/?p=mlt;a=commitdiff_plain;h=96fc85b6fe773d2b1ac1199fe51051efa4717237 Remove the glsl_texture freelist. Given that new/delete on such small objects are cheap and this happens rarely, it is probably not worth the extra complexity. (In the process, fix a minor bug related to out-of-memory; not that new will actually ever return NULL on any compilers newer then MSVC6.) --- diff --git a/src/modules/opengl/filter_glsl_manager.cpp b/src/modules/opengl/filter_glsl_manager.cpp index 9b013373..cf71a211 100644 --- a/src/modules/opengl/filter_glsl_manager.cpp +++ b/src/modules/opengl/filter_glsl_manager.cpp @@ -117,29 +117,18 @@ glsl_texture GlslManager::get_texture(int width, int height, GLint internal_form return tex; } } - - // Recycle a glsl_texture with deleted glTexture. - glsl_texture gtex = 0; - for (int i = 0; i < texture_list.count(); ++i) { - glsl_texture tex = (glsl_texture) texture_list.peek(i); - if (!tex->used && !tex->width && !tex->height) { - gtex = tex; - break; - } - } unlock(); GLuint tex = 0; glGenTextures(1, &tex); if (!tex) { - glDeleteTextures(1, &tex); return NULL; } + glsl_texture gtex = new glsl_texture_s; if (!gtex) { - gtex = new glsl_texture_s; - if (!gtex) - return NULL; + glDeleteTextures(1, &tex); + return NULL; } glBindTexture( GL_TEXTURE_2D, tex ); @@ -210,12 +199,11 @@ glsl_pbo GlslManager::get_pbo(int size) void GlslManager::cleanupContext() { lock(); - for (int i = 0; i < texture_list.count(); ++i) { - glsl_texture texture = (glsl_texture) texture_list.peek(i); + while (texture_list.peek_back()) { + glsl_texture texture = (glsl_texture) texture_list.peek_back(); glDeleteTextures(1, &texture->texture); - texture->used = 0; - texture->width = 0; - texture->height = 0; + delete texture; + texture_list.pop_back(); } if (pbo) { glDeleteBuffers(1, &pbo->pbo);