From f63f28af35a3907911f33108f180815b9e294d21 Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Tue, 22 Dec 2015 20:13:10 +0100 Subject: [PATCH] Made it possible to equality compare tweener objects --- common/tweener.cpp | 14 ++++++++++---- common/tweener.h | 7 +++++-- core/producer/stage.h | 2 +- protocol/amcp/AMCPCommandsImpl.cpp | 6 +++--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/common/tweener.cpp b/common/tweener.cpp index d714f3e9a..e92cec8db 100644 --- a/common/tweener.cpp +++ b/common/tweener.cpp @@ -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& tweener::names() diff --git a/common/tweener.h b/common/tweener.h index 3a842a36b..b5231f816 100644 --- a/common/tweener.h +++ b/common/tweener.h @@ -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 func_; + std::function func_; + std::wstring name_; }; } diff --git a/core/producer/stage.h b/core/producer/stage.h index 9912258fa..69925892e 100644 --- a/core/producer/stage.h +++ b/core/producer/stage.h @@ -64,7 +64,7 @@ public: std::map operator()(const video_format_desc& format_desc); std::future apply_transforms(const std::vector& transforms); - std::future apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration = 0, const tweener& tween = L"linear"); + std::future apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration, const tweener& tween); std::future clear_transforms(int index); std::future clear_transforms(); std::future get_current_transform(int index); diff --git a/protocol/amcp/AMCPCommandsImpl.cpp b/protocol/amcp/AMCPCommandsImpl.cpp index 9297e03f0..0512c563b 100644 --- a/protocol/amcp/AMCPCommandsImpl.cpp +++ b/protocol/amcp/AMCPCommandsImpl.cpp @@ -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"; -- 2.39.2