]> git.sesse.net Git - mlt/commitdiff
Remove the glsl_texture freelist.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 28 Jan 2014 20:34:36 +0000 (21:34 +0100)
committerDan Dennedy <dan@dennedy.org>
Thu, 30 Jan 2014 05:12:15 +0000 (21:12 -0800)
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.)

src/modules/opengl/filter_glsl_manager.cpp

index 9b01337301f5636717dc18637278c3a56caf6f45..cf71a211434073678a9135cc8e5721b903b0eeff 100644 (file)
@@ -117,29 +117,18 @@ glsl_texture GlslManager::get_texture(int width, int height, GLint internal_form
                        return tex;
                }
        }
                        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) {
        unlock();
 
        GLuint tex = 0;
        glGenTextures(1, &tex);
        if (!tex) {
-               glDeleteTextures(1, &tex);
                return NULL;
        }
 
                return NULL;
        }
 
+       glsl_texture gtex = new glsl_texture_s;
        if (!gtex) {
        if (!gtex) {
-               gtex = new glsl_texture_s;
-               if (!gtex)
-                       return NULL;
+               glDeleteTextures(1, &tex);
+               return NULL;
        }
 
        glBindTexture( GL_TEXTURE_2D, tex );
        }
 
        glBindTexture( GL_TEXTURE_2D, tex );
@@ -210,12 +199,11 @@ glsl_pbo GlslManager::get_pbo(int size)
 void GlslManager::cleanupContext()
 {
        lock();
 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);
                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);
        }
        if (pbo) {
                glDeleteBuffers(1, &pbo->pbo);