]> git.sesse.net Git - movit/commitdiff
Mark ResampleEffect as not one-to-one sampling.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Sep 2015 14:37:47 +0000 (16:37 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Sep 2015 14:37:47 +0000 (16:37 +0200)
The assumption is broken whenever a non-integral top or left parameter
is specified. Instead, make an IntegralResampleEffect that enforces
these parameters to be integers, and then mark it as one-to-one sampling.

padding_effect.cpp
padding_effect.h

index f576baa2d5c3f8cb043a0395cdd3d3314a7bdd90..d8ed95212c66d7d797e1bce748362fe54f0f03c8 100644 (file)
@@ -133,4 +133,25 @@ void PaddingEffect::inform_input_size(unsigned input_num, unsigned width, unsign
        input_height = height;
 }
 
+IntegralPaddingEffect::IntegralPaddingEffect() {}
+
+bool IntegralPaddingEffect::set_int(const std::string &key, int value)
+{
+       if (key == "top" || key == "left") {
+               return PaddingEffect::set_float(key, value);
+       } else {
+               return PaddingEffect::set_int(key, value);
+       }
+}
+
+bool IntegralPaddingEffect::set_float(const std::string &key, float value)
+{
+       if (key == "top" || key == "left") {
+               // These are removed as float parameters from this version.
+               return false;
+       } else {
+               return PaddingEffect::set_float(key, value);
+       }
+}
+
 }  // namespace movit
index 13dc5c00ab511e34166450c5f768206c91016cb7..acd555fa3511bd27414e4bf38c9411e49cb384b8 100644 (file)
 // The border color is taken to be in linear gamma, sRGB, with premultiplied alpha.
 // You may not change it after calling finalize(), since that could change the
 // graph (need_linear_light() etc. depend on the border color you choose).
+//
+// IntegralPaddingEffect is like PaddingEffect, except that "top" and "left" parameters
+// are int parameters instead of float. This allows it to guarantee one-to-one sampling,
+// which can speed up processing by allowing more effect passes to be collapsed.
 
 #include <epoxy/gl.h>
 #include <string>
@@ -32,7 +36,6 @@ public:
        
        virtual bool changes_output_size() const { return true; }
        virtual bool sets_virtual_output_size() const { return false; }
-       virtual bool one_to_one_sampling() const { return true; }
        virtual void get_output_size(unsigned *width, unsigned *height, unsigned *virtual_width, unsigned *virtual_height) const;
        virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height);
 
@@ -43,6 +46,15 @@ private:
        float top, left;
 };
 
+class IntegralPaddingEffect : public PaddingEffect {
+public:
+       IntegralPaddingEffect();
+       virtual std::string effect_type_id() const { return "IntegralPaddingEffect"; }
+       virtual bool one_to_one_sampling() const { return true; }
+       virtual bool set_int(const std::string&, int value);
+       virtual bool set_float(const std::string &key, float value);
+};
+
 }  // namespace movit
 
 #endif // !defined(_MOVIT_PADDING_EFFECT_H)