]> git.sesse.net Git - movit/blobdiff - ycbcr_input.cpp
Implement the texture freelist in ResourcePool.
[movit] / ycbcr_input.cpp
index e089e512d5b7961f88159a3db23e9aa89259943e..eebb864c4ed49e7b9d6a61a68f8b2e2f95487ca5 100644 (file)
@@ -6,6 +6,7 @@
 #include <string.h>
 
 #include "effect_util.h"
+#include "resource_pool.h"
 #include "util.h"
 #include "ycbcr_input.h"
 
@@ -65,7 +66,8 @@ YCbCrInput::YCbCrInput(const ImageFormat &image_format,
          finalized(false),
          needs_mipmaps(false),
          width(width),
-         height(height)
+         height(height),
+         resource_pool(NULL)
 {
        pbos[0] = pbos[1] = pbos[2] = 0;
        texture_num[0] = texture_num[1] = texture_num[2] = 0;
@@ -87,25 +89,22 @@ YCbCrInput::YCbCrInput(const ImageFormat &image_format,
 
 YCbCrInput::~YCbCrInput()
 {
-       if (texture_num[0] != 0) {
-               glDeleteTextures(3, texture_num);
-               check_error();
+       for (unsigned channel = 0; channel < 3; ++channel) {
+               if (texture_num[channel] != 0) {
+                       resource_pool->release_2d_texture(texture_num[channel]);
+               }
        }
 }
 
 void YCbCrInput::finalize()
 {
        // Create the textures themselves.
-       glGenTextures(3, texture_num);
-       check_error();
-
        for (unsigned channel = 0; channel < 3; ++channel) {
+               texture_num[channel] = resource_pool->create_2d_texture(GL_LUMINANCE8, widths[channel], heights[channel]);
                glBindTexture(GL_TEXTURE_2D, texture_num[channel]);
                check_error();
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                check_error();
-               glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, widths[channel], heights[channel], 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
-               check_error();
        }
 
        needs_update = true;