]> git.sesse.net Git - casparcg/commitdiff
Made it possible to equality compare tweener objects
authorHelge Norberg <helge.norberg@svt.se>
Tue, 22 Dec 2015 19:13:10 +0000 (20:13 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Tue, 22 Dec 2015 19:13:10 +0000 (20:13 +0100)
common/tweener.cpp
common/tweener.h
core/producer/stage.h
protocol/amcp/AMCPCommandsImpl.cpp

index d714f3e9a6e73fd7317b59d5e00d4a777ca97f95..e92cec8dbd3cf293437372707bbc5193a55b31e5 100644 (file)
@@ -466,17 +466,23 @@ tweener_t get_tweener(std::wstring name)
 
 tweener::tweener(const std::wstring& name)
        : func_(get_tweener(name))
+       , name_(name)
 {
 }
 
-tweener::tweener(const wchar_t* name)
-       : func_(get_tweener(name))
+double tweener::operator()(double t, double b , double c, double d) const
 {
+       return func_(t, b, c, d);
 }
 
-double tweener::operator()(double t, double b , double c, double d) const
+bool tweener::operator==(const tweener& other) const
 {
-       return func_(t, b, c, d);
+       return name_ == other.name_;
+}
+
+bool tweener::operator!=(const tweener& other) const
+{
+       return !(*this == other);
 }
 
 const std::vector<std::wstring>& tweener::names()
index 3a842a36b3401f671b819895f7072b2b8462f0ab..b5231f816375646711c21b6a66760ade521f61d9 100644 (file)
@@ -47,7 +47,6 @@ public:
         * @param name The name of the tween function to use.
         */
        tweener(const std::wstring& name = L"linear");
-       tweener(const wchar_t* name);
 
        /**
         * @return The possible tween function names. Some of them may also support
@@ -73,8 +72,12 @@ public:
         *             than b or greater than b + c for some tweener functions.
         */
        double operator()(double t, double b , double c, double d) const;
+
+       bool operator==(const tweener& other) const;
+       bool operator!=(const tweener& other) const;
 private:
-       std::function<double(double, double, double, double)> func_;
+       std::function<double(double, double, double, double)>   func_;
+       std::wstring                                                                                    name_;
 };
 
 }
index 9912258fa074382eea46781d97d60acad14bb700..69925892ec05babee4b27d6112e6b623b832ed00 100644 (file)
@@ -64,7 +64,7 @@ public:
        std::map<int, draw_frame>               operator()(const video_format_desc& format_desc);
 
        std::future<void>                               apply_transforms(const std::vector<transform_tuple_t>& transforms);
-       std::future<void>                               apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration = 0, const tweener& tween = L"linear");
+       std::future<void>                               apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration, const tweener& tween);
        std::future<void>                               clear_transforms(int index);
        std::future<void>                               clear_transforms();
        std::future<frame_transform>    get_current_transform(int index);
index 9297e03f0a502c44a39dc9baf7677f026bdf81ad..0512c563b3bc47e288773e16040b15d3d6f51f30 100644 (file)
@@ -1248,7 +1248,7 @@ std::wstring mixer_keyer_command(command_context& ctx)
        {
                transform.image_transform.is_key = value;
                return transform;
-       }, 0, L"linear"));
+       }, 0, tweener(L"linear")));
        transforms.apply();
 
        return L"202 MIXER OK\r\n";
@@ -1339,7 +1339,7 @@ std::wstring mixer_blend_command(command_context& ctx)
        {
                transform.image_transform.blend_mode = value;
                return transform;
-       }, 0, L"linear"));
+       }, 0, tweener(L"linear")));
        transforms.apply();
 
        return L"202 MIXER OK\r\n";
@@ -1848,7 +1848,7 @@ std::wstring mixer_mipmap_command(command_context& ctx)
        {
                transform.image_transform.use_mipmap = value;
                return transform;
-       }, 0, L"linear"));
+       }, 0, tweener(L"linear")));
        transforms.apply();
 
        return L"202 MIXER OK\r\n";