virtual bool needs_texture_bounce() const { return true; }
virtual bool needs_mipmaps() const { return true; }
virtual bool needs_srgb_primaries() const { return false; }
- virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED; }
+ virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA; }
virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height);
//Effect *sandbox_effect = chain.add_effect(new SandboxEffect());
//sandbox_effect->set_float("parm", 42.0f);
//chain.add_effect(new MirrorEffect());
- chain.add_output(inout_format, OUTPUT_ALPHA_POSTMULTIPLIED);
+ chain.add_output(inout_format, OUTPUT_POSTMULTIPLIED_ALPHA);
chain.set_dither_bits(8);
chain.finalize();
// This is the most natural format for processing, and the default in
// most of Movit (just like linear light is).
//
- // If you set INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED, all of your inputs
+ // If you set INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA, all of your inputs
// (if any) are guaranteed to also be in premultiplied alpha.
// Otherwise, you can get postmultiplied or premultiplied alpha;
// you won't know. If you have multiple inputs, you will get the same
// pre- and postmultiplied.
OUTPUT_BLANK_ALPHA,
+ // Always outputs postmultiplied alpha. Only appropriate for inputs.
+ OUTPUT_POSTMULTIPLIED_ALPHA,
+
// Always outputs premultiplied alpha. As noted above,
// you will then also get all inputs in premultiplied alpha.
// If you set this, you should also set needs_linear_light().
- INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED,
-
- // Always outputs postmultiplied alpha. Only appropriate for inputs.
- OUTPUT_ALPHA_POSTMULTIPLIED,
+ INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA,
// Keeps the type of alpha unchanged from input to output.
// Usually appropriate if you process all color channels
// Does not make sense for inputs.
DONT_CARE_ALPHA_TYPE,
};
- virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED; }
+ virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA; }
// Whether this effect expects its input to come directly from
// a texture. If this is true, the framework will not chain the
case Effect::OUTPUT_BLANK_ALPHA:
node->output_alpha_type = ALPHA_BLANK;
break;
- case Effect::INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED:
+ case Effect::INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA:
node->output_alpha_type = ALPHA_PREMULTIPLIED;
break;
- case Effect::OUTPUT_ALPHA_POSTMULTIPLIED:
+ case Effect::OUTPUT_POSTMULTIPLIED_ALPHA:
node->output_alpha_type = ALPHA_POSTMULTIPLIED;
break;
case Effect::DONT_CARE_ALPHA_TYPE:
}
// Only inputs can have unconditional alpha output (OUTPUT_BLANK_ALPHA
- // or OUTPUT_ALPHA_POSTMULTIPLIED), and they have already been
+ // or OUTPUT_POSTMULTIPLIED_ALPHA), and they have already been
// taken care of above. Rationale: Even if you could imagine
// e.g. an effect that took in an image and set alpha=1.0
// unconditionally, it wouldn't make any sense to have it as
// got its input pre- or postmultiplied, so it wouldn't know
// whether to divide away the old alpha or not.
Effect::AlphaHandling alpha_handling = node->effect->alpha_handling();
- assert(alpha_handling == Effect::INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED ||
+ assert(alpha_handling == Effect::INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA ||
alpha_handling == Effect::DONT_CARE_ALPHA_TYPE);
// If the node has multiple inputs, check that they are all valid and
continue;
}
- if (alpha_handling == Effect::INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED) {
+ if (alpha_handling == Effect::INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA) {
// If the effect has asked for premultiplied alpha, check that it has got it.
if (any_postmultiplied) {
node->output_alpha_type = ALPHA_INVALID;
return;
}
if (output->output_alpha_type == ALPHA_PREMULTIPLIED &&
- output_alpha_format == OUTPUT_ALPHA_POSTMULTIPLIED) {
+ output_alpha_format == OUTPUT_POSTMULTIPLIED_ALPHA) {
Node *conversion = add_node(new AlphaDivisionEffect());
connect_nodes(output, conversion);
propagate_alpha();
// (see effect.h for a discussion of pre- versus postmultiplied alpha).
enum OutputAlphaFormat {
OUTPUT_ALPHA_PREMULTIPLIED,
- OUTPUT_ALPHA_POSTMULTIPLIED,
+ OUTPUT_POSTMULTIPLIED_ALPHA,
};
// A node in the graph; basically an effect and some associated information.
switch (pixel_format) {
case FORMAT_RGBA_PREMULTIPLIED_ALPHA:
case FORMAT_BGRA_PREMULTIPLIED_ALPHA:
- return INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED;
+ return INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA;
case FORMAT_RGBA_POSTMULTIPLIED_ALPHA:
case FORMAT_BGRA_POSTMULTIPLIED_ALPHA:
- return OUTPUT_ALPHA_POSTMULTIPLIED;
+ return OUTPUT_POSTMULTIPLIED_ALPHA;
case FORMAT_RGB:
case FORMAT_BGR:
case FORMAT_GRAYSCALE:
// Actually needs postmultiplied input as well as outputting it.
// EffectChain will take care of that.
- virtual AlphaHandling alpha_handling() const { return OUTPUT_ALPHA_POSTMULTIPLIED; }
+ virtual AlphaHandling alpha_handling() const { return OUTPUT_POSTMULTIPLIED_ALPHA; }
private:
GammaCurve destination_curve;
// Actually, if either image has blank alpha, our output will have
// blank alpha, too. However, understanding that would require changes
// to EffectChain, so postpone that optimization for later.
- virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED; }
+ virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA; }
};
#endif // !defined(_OVERLAY_EFFECT_H)
if (border_color.r == 0.0 && border_color.g == 0.0 && border_color.b == 0.0) {
return DONT_CARE_ALPHA_TYPE;
}
- return INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED;
+ return INPUT_AND_OUTPUT_PREMULTIPLIED_ALPHA;
}
void PaddingEffect::get_output_size(unsigned *width, unsigned *height, unsigned *virtual_width, unsigned *virtual_height) const
RGBATriplet border_color(0.2f, 0.4f, 0.6f, 0.8f); // Same as the pixel in data[].
CHECK(effect->set_vec4("border_color", (float *)&border_color));
- tester.run(out_data, GL_RGBA, COLORSPACE_REC_601_625, GAMMA_REC_601, OUTPUT_ALPHA_POSTMULTIPLIED);
+ tester.run(out_data, GL_RGBA, COLORSPACE_REC_601_625, GAMMA_REC_601, OUTPUT_POSTMULTIPLIED_ALPHA);
expect_equal(expected_data, out_data, 4, 2);
}
EffectChain *get_chain() { return &chain; }
Input *add_input(const float *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve);
Input *add_input(const unsigned char *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve);
- void run(float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format = OUTPUT_ALPHA_POSTMULTIPLIED);
- void run(unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format = OUTPUT_ALPHA_POSTMULTIPLIED);
+ void run(float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format = OUTPUT_POSTMULTIPLIED_ALPHA);
+ void run(unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format = OUTPUT_POSTMULTIPLIED_ALPHA);
private:
void finalize_chain(Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format);