]> git.sesse.net Git - movit/commitdiff
Remove the finalize() member function from Input.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 26 Jan 2014 23:44:44 +0000 (00:44 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 26 Jan 2014 23:53:39 +0000 (00:53 +0100)
It is no longer needed now that the texture is not created once,
but rather fetched on-demand from the ResourcePool.

effect_chain.cpp
flat_input.cpp
flat_input.h
input.h
ycbcr_input.cpp
ycbcr_input.h

index 114670c913d304daedcdc48acbbdaec24246b1ef..ec64b83fc336800eeb29a0f66520adfa79a332a5 100644 (file)
@@ -1413,10 +1413,6 @@ void EffectChain::finalize()
 
        output_dot("step19-split-to-phases.dot");
 
 
        output_dot("step19-split-to-phases.dot");
 
-       for (unsigned i = 0; i < inputs.size(); ++i) {
-               inputs[i]->finalize();
-       }
-
        assert(phases[0]->inputs.empty());
        
        finalized = true;
        assert(phases[0]->inputs.empty());
        
        finalized = true;
index 70cc10984cc2b2397f4ee109853cdf5bc0ccfc08..d19cd4ee7a272d4147a53f25446bf84b7a0b62d0 100644 (file)
@@ -15,7 +15,6 @@ FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format, GL
          type(type),
          pbo(0),
          texture_num(0),
          type(type),
          pbo(0),
          texture_num(0),
-         finalized(false),
          output_linear_gamma(false),
          needs_mipmaps(false),
          width(width),
          output_linear_gamma(false),
          needs_mipmaps(false),
          width(width),
@@ -35,43 +34,40 @@ FlatInput::~FlatInput()
        }
 }
 
        }
 }
 
-void FlatInput::finalize()
-{
-       // Translate the input format to OpenGL's enums.
-       if (type == GL_FLOAT) {
-               internal_format = GL_RGBA32F_ARB;
-       } else if (output_linear_gamma) {
-               assert(type == GL_UNSIGNED_BYTE);
-               internal_format = GL_SRGB8_ALPHA8;
-       } else {
-               assert(type == GL_UNSIGNED_BYTE);
-               internal_format = GL_RGBA8;
-       }
-       if (pixel_format == FORMAT_RGB) {
-               format = GL_RGB;
-       } else if (pixel_format == FORMAT_RGBA_PREMULTIPLIED_ALPHA ||
-                  pixel_format == FORMAT_RGBA_POSTMULTIPLIED_ALPHA) {
-               format = GL_RGBA;
-       } else if (pixel_format == FORMAT_BGR) {
-               format = GL_BGR;
-       } else if (pixel_format == FORMAT_BGRA_PREMULTIPLIED_ALPHA ||
-                  pixel_format == FORMAT_BGRA_POSTMULTIPLIED_ALPHA) {
-               format = GL_BGRA;
-       } else if (pixel_format == FORMAT_GRAYSCALE) {
-               format = GL_LUMINANCE;
-       } else {
-               assert(false);
-       }
-
-       finalized = true;
-}
-       
 void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num)
 {
        glActiveTexture(GL_TEXTURE0 + *sampler_num);
        check_error();
 
        if (texture_num == 0) {
 void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num)
 {
        glActiveTexture(GL_TEXTURE0 + *sampler_num);
        check_error();
 
        if (texture_num == 0) {
+               // Translate the input format to OpenGL's enums.
+               GLint internal_format;
+               GLenum format;
+               if (type == GL_FLOAT) {
+                       internal_format = GL_RGBA32F_ARB;
+               } else if (output_linear_gamma) {
+                       assert(type == GL_UNSIGNED_BYTE);
+                       internal_format = GL_SRGB8_ALPHA8;
+               } else {
+                       assert(type == GL_UNSIGNED_BYTE);
+                       internal_format = GL_RGBA8;
+               }
+               if (pixel_format == FORMAT_RGB) {
+                       format = GL_RGB;
+               } else if (pixel_format == FORMAT_RGBA_PREMULTIPLIED_ALPHA ||
+                          pixel_format == FORMAT_RGBA_POSTMULTIPLIED_ALPHA) {
+                       format = GL_RGBA;
+               } else if (pixel_format == FORMAT_BGR) {
+                       format = GL_BGR;
+               } else if (pixel_format == FORMAT_BGRA_PREMULTIPLIED_ALPHA ||
+                          pixel_format == FORMAT_BGRA_POSTMULTIPLIED_ALPHA) {
+                       format = GL_BGRA;
+               } else if (pixel_format == FORMAT_GRAYSCALE) {
+                       format = GL_LUMINANCE;
+               } else {
+                       assert(false);
+               }
+
                // (Re-)upload the texture.
                texture_num = resource_pool->create_2d_texture(internal_format, width, height);
                glBindTexture(GL_TEXTURE_2D, texture_num);
                // (Re-)upload the texture.
                texture_num = resource_pool->create_2d_texture(internal_format, width, height);
                glBindTexture(GL_TEXTURE_2D, texture_num);
index 7875e2c793ce91778b2ae5598bc63da1112434fb..57f6f5a27d75213f92e668065dbd23991ef91781 100644 (file)
@@ -22,11 +22,6 @@ public:
 
        virtual std::string effect_type_id() const { return "FlatInput"; }
 
 
        virtual std::string effect_type_id() const { return "FlatInput"; }
 
-       // Create the texture itself. We cannot do this in the constructor,
-       // because we don't necessarily know all the settings (sRGB texture,
-       // mipmap generation) at that point.
-       void finalize();
-
        virtual bool can_output_linear_gamma() const {
                return (movit_srgb_textures_supported &&
                        type == GL_UNSIGNED_BYTE &&
        virtual bool can_output_linear_gamma() const {
                return (movit_srgb_textures_supported &&
                        type == GL_UNSIGNED_BYTE &&
@@ -89,8 +84,8 @@ public:
        void invalidate_pixel_data();
 
        void set_pitch(unsigned pitch) {
        void invalidate_pixel_data();
 
        void set_pitch(unsigned pitch) {
-               assert(!finalized);
                this->pitch = pitch;
                this->pitch = pitch;
+               invalidate_pixel_data();
        }
 
        virtual void inform_added(EffectChain *chain)
        }
 
        virtual void inform_added(EffectChain *chain)
@@ -101,9 +96,8 @@ public:
 private:
        ImageFormat image_format;
        MovitPixelFormat pixel_format;
 private:
        ImageFormat image_format;
        MovitPixelFormat pixel_format;
-       GLenum internal_format, format, type;
+       GLenum type;
        GLuint pbo, texture_num;
        GLuint pbo, texture_num;
-       bool finalized;
        int output_linear_gamma, needs_mipmaps;
        unsigned width, height, pitch;
        const void *pixel_data;
        int output_linear_gamma, needs_mipmaps;
        unsigned width, height, pitch;
        const void *pixel_data;
diff --git a/input.h b/input.h
index da5b1fb287d599b204c32540835322677678b122..e0febb1712895876758c9bffe9459b4c32feb8c7 100644 (file)
--- a/input.h
+++ b/input.h
@@ -7,9 +7,7 @@
 #include "image_format.h"
 
 // An input is a degenerate case of an effect; it represents the picture data
 #include "image_format.h"
 
 // An input is a degenerate case of an effect; it represents the picture data
-// that comes from the user. As such, it has zero “inputs” itself. Also, it
-// has an extra operation called finalize(), which runs when the effect chain
-// is finalized.
+// that comes from the user. As such, it has zero “inputs” itself.
 //
 // An input is, like any other effect, required to be able to output a GLSL
 // fragment giving a RGBA value (although that GLSL fragment will have zero
 //
 // An input is, like any other effect, required to be able to output a GLSL
 // fragment giving a RGBA value (although that GLSL fragment will have zero
@@ -19,11 +17,6 @@ class Input : public Effect {
 public:
        virtual unsigned num_inputs() const { return 0; }
 
 public:
        virtual unsigned num_inputs() const { return 0; }
 
-       // Create the texture itself. We cannot do this in the constructor,
-       // because we don't necessarily know all the settings (sRGB texture,
-       // mipmap generation) at that point.
-       virtual void finalize() = 0;
-
        // Whether this input can deliver linear gamma directly if it's
        // asked to. (If so, set the parameter “output_linear_gamma”
        // to activate it.)
        // Whether this input can deliver linear gamma directly if it's
        // asked to. (If so, set the parameter “output_linear_gamma”
        // to activate it.)
index 6e73d3e2015e219e0fc7f1b7a3961515db96e146..476f083af05d1ad9b5f26c1fd1b9a60a3393738b 100644 (file)
@@ -63,7 +63,6 @@ YCbCrInput::YCbCrInput(const ImageFormat &image_format,
                        unsigned width, unsigned height)
        : image_format(image_format),
          ycbcr_format(ycbcr_format),
                        unsigned width, unsigned height)
        : image_format(image_format),
          ycbcr_format(ycbcr_format),
-         finalized(false),
          needs_mipmaps(false),
          width(width),
          height(height),
          needs_mipmaps(false),
          width(width),
          height(height),
@@ -96,11 +95,6 @@ YCbCrInput::~YCbCrInput()
        }
 }
 
        }
 }
 
-void YCbCrInput::finalize()
-{
-       finalized = true;
-}
-       
 void YCbCrInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num)
 {
        for (unsigned channel = 0; channel < 3; ++channel) {
 void YCbCrInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsigned *sampler_num)
 {
        for (unsigned channel = 0; channel < 3; ++channel) {
index 9f4e320cb6926f1f21d8fc98b2a9c66669ecb6da..997eb481bc57d5ed3fbf491f7b9c2dc7fd44dafc 100644 (file)
@@ -44,11 +44,6 @@ public:
 
        virtual std::string effect_type_id() const { return "YCbCrInput"; }
 
 
        virtual std::string effect_type_id() const { return "YCbCrInput"; }
 
-       // Create the texture itself. We cannot do this in the constructor,
-       // because we don't necessarily know all the settings (sRGB texture,
-       // mipmap generation) at that point.
-       void finalize();
-
        virtual bool can_output_linear_gamma() const { return false; }
        virtual AlphaHandling alpha_handling() const { return OUTPUT_BLANK_ALPHA; }
 
        virtual bool can_output_linear_gamma() const { return false; }
        virtual AlphaHandling alpha_handling() const { return OUTPUT_BLANK_ALPHA; }
 
@@ -85,6 +80,7 @@ public:
        void set_pitch(unsigned channel, unsigned pitch) {
                assert(channel >= 0 && channel < 3);
                this->pitch[channel] = pitch;
        void set_pitch(unsigned channel, unsigned pitch) {
                assert(channel >= 0 && channel < 3);
                this->pitch[channel] = pitch;
+               invalidate_pixel_data();
        }
 
        virtual void inform_added(EffectChain *chain)
        }
 
        virtual void inform_added(EffectChain *chain)
@@ -96,7 +92,6 @@ private:
        ImageFormat image_format;
        YCbCrFormat ycbcr_format;
        GLuint pbos[3], texture_num[3];
        ImageFormat image_format;
        YCbCrFormat ycbcr_format;
        GLuint pbos[3], texture_num[3];
-       bool finalized;
 
        int needs_mipmaps;
 
 
        int needs_mipmaps;