]> git.sesse.net Git - movit/blobdiff - flat_input.cpp
Reduce the amount of computation in combine_two_samples().
[movit] / flat_input.cpp
index e99eba3b0f562469e6d17086d34726fd152db209..1795902bcc23448741427e190772f371fe720a55 100644 (file)
@@ -28,6 +28,7 @@ FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format_in,
        assert(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_BYTE);
        register_int("output_linear_gamma", &output_linear_gamma);
        register_int("needs_mipmaps", &needs_mipmaps);
+       register_uniform_sampler2d("tex", &uniform_tex);
 
        // Some types are not supported in all GL versions (e.g. GLES),
        // and will corrected into the right format in the shader.
@@ -102,7 +103,13 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi
                        }
                } else if (output_linear_gamma) {
                        assert(type == GL_UNSIGNED_BYTE);
-                       internal_format = GL_SRGB8_ALPHA8;
+                       if (pixel_format == FORMAT_RGB) {
+                               internal_format = GL_SRGB8;
+                       } else if (pixel_format == FORMAT_RGBA_POSTMULTIPLIED_ALPHA) {
+                               internal_format = GL_SRGB8_ALPHA8;
+                       } else {
+                               assert(false);
+                       }
                } else {
                        assert(type == GL_UNSIGNED_BYTE);
                        if (pixel_format == FORMAT_R) {
@@ -162,7 +169,7 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi
        }
 
        // Bind it to a sampler.
-       set_uniform_int(glsl_program_num, prefix, "tex", *sampler_num);
+       uniform_tex = *sampler_num;
        ++*sampler_num;
 }