]> git.sesse.net Git - movit/commitdiff
Give the alpha enums somewhat better/more consistent names, and shuffle them around...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 1 Feb 2013 23:38:46 +0000 (00:38 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 1 Feb 2013 23:55:37 +0000 (00:55 +0100)
blur_effect.h
demo.cpp
effect.h
effect_chain.cpp
effect_chain.h
flat_input.h
gamma_compression_effect.h
overlay_effect.h
padding_effect.cpp
padding_effect_test.cpp
test_util.h

index 792014b9214a7e7390a53762dcc5fe0992df101f..4af11a2b16a388ca6435e03b3d500eb2946039c3 100644 (file)
@@ -24,7 +24,7 @@ public:
        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);
 
index 6e5f18c58ef229578f2e673bc7723d67d7755d61..298b5361ff1f8aaba212273e8720ab51cbfe2924 100644 (file)
--- a/demo.cpp
+++ b/demo.cpp
@@ -196,7 +196,7 @@ int main(int argc, char **argv)
        //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();
 
index c911f276ef71d94a6ab281f6339c87bb702af806..43849dfa5cdddd61035a58a528061f7045276ead 100644 (file)
--- a/effect.h
+++ b/effect.h
@@ -99,7 +99,7 @@ public:
        // 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
@@ -113,13 +113,13 @@ public:
                // 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
@@ -128,7 +128,7 @@ public:
                // 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
index 8a7ea9ac9e3a40900bc903c2a0bdef9b13b7d782..c04e34d517833384f90266ac7b80004f71c22f6e 100644 (file)
@@ -776,10 +776,10 @@ void EffectChain::find_color_spaces_for_inputs()
                        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:
@@ -885,7 +885,7 @@ void EffectChain::propagate_alpha()
                }
 
                // 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
@@ -893,7 +893,7 @@ void EffectChain::propagate_alpha()
                // 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
@@ -933,7 +933,7 @@ void EffectChain::propagate_alpha()
                        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;
@@ -1141,7 +1141,7 @@ void EffectChain::fix_output_alpha()
                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();
index bfe52c0dc6ddaf41d590557b984aabf2effa7d4a..f5064eb7b53bb8bfd8ea51919b33a4d9385649d4 100644 (file)
@@ -23,7 +23,7 @@ enum AlphaType {
 // (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.
index 87a0d5e8ce8f3b0a6134366ddf548395497e96f6..24a3fcad90347c545c093884dba809488ea6a317 100644 (file)
@@ -30,10 +30,10 @@ public:
                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:
index 2744d2ddf65f809e96a301cdcb0e016e499c8f25..46ac80e7d6b12e6b2b217dcb942d125fbe9788f3 100644 (file)
@@ -26,7 +26,7 @@ public:
 
        // 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;
index 64224afe572b9a7e738af3ab0a72fe8bb61a15ea..d26d9175110ca636890e5c03084a98a7e747560f 100644 (file)
@@ -24,7 +24,7 @@ public:
        // 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)
index c06a1ac49ef03b36cfa5ad338c71205aeb80d0b8..3c4919a0c3b1b98a3aa31ebf9aad14ff536bcdcf 100644 (file)
@@ -96,7 +96,7 @@ Effect::AlphaHandling PaddingEffect::alpha_handling() const
        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
index ecd0d1eac999abb3b52b51f8b938bbf718e8c3c4..1d2be797eb93a38bfb59fd13b8b6716cd56a703d 100644 (file)
@@ -103,7 +103,7 @@ TEST(PaddingEffectTest, BorderColorIsInLinearGamma) {
        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);
 }
 
index 90665916f4e3e2116e8027efe2c694aa10f0685b..eca6b6a83f65eaa32112e0a577a736f2d3ec8865 100644 (file)
@@ -15,8 +15,8 @@ public:
        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);