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;
type(type),
pbo(0),
texture_num(0),
- finalized(false),
output_linear_gamma(false),
needs_mipmaps(false),
width(width),
}
}
-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) {
+ // 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);
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 &&
void invalidate_pixel_data();
void set_pitch(unsigned pitch) {
- assert(!finalized);
this->pitch = pitch;
+ invalidate_pixel_data();
}
virtual void inform_added(EffectChain *chain)
private:
ImageFormat image_format;
MovitPixelFormat pixel_format;
- GLenum internal_format, format, type;
+ GLenum type;
GLuint pbo, texture_num;
- bool finalized;
int output_linear_gamma, needs_mipmaps;
unsigned width, height, pitch;
const void *pixel_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
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.)
unsigned width, unsigned height)
: image_format(image_format),
ycbcr_format(ycbcr_format),
- finalized(false),
needs_mipmaps(false),
width(width),
height(height),
}
}
-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) {
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; }
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)
ImageFormat image_format;
YCbCrFormat ycbcr_format;
GLuint pbos[3], texture_num[3];
- bool finalized;
int needs_mipmaps;