diff --git a/source/filters/filter-blur.cpp b/source/filters/filter-blur.cpp index 42458fb9..a111ddfc 100644 --- a/source/filters/filter-blur.cpp +++ b/source/filters/filter-blur.cpp @@ -81,26 +81,26 @@ using namespace streamfx::filter::blur; static constexpr std::string_view HELP_URL = "https://github.com/Xaymar/obs-StreamFX/wiki/Filter-Blur"; struct local_blur_type_t { - std::function<::gfx::blur::ifactory&()> fn; - const char* name; + std::function<::streamfx::gfx::blur::ifactory&()> fn; + const char* name; }; struct local_blur_subtype_t { - ::gfx::blur::type type; - const char* name; + ::streamfx::gfx::blur::type type; + const char* name; }; static std::map list_of_types = { - {"box", {&::gfx::blur::box_factory::get, S_BLUR_TYPE_BOX}}, - {"box_linear", {&::gfx::blur::box_linear_factory::get, S_BLUR_TYPE_BOX_LINEAR}}, - {"gaussian", {&::gfx::blur::gaussian_factory::get, S_BLUR_TYPE_GAUSSIAN}}, - {"gaussian_linear", {&::gfx::blur::gaussian_linear_factory::get, S_BLUR_TYPE_GAUSSIAN_LINEAR}}, - {"dual_filtering", {&::gfx::blur::dual_filtering_factory::get, S_BLUR_TYPE_DUALFILTERING}}, + {"box", {&::streamfx::gfx::blur::box_factory::get, S_BLUR_TYPE_BOX}}, + {"box_linear", {&::streamfx::gfx::blur::box_linear_factory::get, S_BLUR_TYPE_BOX_LINEAR}}, + {"gaussian", {&::streamfx::gfx::blur::gaussian_factory::get, S_BLUR_TYPE_GAUSSIAN}}, + {"gaussian_linear", {&::streamfx::gfx::blur::gaussian_linear_factory::get, S_BLUR_TYPE_GAUSSIAN_LINEAR}}, + {"dual_filtering", {&::streamfx::gfx::blur::dual_filtering_factory::get, S_BLUR_TYPE_DUALFILTERING}}, }; static std::map list_of_subtypes = { - {"area", {::gfx::blur::type::Area, S_BLUR_SUBTYPE_AREA}}, - {"directional", {::gfx::blur::type::Directional, S_BLUR_SUBTYPE_DIRECTIONAL}}, - {"rotational", {::gfx::blur::type::Rotational, S_BLUR_SUBTYPE_ROTATIONAL}}, - {"zoom", {::gfx::blur::type::Zoom, S_BLUR_SUBTYPE_ZOOM}}, + {"area", {::streamfx::gfx::blur::type::Area, S_BLUR_SUBTYPE_AREA}}, + {"directional", {::streamfx::gfx::blur::type::Directional, S_BLUR_SUBTYPE_DIRECTIONAL}}, + {"rotational", {::streamfx::gfx::blur::type::Rotational, S_BLUR_SUBTYPE_ROTATIONAL}}, + {"zoom", {::streamfx::gfx::blur::type::Zoom, S_BLUR_SUBTYPE_ZOOM}}, }; blur_instance::blur_instance(obs_data_t* settings, obs_source_t* self) @@ -313,13 +313,14 @@ void blur_instance::video_tick(float) } else { _blur->set_step_scale(1.0, 1.0); } - if ((_blur->get_type() == ::gfx::blur::type::Directional) - || (_blur->get_type() == ::gfx::blur::type::Rotational)) { - auto obj = std::dynamic_pointer_cast<::gfx::blur::base_angle>(_blur); + if ((_blur->get_type() == ::streamfx::gfx::blur::type::Directional) + || (_blur->get_type() == ::streamfx::gfx::blur::type::Rotational)) { + auto obj = std::dynamic_pointer_cast<::streamfx::gfx::blur::base_angle>(_blur); obj->set_angle(_blur_angle); } - if ((_blur->get_type() == ::gfx::blur::type::Zoom) || (_blur->get_type() == ::gfx::blur::type::Rotational)) { - auto obj = std::dynamic_pointer_cast<::gfx::blur::base_center>(_blur); + if ((_blur->get_type() == ::streamfx::gfx::blur::type::Zoom) + || (_blur->get_type() == ::streamfx::gfx::blur::type::Rotational)) { + auto obj = std::dynamic_pointer_cast<::streamfx::gfx::blur::base_center>(_blur); obj->set_center(_blur_center.first, _blur_center.second); } } @@ -338,7 +339,7 @@ void blur_instance::video_tick(float) } else if (_mask.type == mask_type::Source) { if (_mask.source.name_old != _mask.source.name) { try { - _mask.source.source_texture = std::make_shared(_mask.source.name, _self); + _mask.source.source_texture = std::make_shared(_mask.source.name, _self); _mask.source.is_scene = (obs_scene_from_source(_mask.source.source_texture->get_object()) != nullptr); _mask.source.name_old = _mask.source.name; } catch (...) { @@ -672,10 +673,10 @@ try { // Blur Sub-Type { - bool has_angle_support = (subtype_found->second.type == ::gfx::blur::type::Directional) - || (subtype_found->second.type == ::gfx::blur::type::Rotational); - bool has_center_support = (subtype_found->second.type == ::gfx::blur::type::Rotational) - || (subtype_found->second.type == ::gfx::blur::type::Zoom); + bool has_angle_support = (subtype_found->second.type == ::streamfx::gfx::blur::type::Directional) + || (subtype_found->second.type == ::streamfx::gfx::blur::type::Rotational); + bool has_center_support = (subtype_found->second.type == ::streamfx::gfx::blur::type::Rotational) + || (subtype_found->second.type == ::streamfx::gfx::blur::type::Zoom); bool has_stepscale_support = type_found->second.fn().is_step_scale_supported(subtype_found->second.type); bool show_scaling = obs_data_get_bool(settings, ST_STEPSCALE) && has_stepscale_support; @@ -711,7 +712,7 @@ try { } { // Masking - using namespace ::gfx::blur; + using namespace ::streamfx::gfx::blur; bool show_mask = obs_data_get_bool(settings, ST_MASK); mask_type mtype = static_cast(obs_data_get_int(settings, ST_MASK_TYPE)); bool show_region = (mtype == mask_type::Region) && show_mask; diff --git a/source/filters/filter-blur.hpp b/source/filters/filter-blur.hpp index 8c6770e8..da5bdeec 100644 --- a/source/filters/filter-blur.hpp +++ b/source/filters/filter-blur.hpp @@ -53,12 +53,12 @@ namespace streamfx::filter::blur { bool _output_rendered; // Blur - std::shared_ptr<::gfx::blur::base> _blur; - double_t _blur_size; - double_t _blur_angle; - std::pair _blur_center; - bool _blur_step_scaling; - std::pair _blur_step_scale; + std::shared_ptr<::streamfx::gfx::blur::base> _blur; + double_t _blur_size; + double_t _blur_angle; + std::pair _blur_center; + bool _blur_step_scaling; + std::pair _blur_step_scale; // Masking struct { @@ -79,11 +79,11 @@ namespace streamfx::filter::blur { std::shared_ptr texture; } image; struct { - std::string name_old; - std::string name; - bool is_scene; - std::shared_ptr source_texture; - std::shared_ptr texture; + std::string name_old; + std::string name; + bool is_scene; + std::shared_ptr source_texture; + std::shared_ptr texture; } source; struct { float_t r; diff --git a/source/filters/filter-color-grade.cpp b/source/filters/filter-color-grade.cpp index 49ab6b14..eefbc3ea 100644 --- a/source/filters/filter-color-grade.cpp +++ b/source/filters/filter-color-grade.cpp @@ -110,7 +110,7 @@ static constexpr std::string_view HELP_URL = "https://github.com/Xaymar/obs-Stre // TODO: Figure out a way to merge _lut_rt, _lut_texture, _rt_source, _rt_grad, _tex_source, _tex_grade, _source_updated and _grade_updated. // Seriously this is too much GPU space wasted on unused trash. -#define LOCAL_PREFIX " " +#define ST_PREFIX " " color_grade_instance::~color_grade_instance() {} @@ -127,25 +127,24 @@ color_grade_instance::color_grade_instance(obs_data_t* data, obs_source_t* self) // Load the color grading effect. auto path = streamfx::data_file_path("effects/color-grade.effect"); if (!std::filesystem::exists(path)) { - DLOG_ERROR(LOCAL_PREFIX "Failed to locate effect file '%s'.", path.u8string().c_str()); + DLOG_ERROR(ST_PREFIX "Failed to locate effect file '%s'.", path.u8string().c_str()); throw std::runtime_error("Failed to load color grade effect."); } else { try { _effect = streamfx::obs::gs::effect::create(path.u8string()); } catch (std::exception const& ex) { - DLOG_ERROR(LOCAL_PREFIX "Failed to load effect '%s': %s", path.u8string().c_str(), ex.what()); + DLOG_ERROR(ST_PREFIX "Failed to load effect '%s': %s", path.u8string().c_str(), ex.what()); throw; } } // Initialize LUT work flow. try { - _lut_producer = std::make_shared(); - _lut_consumer = std::make_shared(); + _lut_producer = std::make_shared(); + _lut_consumer = std::make_shared(); _lut_initialized = true; } catch (std::exception const& ex) { - DLOG_WARNING(LOCAL_PREFIX "Failed to initialize LUT rendering, falling back to direct rendering.\n%s", - ex.what()); + DLOG_WARNING(ST_PREFIX "Failed to initialize LUT rendering, falling back to direct rendering.\n%s", ex.what()); _lut_initialized = false; } @@ -153,7 +152,7 @@ color_grade_instance::color_grade_instance(obs_data_t* data, obs_source_t* self) try { allocate_rendertarget(GS_RGBA); } catch (std::exception const& ex) { - DLOG_ERROR(LOCAL_PREFIX "Failed to acquire render target for rendering: %s", ex.what()); + DLOG_ERROR(ST_PREFIX "Failed to acquire render target for rendering: %s", ex.what()); throw; } @@ -223,9 +222,9 @@ void color_grade_instance::update(obs_data_t* data) _lut_enabled = v != 0; // 0 (Direct) if (v == -1) { - _lut_depth = gfx::lut::color_depth::_8; + _lut_depth = streamfx::gfx::lut::color_depth::_8; } else if (v > 0) { - _lut_depth = static_cast(v); + _lut_depth = static_cast(v); } } @@ -488,7 +487,7 @@ void color_grade_instance::video_render(gs_effect_t* shader) _lut_rt.reset(); _lut_texture.reset(); _lut_enabled = false; - DLOG_WARNING(LOCAL_PREFIX "Reverting to direct rendering due to error: %s", ex.what()); + DLOG_WARNING(ST_PREFIX "Reverting to direct rendering due to error: %s", ex.what()); } } if ((!_lut_initialized || !_lut_enabled) && !_cache_fresh) { @@ -852,10 +851,10 @@ obs_properties_t* color_grade_factory::get_properties2(color_grade_instance* dat std::pair els[] = { {S_STATE_AUTOMATIC, -1}, {ST_I18N_RENDERMODE_DIRECT, 0}, - {ST_I18N_RENDERMODE_LUT_2BIT, static_cast(gfx::lut::color_depth::_2)}, - {ST_I18N_RENDERMODE_LUT_4BIT, static_cast(gfx::lut::color_depth::_4)}, - {ST_I18N_RENDERMODE_LUT_6BIT, static_cast(gfx::lut::color_depth::_6)}, - {ST_I18N_RENDERMODE_LUT_8BIT, static_cast(gfx::lut::color_depth::_8)}, + {ST_I18N_RENDERMODE_LUT_2BIT, static_cast(streamfx::gfx::lut::color_depth::_2)}, + {ST_I18N_RENDERMODE_LUT_4BIT, static_cast(streamfx::gfx::lut::color_depth::_4)}, + {ST_I18N_RENDERMODE_LUT_6BIT, static_cast(streamfx::gfx::lut::color_depth::_6)}, + {ST_I18N_RENDERMODE_LUT_8BIT, static_cast(streamfx::gfx::lut::color_depth::_8)}, //{ST_RENDERMODE_LUT_10BIT, static_cast(gfx::lut::color_depth::_10)}, }; for (auto kv : els) { diff --git a/source/filters/filter-color-grade.hpp b/source/filters/filter-color-grade.hpp index 0ef3e488..a9b1c4f1 100644 --- a/source/filters/filter-color-grade.hpp +++ b/source/filters/filter-color-grade.hpp @@ -48,19 +48,19 @@ namespace streamfx::filter::color_grade { streamfx::obs::gs::effect _effect; // User Configuration - vec4 _lift; - vec4 _gamma; - vec4 _gain; - vec4 _offset; - detection_mode _tint_detection; - luma_mode _tint_luma; - float_t _tint_exponent; - vec3 _tint_low; - vec3 _tint_mid; - vec3 _tint_hig; - vec4 _correction; - bool _lut_enabled; - gfx::lut::color_depth _lut_depth; + vec4 _lift; + vec4 _gamma; + vec4 _gain; + vec4 _offset; + detection_mode _tint_detection; + luma_mode _tint_luma; + float_t _tint_exponent; + vec3 _tint_low; + vec3 _tint_mid; + vec3 _tint_hig; + vec4 _correction; + bool _lut_enabled; + streamfx::gfx::lut::color_depth _lut_depth; // Capture Cache std::shared_ptr _ccache_rt; @@ -70,8 +70,8 @@ namespace streamfx::filter::color_grade { // LUT work flow bool _lut_initialized; bool _lut_dirty; - std::shared_ptr _lut_producer; - std::shared_ptr _lut_consumer; + std::shared_ptr _lut_producer; + std::shared_ptr _lut_consumer; std::shared_ptr _lut_rt; std::shared_ptr _lut_texture; diff --git a/source/filters/filter-dynamic-mask.cpp b/source/filters/filter-dynamic-mask.cpp index fbed8039..a0899174 100644 --- a/source/filters/filter-dynamic-mask.cpp +++ b/source/filters/filter-dynamic-mask.cpp @@ -84,7 +84,7 @@ void dynamic_mask_instance::update(obs_data_t* settings) try { auto input = std::make_shared(obs_data_get_string(settings, ST_INPUT)); auto gctx = streamfx::obs::gs::context(); - auto capture = std::make_shared(input, _self); + auto capture = std::make_shared(input, _self); input->events.rename += std::bind(&dynamic_mask_instance::input_renamed, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); diff --git a/source/filters/filter-dynamic-mask.hpp b/source/filters/filter-dynamic-mask.hpp index 34654fd5..a3178788 100644 --- a/source/filters/filter-dynamic-mask.hpp +++ b/source/filters/filter-dynamic-mask.hpp @@ -40,12 +40,12 @@ namespace streamfx::filter::dynamic_mask { std::shared_ptr _filter_rt; std::shared_ptr _filter_texture; - bool _have_input_texture; - std::shared_ptr _input; - std::shared_ptr _input_capture; - std::shared_ptr _input_texture; - std::shared_ptr _input_vs; - std::shared_ptr _input_ac; + bool _have_input_texture; + std::shared_ptr _input; + std::shared_ptr _input_capture; + std::shared_ptr _input_texture; + std::shared_ptr _input_vs; + std::shared_ptr _input_ac; bool _have_final_texture; std::shared_ptr _final_rt; diff --git a/source/filters/filter-shader.cpp b/source/filters/filter-shader.cpp index 90b2583c..47ea952b 100644 --- a/source/filters/filter-shader.cpp +++ b/source/filters/filter-shader.cpp @@ -31,7 +31,7 @@ static constexpr std::string_view HELP_URL = shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self) { - _fx = std::make_shared(self, gfx::shader::shader_mode::Filter); + _fx = std::make_shared(self, streamfx::gfx::shader::shader_mode::Filter); _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); update(data); @@ -168,7 +168,7 @@ const char* shader_factory::get_name() void shader_factory::get_defaults2(obs_data_t* data) { - gfx::shader::shader::defaults(data); + streamfx::gfx::shader::shader::defaults(data); } obs_properties_t* shader_factory::get_properties2(shader::shader_instance* data) diff --git a/source/filters/filter-shader.hpp b/source/filters/filter-shader.hpp index 2520616e..cc298668 100644 --- a/source/filters/filter-shader.hpp +++ b/source/filters/filter-shader.hpp @@ -25,7 +25,7 @@ namespace streamfx::filter::shader { class shader_instance : public obs::source_instance { - std::shared_ptr _fx; + std::shared_ptr _fx; std::shared_ptr _rt; public: diff --git a/source/gfx/blur/gfx-blur-base.cpp b/source/gfx/blur/gfx-blur-base.cpp index c12f0d56..ca0dcd99 100644 --- a/source/gfx/blur/gfx-blur-base.cpp +++ b/source/gfx/blur/gfx-blur-base.cpp @@ -18,48 +18,48 @@ #include "gfx-blur-base.hpp" #include -void gfx::blur::base::set_step_scale_x(double_t v) +void streamfx::gfx::blur::base::set_step_scale_x(double_t v) { this->set_step_scale(v, this->get_step_scale_y()); } -void gfx::blur::base::set_step_scale_y(double_t v) +void streamfx::gfx::blur::base::set_step_scale_y(double_t v) { this->set_step_scale(this->get_step_scale_x(), v); } -double_t gfx::blur::base::get_step_scale_x() +double_t streamfx::gfx::blur::base::get_step_scale_x() { double_t x, y; this->get_step_scale(x, y); return x; } -double_t gfx::blur::base::get_step_scale_y() +double_t streamfx::gfx::blur::base::get_step_scale_y() { double_t x, y; this->get_step_scale(x, y); return y; } -void gfx::blur::base_center::set_center_x(double_t v) +void streamfx::gfx::blur::base_center::set_center_x(double_t v) { this->set_center(v, this->get_center_y()); } -void gfx::blur::base_center::set_center_y(double_t v) +void streamfx::gfx::blur::base_center::set_center_y(double_t v) { this->set_center(this->get_center_x(), v); } -double_t gfx::blur::base_center::get_center_x() +double_t streamfx::gfx::blur::base_center::get_center_x() { double_t x, y; this->get_center(x, y); return x; } -double_t gfx::blur::base_center::get_center_y() +double_t streamfx::gfx::blur::base_center::get_center_y() { double_t x, y; this->get_center(x, y); diff --git a/source/gfx/blur/gfx-blur-base.hpp b/source/gfx/blur/gfx-blur-base.hpp index d9969d41..69b8fa89 100644 --- a/source/gfx/blur/gfx-blur-base.hpp +++ b/source/gfx/blur/gfx-blur-base.hpp @@ -19,7 +19,7 @@ #include "common.hpp" #include "obs/gs/gs-texture.hpp" -namespace gfx { +namespace streamfx::gfx { namespace blur { enum class type : int64_t { Invalid = -1, @@ -35,7 +35,7 @@ namespace gfx { virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) = 0; - virtual ::gfx::blur::type get_type() = 0; + virtual ::streamfx::gfx::blur::type get_type() = 0; virtual double_t get_size() = 0; @@ -88,35 +88,35 @@ namespace gfx { public: virtual ~ifactory() {} - virtual bool is_type_supported(::gfx::blur::type type) = 0; + virtual bool is_type_supported(::streamfx::gfx::blur::type type) = 0; - virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) = 0; + virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_min_size(::gfx::blur::type type) = 0; + virtual double_t get_min_size(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_step_size(::gfx::blur::type type) = 0; + virtual double_t get_step_size(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_max_size(::gfx::blur::type type) = 0; + virtual double_t get_max_size(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_min_angle(::gfx::blur::type type) = 0; + virtual double_t get_min_angle(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_step_angle(::gfx::blur::type type) = 0; + virtual double_t get_step_angle(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_max_angle(::gfx::blur::type type) = 0; + virtual double_t get_max_angle(::streamfx::gfx::blur::type type) = 0; - virtual bool is_step_scale_supported(::gfx::blur::type type) = 0; + virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_min_step_scale_x(::gfx::blur::type type) = 0; + virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_step_step_scale_x(::gfx::blur::type type) = 0; + virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_max_step_scale_x(::gfx::blur::type type) = 0; + virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_min_step_scale_y(::gfx::blur::type type) = 0; + virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_step_step_scale_y(::gfx::blur::type type) = 0; + virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) = 0; - virtual double_t get_max_step_scale_y(::gfx::blur::type type) = 0; + virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) = 0; }; } // namespace blur -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/blur/gfx-blur-box-linear.cpp b/source/gfx/blur/gfx-blur-box-linear.cpp index 91a7d1ab..e19047a8 100644 --- a/source/gfx/blur/gfx-blur-box-linear.cpp +++ b/source/gfx/blur/gfx-blur-box-linear.cpp @@ -32,9 +32,9 @@ #pragma warning(pop) #endif -#define MAX_BLUR_SIZE 128 // Also change this in box-linear.effect if modified. +#define ST_MAX_BLUR_SIZE 128 // Also change this in box-linear.effect if modified. -gfx::blur::box_linear_data::box_linear_data() +streamfx::gfx::blur::box_linear_data::box_linear_data() { auto gctx = streamfx::obs::gs::context(); try { @@ -45,203 +45,204 @@ gfx::blur::box_linear_data::box_linear_data() } } -gfx::blur::box_linear_data::~box_linear_data() +streamfx::gfx::blur::box_linear_data::~box_linear_data() { auto gctx = streamfx::obs::gs::context(); _effect.reset(); } -streamfx::obs::gs::effect gfx::blur::box_linear_data::get_effect() +streamfx::obs::gs::effect streamfx::gfx::blur::box_linear_data::get_effect() { return _effect; } -gfx::blur::box_linear_factory::box_linear_factory() {} +streamfx::gfx::blur::box_linear_factory::box_linear_factory() {} -gfx::blur::box_linear_factory::~box_linear_factory() {} +streamfx::gfx::blur::box_linear_factory::~box_linear_factory() {} -bool gfx::blur::box_linear_factory::is_type_supported(::gfx::blur::type type) +bool streamfx::gfx::blur::box_linear_factory::is_type_supported(::streamfx::gfx::blur::type type) { switch (type) { - case ::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Area: return true; - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Directional: return true; default: return false; } } -std::shared_ptr<::gfx::blur::base> gfx::blur::box_linear_factory::create(::gfx::blur::type type) +std::shared_ptr<::streamfx::gfx::blur::base> + streamfx::gfx::blur::box_linear_factory::create(::streamfx::gfx::blur::type type) { switch (type) { - case ::gfx::blur::type::Area: - return std::make_shared<::gfx::blur::box_linear>(); - case ::gfx::blur::type::Directional: - return std::make_shared<::gfx::blur::box_linear_directional>(); + case ::streamfx::gfx::blur::type::Area: + return std::make_shared<::streamfx::gfx::blur::box_linear>(); + case ::streamfx::gfx::blur::type::Directional: + return std::make_shared<::streamfx::gfx::blur::box_linear_directional>(); default: throw std::runtime_error("Invalid type."); } } -double_t gfx::blur::box_linear_factory::get_min_size(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_min_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::box_linear_factory::get_step_size(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_step_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::box_linear_factory::get_max_size(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_max_size(::streamfx::gfx::blur::type) { - return double_t(MAX_BLUR_SIZE); + return double_t(ST_MAX_BLUR_SIZE); } -double_t gfx::blur::box_linear_factory::get_min_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::box_linear_factory::get_min_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return -180.0; default: return 0; } } -double_t gfx::blur::box_linear_factory::get_step_angle(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_step_angle(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_linear_factory::get_max_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::box_linear_factory::get_max_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return 180.0; default: return 0; } } -bool gfx::blur::box_linear_factory::is_step_scale_supported(::gfx::blur::type v) +bool streamfx::gfx::blur::box_linear_factory::is_step_scale_supported(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: - case ::gfx::blur::type::Zoom: - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Zoom: + case ::streamfx::gfx::blur::type::Directional: return true; default: return false; } } -double_t gfx::blur::box_linear_factory::get_min_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_min_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_linear_factory::get_step_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_step_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_linear_factory::get_max_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_max_step_scale_x(::streamfx::gfx::blur::type) { return double_t(1000.0); } -double_t gfx::blur::box_linear_factory::get_min_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_min_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_linear_factory::get_step_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_step_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_linear_factory::get_max_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::box_linear_factory::get_max_step_scale_y(::streamfx::gfx::blur::type) { return double_t(1000.0); } -std::shared_ptr<::gfx::blur::box_linear_data> gfx::blur::box_linear_factory::data() +std::shared_ptr<::streamfx::gfx::blur::box_linear_data> streamfx::gfx::blur::box_linear_factory::data() { - std::unique_lock ulock(_data_lock); - std::shared_ptr<::gfx::blur::box_linear_data> data = _data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::streamfx::gfx::blur::box_linear_data> data = _data.lock(); if (!data) { - data = std::make_shared<::gfx::blur::box_linear_data>(); + data = std::make_shared<::streamfx::gfx::blur::box_linear_data>(); _data = data; } return data; } -::gfx::blur::box_linear_factory& gfx::blur::box_linear_factory::get() +::streamfx::gfx::blur::box_linear_factory& streamfx::gfx::blur::box_linear_factory::get() { - static ::gfx::blur::box_linear_factory instance; + static ::streamfx::gfx::blur::box_linear_factory instance; return instance; } -gfx::blur::box_linear::box_linear() - : _data(::gfx::blur::box_linear_factory::get().data()), _size(1.), _step_scale({1., 1.}) +streamfx::gfx::blur::box_linear::box_linear() + : _data(::streamfx::gfx::blur::box_linear_factory::get().data()), _size(1.), _step_scale({1., 1.}) { _rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); _rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); } -gfx::blur::box_linear::~box_linear() {} +streamfx::gfx::blur::box_linear::~box_linear() {} -void gfx::blur::box_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) +void streamfx::gfx::blur::box_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) { _input_texture = texture; } -::gfx::blur::type gfx::blur::box_linear::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::box_linear::get_type() { - return ::gfx::blur::type::Area; + return ::streamfx::gfx::blur::type::Area; } -double_t gfx::blur::box_linear::get_size() +double_t streamfx::gfx::blur::box_linear::get_size() { return _size; } -void gfx::blur::box_linear::set_size(double_t width) +void streamfx::gfx::blur::box_linear::set_size(double_t width) { _size = width; if (_size < 1.0) { _size = 1.0; } - if (_size > MAX_BLUR_SIZE) { - _size = MAX_BLUR_SIZE; + if (_size > ST_MAX_BLUR_SIZE) { + _size = ST_MAX_BLUR_SIZE; } } -void gfx::blur::box_linear::set_step_scale(double_t x, double_t y) +void streamfx::gfx::blur::box_linear::set_step_scale(double_t x, double_t y) { _step_scale = {x, y}; } -void gfx::blur::box_linear::get_step_scale(double_t& x, double_t& y) +void streamfx::gfx::blur::box_linear::get_step_scale(double_t& x, double_t& y) { x = _step_scale.first; y = _step_scale.second; } -double_t gfx::blur::box_linear::get_step_scale_x() +double_t streamfx::gfx::blur::box_linear::get_step_scale_x() { return _step_scale.first; } -double_t gfx::blur::box_linear::get_step_scale_y() +double_t streamfx::gfx::blur::box_linear::get_step_scale_y() { return _step_scale.second; } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear::render() { auto gctx = streamfx::obs::gs::context(); @@ -309,29 +310,29 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::render() return _rendertarget->get_texture(); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::get() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear::get() { return _rendertarget->get_texture(); } -gfx::blur::box_linear_directional::box_linear_directional() : _angle(0) {} +streamfx::gfx::blur::box_linear_directional::box_linear_directional() : _angle(0) {} -::gfx::blur::type gfx::blur::box_linear_directional::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::box_linear_directional::get_type() { - return ::gfx::blur::type::Directional; + return ::streamfx::gfx::blur::type::Directional; } -double_t gfx::blur::box_linear_directional::get_angle() +double_t streamfx::gfx::blur::box_linear_directional::get_angle() { return D_RAD_TO_DEG(_angle); } -void gfx::blur::box_linear_directional::set_angle(double_t angle) +void streamfx::gfx::blur::box_linear_directional::set_angle(double_t angle) { _angle = D_DEG_TO_RAD(angle); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear_directional::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear_directional::render() { auto gctx = streamfx::obs::gs::context(); diff --git a/source/gfx/blur/gfx-blur-box-linear.hpp b/source/gfx/blur/gfx-blur-box-linear.hpp index 91adc3b1..5f6df0f0 100644 --- a/source/gfx/blur/gfx-blur-box-linear.hpp +++ b/source/gfx/blur/gfx-blur-box-linear.hpp @@ -23,7 +23,7 @@ #include "obs/gs/gs-rendertarget.hpp" #include "obs/gs/gs-texture.hpp" -namespace gfx { +namespace streamfx::gfx { namespace blur { class box_linear_data { streamfx::obs::gs::effect _effect; @@ -35,53 +35,53 @@ namespace gfx { streamfx::obs::gs::effect get_effect(); }; - class box_linear_factory : public ::gfx::blur::ifactory { - std::mutex _data_lock; - std::weak_ptr<::gfx::blur::box_linear_data> _data; + class box_linear_factory : public ::streamfx::gfx::blur::ifactory { + std::mutex _data_lock; + std::weak_ptr<::streamfx::gfx::blur::box_linear_data> _data; public: box_linear_factory(); virtual ~box_linear_factory() override; - virtual bool is_type_supported(::gfx::blur::type type) override; + virtual bool is_type_supported(::streamfx::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_size(::gfx::blur::type type) override; + virtual double_t get_min_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_size(::gfx::blur::type type) override; + virtual double_t get_step_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_size(::gfx::blur::type type) override; + virtual double_t get_max_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_angle(::gfx::blur::type type) override; + virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_angle(::gfx::blur::type type) override; + virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_angle(::gfx::blur::type type) override; + virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override; - virtual bool is_step_scale_supported(::gfx::blur::type type) override; + virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override; - std::shared_ptr<::gfx::blur::box_linear_data> data(); + std::shared_ptr<::streamfx::gfx::blur::box_linear_data> data(); public: // Singleton - static ::gfx::blur::box_linear_factory& get(); + static ::streamfx::gfx::blur::box_linear_factory& get(); }; - class box_linear : public ::gfx::blur::base { + class box_linear : public ::streamfx::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::box_linear_data> _data; + std::shared_ptr<::streamfx::gfx::blur::box_linear_data> _data; double_t _size; std::pair _step_scale; @@ -97,7 +97,7 @@ namespace gfx { virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override; - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_size() override; virtual void set_size(double_t width) override; @@ -111,13 +111,14 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override; }; - class box_linear_directional : public ::gfx::blur::box_linear, public ::gfx::blur::base_angle { + class box_linear_directional : public ::streamfx::gfx::blur::box_linear, + public ::streamfx::gfx::blur::base_angle { double_t _angle; public: box_linear_directional(); - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_angle() override; virtual void set_angle(double_t angle) override; @@ -125,4 +126,4 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; } // namespace blur -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/blur/gfx-blur-box.cpp b/source/gfx/blur/gfx-blur-box.cpp index 74dbb902..979267d9 100644 --- a/source/gfx/blur/gfx-blur-box.cpp +++ b/source/gfx/blur/gfx-blur-box.cpp @@ -32,9 +32,9 @@ #pragma warning(pop) #endif -#define MAX_BLUR_SIZE 128 // Also change this in box.effect if modified. +#define ST_MAX_BLUR_SIZE 128 // Also change this in box.effect if modified. -gfx::blur::box_data::box_data() +streamfx::gfx::blur::box_data::box_data() { auto gctx = streamfx::obs::gs::context(); try { @@ -44,211 +44,213 @@ gfx::blur::box_data::box_data() } } -gfx::blur::box_data::~box_data() +streamfx::gfx::blur::box_data::~box_data() { auto gctx = streamfx::obs::gs::context(); _effect.reset(); } -streamfx::obs::gs::effect gfx::blur::box_data::get_effect() +streamfx::obs::gs::effect streamfx::gfx::blur::box_data::get_effect() { return _effect; } -gfx::blur::box_factory::box_factory() {} +streamfx::gfx::blur::box_factory::box_factory() {} -gfx::blur::box_factory::~box_factory() {} +streamfx::gfx::blur::box_factory::~box_factory() {} -bool gfx::blur::box_factory::is_type_supported(::gfx::blur::type type) +bool streamfx::gfx::blur::box_factory::is_type_supported(::streamfx::gfx::blur::type type) { switch (type) { - case ::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Area: return true; - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Directional: return true; - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Rotational: return true; - case ::gfx::blur::type::Zoom: + case ::streamfx::gfx::blur::type::Zoom: return true; default: return false; } } -std::shared_ptr<::gfx::blur::base> gfx::blur::box_factory::create(::gfx::blur::type type) +std::shared_ptr<::streamfx::gfx::blur::base> streamfx::gfx::blur::box_factory::create(::streamfx::gfx::blur::type type) { switch (type) { - case ::gfx::blur::type::Area: - return std::make_shared<::gfx::blur::box>(); - case ::gfx::blur::type::Directional: - return std::static_pointer_cast<::gfx::blur::box>(std::make_shared<::gfx::blur::box_directional>()); - case ::gfx::blur::type::Rotational: - return std::make_shared<::gfx::blur::box_rotational>(); - case ::gfx::blur::type::Zoom: - return std::make_shared<::gfx::blur::box_zoom>(); + case ::streamfx::gfx::blur::type::Area: + return std::make_shared<::streamfx::gfx::blur::box>(); + case ::streamfx::gfx::blur::type::Directional: + return std::static_pointer_cast<::streamfx::gfx::blur::box>( + std::make_shared<::streamfx::gfx::blur::box_directional>()); + case ::streamfx::gfx::blur::type::Rotational: + return std::make_shared<::streamfx::gfx::blur::box_rotational>(); + case ::streamfx::gfx::blur::type::Zoom: + return std::make_shared<::streamfx::gfx::blur::box_zoom>(); default: throw std::runtime_error("Invalid type."); } } -double_t gfx::blur::box_factory::get_min_size(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_min_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::box_factory::get_step_size(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_step_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::box_factory::get_max_size(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_max_size(::streamfx::gfx::blur::type) { - return double_t(MAX_BLUR_SIZE); + return double_t(ST_MAX_BLUR_SIZE); } -double_t gfx::blur::box_factory::get_min_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::box_factory::get_min_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return -180.0; default: return 0; } } -double_t gfx::blur::box_factory::get_step_angle(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_step_angle(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_factory::get_max_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::box_factory::get_max_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return 180.0; default: return 0; } } -bool gfx::blur::box_factory::is_step_scale_supported(::gfx::blur::type v) +bool streamfx::gfx::blur::box_factory::is_step_scale_supported(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: - case ::gfx::blur::type::Zoom: - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Zoom: + case ::streamfx::gfx::blur::type::Directional: return true; default: return false; } } -double_t gfx::blur::box_factory::get_min_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_min_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_factory::get_step_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_step_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_factory::get_max_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_max_step_scale_x(::streamfx::gfx::blur::type) { return double_t(1000.0); } -double_t gfx::blur::box_factory::get_min_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_min_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_factory::get_step_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_step_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::box_factory::get_max_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::box_factory::get_max_step_scale_y(::streamfx::gfx::blur::type) { return double_t(1000.0); } -std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data() +std::shared_ptr<::streamfx::gfx::blur::box_data> streamfx::gfx::blur::box_factory::data() { - std::unique_lock ulock(_data_lock); - std::shared_ptr<::gfx::blur::box_data> data = _data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::streamfx::gfx::blur::box_data> data = _data.lock(); if (!data) { - data = std::make_shared<::gfx::blur::box_data>(); + data = std::make_shared<::streamfx::gfx::blur::box_data>(); _data = data; } return data; } -::gfx::blur::box_factory& gfx::blur::box_factory::get() +::streamfx::gfx::blur::box_factory& streamfx::gfx::blur::box_factory::get() { - static ::gfx::blur::box_factory instance; + static ::streamfx::gfx::blur::box_factory instance; return instance; } -gfx::blur::box::box() : _data(::gfx::blur::box_factory::get().data()), _size(1.), _step_scale({1., 1.}) +streamfx::gfx::blur::box::box() + : _data(::streamfx::gfx::blur::box_factory::get().data()), _size(1.), _step_scale({1., 1.}) { auto gctx = streamfx::obs::gs::context(); _rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); _rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); } -gfx::blur::box::~box() {} +streamfx::gfx::blur::box::~box() {} -void gfx::blur::box::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) +void streamfx::gfx::blur::box::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) { _input_texture = texture; } -::gfx::blur::type gfx::blur::box::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::box::get_type() { - return ::gfx::blur::type::Area; + return ::streamfx::gfx::blur::type::Area; } -double_t gfx::blur::box::get_size() +double_t streamfx::gfx::blur::box::get_size() { return _size; } -void gfx::blur::box::set_size(double_t width) +void streamfx::gfx::blur::box::set_size(double_t width) { _size = width; if (_size < 1.0) { _size = 1.0; } - if (_size > MAX_BLUR_SIZE) { - _size = MAX_BLUR_SIZE; + if (_size > ST_MAX_BLUR_SIZE) { + _size = ST_MAX_BLUR_SIZE; } } -void gfx::blur::box::set_step_scale(double_t x, double_t y) +void streamfx::gfx::blur::box::set_step_scale(double_t x, double_t y) { _step_scale = {x, y}; } -void gfx::blur::box::get_step_scale(double_t& x, double_t& y) +void streamfx::gfx::blur::box::get_step_scale(double_t& x, double_t& y) { x = _step_scale.first; y = _step_scale.second; } -double_t gfx::blur::box::get_step_scale_x() +double_t streamfx::gfx::blur::box::get_step_scale_x() { return _step_scale.first; } -double_t gfx::blur::box::get_step_scale_y() +double_t streamfx::gfx::blur::box::get_step_scale_y() { return _step_scale.second; } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box::render() { auto gctx = streamfx::obs::gs::context(); @@ -316,29 +318,29 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::render() return _rendertarget->get_texture(); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::get() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box::get() { return _rendertarget->get_texture(); } -gfx::blur::box_directional::box_directional() : _angle(0) {} +streamfx::gfx::blur::box_directional::box_directional() : _angle(0) {} -::gfx::blur::type gfx::blur::box_directional::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::box_directional::get_type() { - return ::gfx::blur::type::Directional; + return ::streamfx::gfx::blur::type::Directional; } -double_t gfx::blur::box_directional::get_angle() +double_t streamfx::gfx::blur::box_directional::get_angle() { return D_RAD_TO_DEG(_angle); } -void gfx::blur::box_directional::set_angle(double_t angle) +void streamfx::gfx::blur::box_directional::set_angle(double_t angle) { _angle = D_DEG_TO_RAD(angle); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_directional::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_directional::render() { auto gctx = streamfx::obs::gs::context(); @@ -386,34 +388,34 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_directional::render return _rendertarget->get_texture(); } -::gfx::blur::type gfx::blur::box_rotational::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::box_rotational::get_type() { - return ::gfx::blur::type::Rotational; + return ::streamfx::gfx::blur::type::Rotational; } -void gfx::blur::box_rotational::set_center(double_t x, double_t y) +void streamfx::gfx::blur::box_rotational::set_center(double_t x, double_t y) { _center.first = x; _center.second = y; } -void gfx::blur::box_rotational::get_center(double_t& x, double_t& y) +void streamfx::gfx::blur::box_rotational::get_center(double_t& x, double_t& y) { x = _center.first; y = _center.second; } -double_t gfx::blur::box_rotational::get_angle() +double_t streamfx::gfx::blur::box_rotational::get_angle() { return D_RAD_TO_DEG(_angle); } -void gfx::blur::box_rotational::set_angle(double_t angle) +void streamfx::gfx::blur::box_rotational::set_angle(double_t angle) { _angle = D_DEG_TO_RAD(angle); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_rotational::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_rotational::render() { auto gctx = streamfx::obs::gs::context(); @@ -462,24 +464,24 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_rotational::render( return _rendertarget->get_texture(); } -::gfx::blur::type gfx::blur::box_zoom::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::box_zoom::get_type() { - return ::gfx::blur::type::Zoom; + return ::streamfx::gfx::blur::type::Zoom; } -void gfx::blur::box_zoom::set_center(double_t x, double_t y) +void streamfx::gfx::blur::box_zoom::set_center(double_t x, double_t y) { _center.first = x; _center.second = y; } -void gfx::blur::box_zoom::get_center(double_t& x, double_t& y) +void streamfx::gfx::blur::box_zoom::get_center(double_t& x, double_t& y) { x = _center.first; y = _center.second; } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_zoom::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_zoom::render() { auto gctx = streamfx::obs::gs::context(); diff --git a/source/gfx/blur/gfx-blur-box.hpp b/source/gfx/blur/gfx-blur-box.hpp index acd3712c..7316afbc 100644 --- a/source/gfx/blur/gfx-blur-box.hpp +++ b/source/gfx/blur/gfx-blur-box.hpp @@ -23,7 +23,7 @@ #include "obs/gs/gs-rendertarget.hpp" #include "obs/gs/gs-texture.hpp" -namespace gfx { +namespace streamfx::gfx { namespace blur { class box_data { streamfx::obs::gs::effect _effect; @@ -35,53 +35,53 @@ namespace gfx { streamfx::obs::gs::effect get_effect(); }; - class box_factory : public ::gfx::blur::ifactory { - std::mutex _data_lock; - std::weak_ptr<::gfx::blur::box_data> _data; + class box_factory : public ::streamfx::gfx::blur::ifactory { + std::mutex _data_lock; + std::weak_ptr<::streamfx::gfx::blur::box_data> _data; public: box_factory(); virtual ~box_factory() override; - virtual bool is_type_supported(::gfx::blur::type type) override; + virtual bool is_type_supported(::streamfx::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_size(::gfx::blur::type type) override; + virtual double_t get_min_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_size(::gfx::blur::type type) override; + virtual double_t get_step_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_size(::gfx::blur::type type) override; + virtual double_t get_max_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_angle(::gfx::blur::type type) override; + virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_angle(::gfx::blur::type type) override; + virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_angle(::gfx::blur::type type) override; + virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override; - virtual bool is_step_scale_supported(::gfx::blur::type type) override; + virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override; - std::shared_ptr<::gfx::blur::box_data> data(); + std::shared_ptr<::streamfx::gfx::blur::box_data> data(); public: // Singleton - static ::gfx::blur::box_factory& get(); + static ::streamfx::gfx::blur::box_factory& get(); }; - class box : public ::gfx::blur::base { + class box : public ::streamfx::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::box_data> _data; + std::shared_ptr<::streamfx::gfx::blur::box_data> _data; double_t _size; std::pair _step_scale; @@ -97,7 +97,7 @@ namespace gfx { virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override; - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_size() override; virtual void set_size(double_t width) override; @@ -111,13 +111,13 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override; }; - class box_directional : public ::gfx::blur::box, public ::gfx::blur::base_angle { + class box_directional : public ::streamfx::gfx::blur::box, public ::streamfx::gfx::blur::base_angle { double_t _angle; public: box_directional(); - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_angle() override; virtual void set_angle(double_t angle) override; @@ -125,14 +125,14 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; - class box_rotational : public ::gfx::blur::box, - public ::gfx::blur::base_angle, - public ::gfx::blur::base_center { + class box_rotational : public ::streamfx::gfx::blur::box, + public ::streamfx::gfx::blur::base_angle, + public ::streamfx::gfx::blur::base_center { std::pair _center; double_t _angle; public: - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual void set_center(double_t x, double_t y) override; virtual void get_center(double_t& x, double_t& y) override; @@ -143,11 +143,11 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; - class box_zoom : public ::gfx::blur::box, public ::gfx::blur::base_center { + class box_zoom : public ::streamfx::gfx::blur::box, public ::streamfx::gfx::blur::base_center { std::pair _center; public: - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual void set_center(double_t x, double_t y) override; virtual void get_center(double_t& x, double_t& y) override; @@ -155,4 +155,4 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; } // namespace blur -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/blur/gfx-blur-dual-filtering.cpp b/source/gfx/blur/gfx-blur-dual-filtering.cpp index 8359db37..945f91c3 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.cpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.cpp @@ -48,9 +48,9 @@ // 7: 3 Iteration (8x), Arm Size 8, Offset Scale 1.0 // ... -#define MAX_LEVELS 16 +#define ST_MAX_LEVELS 16 -gfx::blur::dual_filtering_data::dual_filtering_data() +streamfx::gfx::blur::dual_filtering_data::dual_filtering_data() { auto gctx = streamfx::obs::gs::context(); try { @@ -61,129 +61,130 @@ gfx::blur::dual_filtering_data::dual_filtering_data() } } -gfx::blur::dual_filtering_data::~dual_filtering_data() +streamfx::gfx::blur::dual_filtering_data::~dual_filtering_data() { auto gctx = streamfx::obs::gs::context(); _effect.reset(); } -streamfx::obs::gs::effect gfx::blur::dual_filtering_data::get_effect() +streamfx::obs::gs::effect streamfx::gfx::blur::dual_filtering_data::get_effect() { return _effect; } -gfx::blur::dual_filtering_factory::dual_filtering_factory() {} +streamfx::gfx::blur::dual_filtering_factory::dual_filtering_factory() {} -gfx::blur::dual_filtering_factory::~dual_filtering_factory() {} +streamfx::gfx::blur::dual_filtering_factory::~dual_filtering_factory() {} -bool gfx::blur::dual_filtering_factory::is_type_supported(::gfx::blur::type type) +bool streamfx::gfx::blur::dual_filtering_factory::is_type_supported(::streamfx::gfx::blur::type type) { switch (type) { - case ::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Area: return true; default: return false; } } -std::shared_ptr<::gfx::blur::base> gfx::blur::dual_filtering_factory::create(::gfx::blur::type type) +std::shared_ptr<::streamfx::gfx::blur::base> + streamfx::gfx::blur::dual_filtering_factory::create(::streamfx::gfx::blur::type type) { switch (type) { - case ::gfx::blur::type::Area: - return std::make_shared<::gfx::blur::dual_filtering>(); + case ::streamfx::gfx::blur::type::Area: + return std::make_shared<::streamfx::gfx::blur::dual_filtering>(); default: throw std::runtime_error("Invalid type."); } } -double_t gfx::blur::dual_filtering_factory::get_min_size(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_min_size(::streamfx::gfx::blur::type) { return double_t(1.); } -double_t gfx::blur::dual_filtering_factory::get_step_size(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_step_size(::streamfx::gfx::blur::type) { return double_t(1.); } -double_t gfx::blur::dual_filtering_factory::get_max_size(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_max_size(::streamfx::gfx::blur::type) { - return double_t(MAX_LEVELS); + return double_t(ST_MAX_LEVELS); } -double_t gfx::blur::dual_filtering_factory::get_min_angle(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_min_angle(::streamfx::gfx::blur::type) { return double_t(0); } -double_t gfx::blur::dual_filtering_factory::get_step_angle(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_step_angle(::streamfx::gfx::blur::type) { return double_t(0); } -double_t gfx::blur::dual_filtering_factory::get_max_angle(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_max_angle(::streamfx::gfx::blur::type) { return double_t(0); } -bool gfx::blur::dual_filtering_factory::is_step_scale_supported(::gfx::blur::type) +bool streamfx::gfx::blur::dual_filtering_factory::is_step_scale_supported(::streamfx::gfx::blur::type) { return false; } -double_t gfx::blur::dual_filtering_factory::get_min_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_min_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0); } -double_t gfx::blur::dual_filtering_factory::get_step_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_step_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0); } -double_t gfx::blur::dual_filtering_factory::get_max_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_max_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0); } -double_t gfx::blur::dual_filtering_factory::get_min_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_min_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0); } -double_t gfx::blur::dual_filtering_factory::get_step_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_step_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0); } -double_t gfx::blur::dual_filtering_factory::get_max_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::dual_filtering_factory::get_max_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0); } -std::shared_ptr<::gfx::blur::dual_filtering_data> gfx::blur::dual_filtering_factory::data() +std::shared_ptr<::streamfx::gfx::blur::dual_filtering_data> streamfx::gfx::blur::dual_filtering_factory::data() { - std::unique_lock ulock(_data_lock); - std::shared_ptr<::gfx::blur::dual_filtering_data> data = _data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::streamfx::gfx::blur::dual_filtering_data> data = _data.lock(); if (!data) { - data = std::make_shared<::gfx::blur::dual_filtering_data>(); + data = std::make_shared<::streamfx::gfx::blur::dual_filtering_data>(); _data = data; } return data; } -::gfx::blur::dual_filtering_factory& gfx::blur::dual_filtering_factory::get() +::streamfx::gfx::blur::dual_filtering_factory& streamfx::gfx::blur::dual_filtering_factory::get() { - static ::gfx::blur::dual_filtering_factory instance; + static ::streamfx::gfx::blur::dual_filtering_factory instance; return instance; } -gfx::blur::dual_filtering::dual_filtering() - : _data(::gfx::blur::dual_filtering_factory::get().data()), _size(0), _size_iterations(0) +streamfx::gfx::blur::dual_filtering::dual_filtering() + : _data(::streamfx::gfx::blur::dual_filtering_factory::get().data()), _size(0), _size_iterations(0) { auto gctx = streamfx::obs::gs::context(); - _rts.resize(MAX_LEVELS + 1); - for (std::size_t n = 0; n <= MAX_LEVELS; n++) { + _rts.resize(ST_MAX_LEVELS + 1); + for (std::size_t n = 0; n <= ST_MAX_LEVELS; n++) { gs_color_format cf = GS_RGBA; #if 0 cf = GS_RGBA16F; @@ -194,37 +195,37 @@ gfx::blur::dual_filtering::dual_filtering() } } -gfx::blur::dual_filtering::~dual_filtering() {} +streamfx::gfx::blur::dual_filtering::~dual_filtering() {} -void gfx::blur::dual_filtering::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) +void streamfx::gfx::blur::dual_filtering::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) { _input_texture = texture; } -::gfx::blur::type gfx::blur::dual_filtering::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::dual_filtering::get_type() { - return ::gfx::blur::type::Area; + return ::streamfx::gfx::blur::type::Area; } -double_t gfx::blur::dual_filtering::get_size() +double_t streamfx::gfx::blur::dual_filtering::get_size() { return _size; } -void gfx::blur::dual_filtering::set_size(double_t width) +void streamfx::gfx::blur::dual_filtering::set_size(double_t width) { _size = width; _size_iterations = size_t(round(width)); - if (_size_iterations >= MAX_LEVELS) { - _size_iterations = MAX_LEVELS; + if (_size_iterations >= ST_MAX_LEVELS) { + _size_iterations = ST_MAX_LEVELS; } } -void gfx::blur::dual_filtering::set_step_scale(double_t, double_t) {} +void streamfx::gfx::blur::dual_filtering::set_step_scale(double_t, double_t) {} -void gfx::blur::dual_filtering::get_step_scale(double_t&, double_t&) {} +void streamfx::gfx::blur::dual_filtering::get_step_scale(double_t&, double_t&) {} -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::dual_filtering::render() { auto gctx = streamfx::obs::gs::context(); @@ -327,7 +328,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::render( return _rts[0]->get_texture(); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::get() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::dual_filtering::get() { return _rts[0]->get_texture(); } diff --git a/source/gfx/blur/gfx-blur-dual-filtering.hpp b/source/gfx/blur/gfx-blur-dual-filtering.hpp index a9ccd39f..70c9dfd6 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.hpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.hpp @@ -24,7 +24,7 @@ #include "obs/gs/gs-rendertarget.hpp" #include "obs/gs/gs-texture.hpp" -namespace gfx { +namespace streamfx::gfx { namespace blur { class dual_filtering_data { streamfx::obs::gs::effect _effect; @@ -36,52 +36,52 @@ namespace gfx { streamfx::obs::gs::effect get_effect(); }; - class dual_filtering_factory : public ::gfx::blur::ifactory { - std::mutex _data_lock; - std::weak_ptr<::gfx::blur::dual_filtering_data> _data; + class dual_filtering_factory : public ::streamfx::gfx::blur::ifactory { + std::mutex _data_lock; + std::weak_ptr<::streamfx::gfx::blur::dual_filtering_data> _data; public: dual_filtering_factory(); virtual ~dual_filtering_factory() override; - virtual bool is_type_supported(::gfx::blur::type type) override; + virtual bool is_type_supported(::streamfx::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_size(::gfx::blur::type type) override; + virtual double_t get_min_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_size(::gfx::blur::type type) override; + virtual double_t get_step_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_size(::gfx::blur::type type) override; + virtual double_t get_max_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_angle(::gfx::blur::type type) override; + virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_angle(::gfx::blur::type type) override; + virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_angle(::gfx::blur::type type) override; + virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override; - virtual bool is_step_scale_supported(::gfx::blur::type type) override; + virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override; - std::shared_ptr<::gfx::blur::dual_filtering_data> data(); + std::shared_ptr<::streamfx::gfx::blur::dual_filtering_data> data(); public: // Singleton - static ::gfx::blur::dual_filtering_factory& get(); + static ::streamfx::gfx::blur::dual_filtering_factory& get(); }; - class dual_filtering : public ::gfx::blur::base { - std::shared_ptr<::gfx::blur::dual_filtering_data> _data; + class dual_filtering : public ::streamfx::gfx::blur::base { + std::shared_ptr<::streamfx::gfx::blur::dual_filtering_data> _data; double_t _size; std::size_t _size_iterations; @@ -96,7 +96,7 @@ namespace gfx { virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override; - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_size() override; @@ -111,4 +111,4 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override; }; } // namespace blur -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.cpp b/source/gfx/blur/gfx-blur-gaussian-linear.cpp index f2597ab6..b1ebc85f 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.cpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.cpp @@ -33,29 +33,29 @@ // function first goes up at the point, and then once we pass the critical point // will go down again and it is not handled well. This is a pretty basic // approximation anyway at the moment. -#define MAX_KERNEL_SIZE 128 -#define MAX_BLUR_SIZE (MAX_KERNEL_SIZE - 1) -#define SEARCH_DENSITY double_t(1. / 500.) -#define SEARCH_THRESHOLD double_t(1. / (MAX_KERNEL_SIZE * 5)) -#define SEARCH_EXTENSION 1 -#define SEARCH_RANGE MAX_KERNEL_SIZE * 2 +#define ST_MAX_KERNEL_SIZE 128 +#define ST_MAX_BLUR_SIZE (ST_MAX_KERNEL_SIZE - 1) +#define ST_SEARCH_DENSITY double_t(1. / 500.) +#define ST_SEARCH_THRESHOLD double_t(1. / (ST_MAX_KERNEL_SIZE * 5)) +#define ST_SEARCH_EXTENSION 1 +#define ST_SEARCH_RANGE ST_MAX_KERNEL_SIZE * 2 -gfx::blur::gaussian_linear_data::gaussian_linear_data() +streamfx::gfx::blur::gaussian_linear_data::gaussian_linear_data() { auto gctx = streamfx::obs::gs::context(); _effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian-linear.effect").u8string()); // Precalculate Kernels - for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) { - std::vector kernel_math(MAX_KERNEL_SIZE); - std::vector kernel_data(MAX_KERNEL_SIZE); + for (std::size_t kernel_size = 1; kernel_size <= ST_MAX_BLUR_SIZE; kernel_size++) { + std::vector kernel_math(ST_MAX_KERNEL_SIZE); + std::vector kernel_data(ST_MAX_KERNEL_SIZE); double_t actual_width = 1.; // Find actual kernel width. - for (double_t h = SEARCH_DENSITY; h < SEARCH_RANGE; h += SEARCH_DENSITY) { - if (streamfx::util::math::gaussian(double_t(kernel_size + SEARCH_EXTENSION), h) - > SEARCH_THRESHOLD) { + for (double_t h = ST_SEARCH_DENSITY; h < ST_SEARCH_RANGE; h += ST_SEARCH_DENSITY) { + if (streamfx::util::math::gaussian(double_t(kernel_size + ST_SEARCH_EXTENSION), h) + > ST_SEARCH_THRESHOLD) { actual_width = h; break; } @@ -78,158 +78,159 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data() } } -gfx::blur::gaussian_linear_data::~gaussian_linear_data() +streamfx::gfx::blur::gaussian_linear_data::~gaussian_linear_data() { _effect.reset(); } -streamfx::obs::gs::effect gfx::blur::gaussian_linear_data::get_effect() +streamfx::obs::gs::effect streamfx::gfx::blur::gaussian_linear_data::get_effect() { return _effect; } -std::vector const& gfx::blur::gaussian_linear_data::get_kernel(std::size_t width) +std::vector const& streamfx::gfx::blur::gaussian_linear_data::get_kernel(std::size_t width) { if (width < 1) width = 1; - if (width > MAX_BLUR_SIZE) - width = MAX_BLUR_SIZE; + if (width > ST_MAX_BLUR_SIZE) + width = ST_MAX_BLUR_SIZE; width -= 1; return _kernels[width]; } -gfx::blur::gaussian_linear_factory::gaussian_linear_factory() {} +streamfx::gfx::blur::gaussian_linear_factory::gaussian_linear_factory() {} -gfx::blur::gaussian_linear_factory::~gaussian_linear_factory() {} +streamfx::gfx::blur::gaussian_linear_factory::~gaussian_linear_factory() {} -bool gfx::blur::gaussian_linear_factory::is_type_supported(::gfx::blur::type v) +bool streamfx::gfx::blur::gaussian_linear_factory::is_type_supported(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Area: return true; - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Directional: return true; default: return false; } } -std::shared_ptr<::gfx::blur::base> gfx::blur::gaussian_linear_factory::create(::gfx::blur::type v) +std::shared_ptr<::streamfx::gfx::blur::base> + streamfx::gfx::blur::gaussian_linear_factory::create(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: - return std::make_shared<::gfx::blur::gaussian_linear>(); - case ::gfx::blur::type::Directional: - return std::static_pointer_cast<::gfx::blur::gaussian_linear>( - std::make_shared<::gfx::blur::gaussian_linear_directional>()); + case ::streamfx::gfx::blur::type::Area: + return std::make_shared<::streamfx::gfx::blur::gaussian_linear>(); + case ::streamfx::gfx::blur::type::Directional: + return std::static_pointer_cast<::streamfx::gfx::blur::gaussian_linear>( + std::make_shared<::streamfx::gfx::blur::gaussian_linear_directional>()); default: throw std::runtime_error("Invalid type."); } } -double_t gfx::blur::gaussian_linear_factory::get_min_size(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::gaussian_linear_factory::get_step_size(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::gaussian_linear_factory::get_max_size(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_size(::streamfx::gfx::blur::type) { - return double_t(MAX_BLUR_SIZE); + return double_t(ST_MAX_BLUR_SIZE); } -double_t gfx::blur::gaussian_linear_factory::get_min_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return -180.0; default: return 0; } } -double_t gfx::blur::gaussian_linear_factory::get_step_angle(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_angle(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_linear_factory::get_max_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return 180.0; default: return 0; } } -bool gfx::blur::gaussian_linear_factory::is_step_scale_supported(::gfx::blur::type v) +bool streamfx::gfx::blur::gaussian_linear_factory::is_step_scale_supported(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: - case ::gfx::blur::type::Zoom: - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Zoom: + case ::streamfx::gfx::blur::type::Directional: return true; default: return false; } } -double_t gfx::blur::gaussian_linear_factory::get_min_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_linear_factory::get_step_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_linear_factory::get_max_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_step_scale_x(::streamfx::gfx::blur::type) { return double_t(1000.0); } -double_t gfx::blur::gaussian_linear_factory::get_min_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_linear_factory::get_step_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_linear_factory::get_max_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_step_scale_y(::streamfx::gfx::blur::type) { return double_t(1000.0); } -std::shared_ptr<::gfx::blur::gaussian_linear_data> gfx::blur::gaussian_linear_factory::data() +std::shared_ptr<::streamfx::gfx::blur::gaussian_linear_data> streamfx::gfx::blur::gaussian_linear_factory::data() { - std::unique_lock ulock(_data_lock); - std::shared_ptr<::gfx::blur::gaussian_linear_data> data = _data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::streamfx::gfx::blur::gaussian_linear_data> data = _data.lock(); if (!data) { - data = std::make_shared<::gfx::blur::gaussian_linear_data>(); + data = std::make_shared<::streamfx::gfx::blur::gaussian_linear_data>(); _data = data; } return data; } -::gfx::blur::gaussian_linear_factory& gfx::blur::gaussian_linear_factory::get() +::streamfx::gfx::blur::gaussian_linear_factory& streamfx::gfx::blur::gaussian_linear_factory::get() { - static ::gfx::blur::gaussian_linear_factory instance; + static ::streamfx::gfx::blur::gaussian_linear_factory instance; return instance; } -gfx::blur::gaussian_linear::gaussian_linear() - : _data(::gfx::blur::gaussian_linear_factory::get().data()), _size(1.), _step_scale({1., 1.}) +streamfx::gfx::blur::gaussian_linear::gaussian_linear() + : _data(::streamfx::gfx::blur::gaussian_linear_factory::get().data()), _size(1.), _step_scale({1., 1.}) { auto gctx = streamfx::obs::gs::context(); @@ -237,55 +238,55 @@ gfx::blur::gaussian_linear::gaussian_linear() _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); } -gfx::blur::gaussian_linear::~gaussian_linear() {} +streamfx::gfx::blur::gaussian_linear::~gaussian_linear() {} -void gfx::blur::gaussian_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) +void streamfx::gfx::blur::gaussian_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) { _input_texture = texture; } -::gfx::blur::type gfx::blur::gaussian_linear::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_linear::get_type() { - return ::gfx::blur::type::Area; + return ::streamfx::gfx::blur::type::Area; } -double_t gfx::blur::gaussian_linear::get_size() +double_t streamfx::gfx::blur::gaussian_linear::get_size() { return _size; } -void gfx::blur::gaussian_linear::set_size(double_t width) +void streamfx::gfx::blur::gaussian_linear::set_size(double_t width) { if (width < 1.) width = 1.; - if (width > MAX_BLUR_SIZE) - width = MAX_BLUR_SIZE; + if (width > ST_MAX_BLUR_SIZE) + width = ST_MAX_BLUR_SIZE; _size = width; } -void gfx::blur::gaussian_linear::set_step_scale(double_t x, double_t y) +void streamfx::gfx::blur::gaussian_linear::set_step_scale(double_t x, double_t y) { _step_scale.first = x; _step_scale.second = y; } -void gfx::blur::gaussian_linear::get_step_scale(double_t& x, double_t& y) +void streamfx::gfx::blur::gaussian_linear::get_step_scale(double_t& x, double_t& y) { x = _step_scale.first; y = _step_scale.second; } -double_t gfx::blur::gaussian_linear::get_step_scale_x() +double_t streamfx::gfx::blur::gaussian_linear::get_step_scale_x() { return _step_scale.first; } -double_t gfx::blur::gaussian_linear::get_step_scale_y() +double_t streamfx::gfx::blur::gaussian_linear::get_step_scale_y() { return _step_scale.second; } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_linear::render() { auto gctx = streamfx::obs::gs::context(); @@ -320,7 +321,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::render effect.get_parameter("pImage").set_texture(_input_texture); effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second)); effect.get_parameter("pSize").set_float(float_t(_size)); - effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE); + effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE); // First Pass if (_step_scale.first > std::numeric_limits::epsilon()) { @@ -366,31 +367,31 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::render return this->get(); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::get() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_linear::get() { return _rendertarget->get_texture(); } -gfx::blur::gaussian_linear_directional::gaussian_linear_directional() : _angle(0.) {} +streamfx::gfx::blur::gaussian_linear_directional::gaussian_linear_directional() : _angle(0.) {} -gfx::blur::gaussian_linear_directional::~gaussian_linear_directional() {} +streamfx::gfx::blur::gaussian_linear_directional::~gaussian_linear_directional() {} -::gfx::blur::type gfx::blur::gaussian_linear_directional::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_linear_directional::get_type() { - return ::gfx::blur::type::Directional; + return ::streamfx::gfx::blur::type::Directional; } -double_t gfx::blur::gaussian_linear_directional::get_angle() +double_t streamfx::gfx::blur::gaussian_linear_directional::get_angle() { return D_RAD_TO_DEG(_angle); } -void gfx::blur::gaussian_linear_directional::set_angle(double_t angle) +void streamfx::gfx::blur::gaussian_linear_directional::set_angle(double_t angle) { _angle = D_DEG_TO_RAD(angle); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear_directional::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_linear_directional::render() { auto gctx = streamfx::obs::gs::context(); @@ -428,7 +429,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear_directi .set_float2(float_t(1.f / width * cos(_angle)), float_t(1.f / height * sin(_angle))); effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second)); effect.get_parameter("pSize").set_float(float_t(_size)); - effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE); + effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE); // First Pass { diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.hpp b/source/gfx/blur/gfx-blur-gaussian-linear.hpp index 53287493..26efe352 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.hpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.hpp @@ -24,7 +24,7 @@ #include "obs/gs/gs-rendertarget.hpp" #include "obs/gs/gs-texture.hpp" -namespace gfx { +namespace streamfx::gfx { namespace blur { class gaussian_linear_data { streamfx::obs::gs::effect _effect; @@ -39,53 +39,53 @@ namespace gfx { std::vector const& get_kernel(std::size_t width); }; - class gaussian_linear_factory : public ::gfx::blur::ifactory { - std::mutex _data_lock; - std::weak_ptr<::gfx::blur::gaussian_linear_data> _data; + class gaussian_linear_factory : public ::streamfx::gfx::blur::ifactory { + std::mutex _data_lock; + std::weak_ptr<::streamfx::gfx::blur::gaussian_linear_data> _data; public: gaussian_linear_factory(); virtual ~gaussian_linear_factory() override; - virtual bool is_type_supported(::gfx::blur::type type) override; + virtual bool is_type_supported(::streamfx::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_size(::gfx::blur::type type) override; + virtual double_t get_min_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_size(::gfx::blur::type type) override; + virtual double_t get_step_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_size(::gfx::blur::type type) override; + virtual double_t get_max_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_angle(::gfx::blur::type type) override; + virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_angle(::gfx::blur::type type) override; + virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_angle(::gfx::blur::type type) override; + virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override; - virtual bool is_step_scale_supported(::gfx::blur::type type) override; + virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override; - std::shared_ptr<::gfx::blur::gaussian_linear_data> data(); + std::shared_ptr<::streamfx::gfx::blur::gaussian_linear_data> data(); public: // Singleton - static ::gfx::blur::gaussian_linear_factory& get(); + static ::streamfx::gfx::blur::gaussian_linear_factory& get(); }; - class gaussian_linear : public ::gfx::blur::base { + class gaussian_linear : public ::streamfx::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::gaussian_linear_data> _data; + std::shared_ptr<::streamfx::gfx::blur::gaussian_linear_data> _data; double_t _size; std::pair _step_scale; @@ -101,7 +101,7 @@ namespace gfx { virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override; - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_size() override; @@ -120,14 +120,15 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override; }; - class gaussian_linear_directional : public ::gfx::blur::gaussian_linear, public ::gfx::blur::base_angle { + class gaussian_linear_directional : public ::streamfx::gfx::blur::gaussian_linear, + public ::streamfx::gfx::blur::base_angle { double_t _angle; public: gaussian_linear_directional(); virtual ~gaussian_linear_directional() override; - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_angle() override; @@ -136,4 +137,4 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; } // namespace blur -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/blur/gfx-blur-gaussian.cpp b/source/gfx/blur/gfx-blur-gaussian.cpp index 5f293e7e..6606df6d 100644 --- a/source/gfx/blur/gfx-blur-gaussian.cpp +++ b/source/gfx/blur/gfx-blur-gaussian.cpp @@ -34,28 +34,28 @@ // function first goes up at the point, and then once we pass the critical point // will go down again and it is not handled well. This is a pretty basic // approximation anyway at the moment. -#define MAX_KERNEL_SIZE 128 -#define MAX_BLUR_SIZE (MAX_KERNEL_SIZE - 1) -#define SEARCH_DENSITY double_t(1. / 500.) -#define SEARCH_THRESHOLD double_t(1. / (MAX_KERNEL_SIZE * 5)) -#define SEARCH_EXTENSION 1 -#define SEARCH_RANGE MAX_KERNEL_SIZE * 2 +#define ST_MAX_KERNEL_SIZE 128 +#define ST_MAX_BLUR_SIZE (ST_MAX_KERNEL_SIZE - 1) +#define ST_SEARCH_DENSITY double_t(1. / 500.) +#define ST_SEARCH_THRESHOLD double_t(1. / (ST_MAX_KERNEL_SIZE * 5)) +#define ST_SEARCH_EXTENSION 1 +#define ST_SEARCH_RANGE ST_MAX_KERNEL_SIZE * 2 -gfx::blur::gaussian_data::gaussian_data() +streamfx::gfx::blur::gaussian_data::gaussian_data() { auto gctx = streamfx::obs::gs::context(); _effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian.effect").u8string()); // Precalculate Kernels - for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) { - std::vector kernel_math(MAX_KERNEL_SIZE); - std::vector kernel_data(MAX_KERNEL_SIZE); + for (std::size_t kernel_size = 1; kernel_size <= ST_MAX_BLUR_SIZE; kernel_size++) { + std::vector kernel_math(ST_MAX_KERNEL_SIZE); + std::vector kernel_data(ST_MAX_KERNEL_SIZE); double_t actual_width = 1.; // Find actual kernel width. - for (double_t h = SEARCH_DENSITY; h < SEARCH_RANGE; h += SEARCH_DENSITY) { - if (streamfx::util::math::gaussian(double_t(kernel_size + SEARCH_EXTENSION), h) - > SEARCH_THRESHOLD) { + for (double_t h = ST_SEARCH_DENSITY; h < ST_SEARCH_RANGE; h += ST_SEARCH_DENSITY) { + if (streamfx::util::math::gaussian(double_t(kernel_size + ST_SEARCH_EXTENSION), h) + > ST_SEARCH_THRESHOLD) { actual_width = h; break; } @@ -78,220 +78,223 @@ gfx::blur::gaussian_data::gaussian_data() } } -gfx::blur::gaussian_data::~gaussian_data() +streamfx::gfx::blur::gaussian_data::~gaussian_data() { auto gctx = streamfx::obs::gs::context(); _effect.reset(); } -streamfx::obs::gs::effect gfx::blur::gaussian_data::get_effect() +streamfx::obs::gs::effect streamfx::gfx::blur::gaussian_data::get_effect() { return _effect; } -std::vector const& gfx::blur::gaussian_data::get_kernel(std::size_t width) +std::vector const& streamfx::gfx::blur::gaussian_data::get_kernel(std::size_t width) { if (width < 1) width = 1; - if (width > MAX_BLUR_SIZE) - width = MAX_BLUR_SIZE; + if (width > ST_MAX_BLUR_SIZE) + width = ST_MAX_BLUR_SIZE; width -= 1; return _kernels[width]; } -gfx::blur::gaussian_factory::gaussian_factory() {} +streamfx::gfx::blur::gaussian_factory::gaussian_factory() {} -gfx::blur::gaussian_factory::~gaussian_factory() {} +streamfx::gfx::blur::gaussian_factory::~gaussian_factory() {} -bool gfx::blur::gaussian_factory::is_type_supported(::gfx::blur::type v) +bool streamfx::gfx::blur::gaussian_factory::is_type_supported(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Area: return true; - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Directional: return true; - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Rotational: return true; - case ::gfx::blur::type::Zoom: + case ::streamfx::gfx::blur::type::Zoom: return true; default: return false; } } -std::shared_ptr<::gfx::blur::base> gfx::blur::gaussian_factory::create(::gfx::blur::type v) +std::shared_ptr<::streamfx::gfx::blur::base> + streamfx::gfx::blur::gaussian_factory::create(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: - return std::make_shared<::gfx::blur::gaussian>(); - case ::gfx::blur::type::Directional: - return std::static_pointer_cast<::gfx::blur::gaussian>(std::make_shared<::gfx::blur::gaussian_directional>()); - case ::gfx::blur::type::Rotational: - return std::make_shared<::gfx::blur::gaussian_rotational>(); - case ::gfx::blur::type::Zoom: - return std::make_shared<::gfx::blur::gaussian_zoom>(); + case ::streamfx::gfx::blur::type::Area: + return std::make_shared<::streamfx::gfx::blur::gaussian>(); + case ::streamfx::gfx::blur::type::Directional: + return std::static_pointer_cast<::streamfx::gfx::blur::gaussian>( + std::make_shared<::streamfx::gfx::blur::gaussian_directional>()); + case ::streamfx::gfx::blur::type::Rotational: + return std::make_shared<::streamfx::gfx::blur::gaussian_rotational>(); + case ::streamfx::gfx::blur::type::Zoom: + return std::make_shared<::streamfx::gfx::blur::gaussian_zoom>(); default: throw std::runtime_error("Invalid type."); } } -double_t gfx::blur::gaussian_factory::get_min_size(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_min_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::gaussian_factory::get_step_size(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_step_size(::streamfx::gfx::blur::type) { return double_t(1.0); } -double_t gfx::blur::gaussian_factory::get_max_size(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_max_size(::streamfx::gfx::blur::type) { - return double_t(MAX_BLUR_SIZE); + return double_t(ST_MAX_BLUR_SIZE); } -double_t gfx::blur::gaussian_factory::get_min_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::gaussian_factory::get_min_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return -180.0; default: return 0; } } -double_t gfx::blur::gaussian_factory::get_step_angle(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_step_angle(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_factory::get_max_angle(::gfx::blur::type v) +double_t streamfx::gfx::blur::gaussian_factory::get_max_angle(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Directional: - case ::gfx::blur::type::Rotational: + case ::streamfx::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Rotational: return 180.0; default: return 0; } } -bool gfx::blur::gaussian_factory::is_step_scale_supported(::gfx::blur::type v) +bool streamfx::gfx::blur::gaussian_factory::is_step_scale_supported(::streamfx::gfx::blur::type v) { switch (v) { - case ::gfx::blur::type::Area: - case ::gfx::blur::type::Zoom: - case ::gfx::blur::type::Directional: + case ::streamfx::gfx::blur::type::Area: + case ::streamfx::gfx::blur::type::Zoom: + case ::streamfx::gfx::blur::type::Directional: return true; default: return false; } } -double_t gfx::blur::gaussian_factory::get_min_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_min_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_factory::get_step_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_step_step_scale_x(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_factory::get_max_step_scale_x(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_max_step_scale_x(::streamfx::gfx::blur::type) { return double_t(1000.0); } -double_t gfx::blur::gaussian_factory::get_min_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_min_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_factory::get_step_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_step_step_scale_y(::streamfx::gfx::blur::type) { return double_t(0.01); } -double_t gfx::blur::gaussian_factory::get_max_step_scale_y(::gfx::blur::type) +double_t streamfx::gfx::blur::gaussian_factory::get_max_step_scale_y(::streamfx::gfx::blur::type) { return double_t(1000.0); } -std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data() +std::shared_ptr<::streamfx::gfx::blur::gaussian_data> streamfx::gfx::blur::gaussian_factory::data() { - std::unique_lock ulock(_data_lock); - std::shared_ptr<::gfx::blur::gaussian_data> data = _data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::streamfx::gfx::blur::gaussian_data> data = _data.lock(); if (!data) { - data = std::make_shared<::gfx::blur::gaussian_data>(); + data = std::make_shared<::streamfx::gfx::blur::gaussian_data>(); _data = data; } return data; } -::gfx::blur::gaussian_factory& gfx::blur::gaussian_factory::get() +::streamfx::gfx::blur::gaussian_factory& streamfx::gfx::blur::gaussian_factory::get() { - static ::gfx::blur::gaussian_factory instance; + static ::streamfx::gfx::blur::gaussian_factory instance; return instance; } -gfx::blur::gaussian::gaussian() : _data(::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.}) +streamfx::gfx::blur::gaussian::gaussian() + : _data(::streamfx::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.}) { auto gctx = streamfx::obs::gs::context(); _rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); } -gfx::blur::gaussian::~gaussian() {} +streamfx::gfx::blur::gaussian::~gaussian() {} -void gfx::blur::gaussian::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) +void streamfx::gfx::blur::gaussian::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) { _input_texture = texture; } -::gfx::blur::type gfx::blur::gaussian::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian::get_type() { - return ::gfx::blur::type::Area; + return ::streamfx::gfx::blur::type::Area; } -double_t gfx::blur::gaussian::get_size() +double_t streamfx::gfx::blur::gaussian::get_size() { return _size; } -void gfx::blur::gaussian::set_size(double_t width) +void streamfx::gfx::blur::gaussian::set_size(double_t width) { if (width < 1.) width = 1.; - if (width > MAX_BLUR_SIZE) - width = MAX_BLUR_SIZE; + if (width > ST_MAX_BLUR_SIZE) + width = ST_MAX_BLUR_SIZE; _size = width; } -void gfx::blur::gaussian::set_step_scale(double_t x, double_t y) +void streamfx::gfx::blur::gaussian::set_step_scale(double_t x, double_t y) { _step_scale.first = x; _step_scale.second = y; } -void gfx::blur::gaussian::get_step_scale(double_t& x, double_t& y) +void streamfx::gfx::blur::gaussian::get_step_scale(double_t& x, double_t& y) { x = _step_scale.first; y = _step_scale.second; } -double_t gfx::blur::gaussian::get_step_scale_x() +double_t streamfx::gfx::blur::gaussian::get_step_scale_x() { return _step_scale.first; } -double_t gfx::blur::gaussian::get_step_scale_y() +double_t streamfx::gfx::blur::gaussian::get_step_scale_y() { return _step_scale.second; } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian::render() { auto gctx = streamfx::obs::gs::context(); @@ -326,7 +329,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::render() effect.get_parameter("pImage").set_texture(_input_texture); effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second)); effect.get_parameter("pSize").set_float(float_t(_size)); - effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE); + effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE); // First Pass if (_step_scale.first > std::numeric_limits::epsilon()) { @@ -372,31 +375,31 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::render() return this->get(); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::get() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian::get() { return _rendertarget->get_texture(); } -gfx::blur::gaussian_directional::gaussian_directional() : m_angle(0.) {} +streamfx::gfx::blur::gaussian_directional::gaussian_directional() : m_angle(0.) {} -gfx::blur::gaussian_directional::~gaussian_directional() {} +streamfx::gfx::blur::gaussian_directional::~gaussian_directional() {} -::gfx::blur::type gfx::blur::gaussian_directional::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_directional::get_type() { - return ::gfx::blur::type::Directional; + return ::streamfx::gfx::blur::type::Directional; } -double_t gfx::blur::gaussian_directional::get_angle() +double_t streamfx::gfx::blur::gaussian_directional::get_angle() { return D_RAD_TO_DEG(m_angle); } -void gfx::blur::gaussian_directional::set_angle(double_t angle) +void streamfx::gfx::blur::gaussian_directional::set_angle(double_t angle) { m_angle = D_DEG_TO_RAD(angle); } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_directional::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_directional::render() { auto gctx = streamfx::obs::gs::context(); @@ -434,7 +437,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_directional::r .set_float2(float_t(1.f / width * cos(m_angle)), float_t(1.f / height * sin(m_angle))); effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second)); effect.get_parameter("pSize").set_float(float_t(_size)); - effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE); + effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE); // First Pass { @@ -450,12 +453,12 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_directional::r return this->get(); } -::gfx::blur::type gfx::blur::gaussian_rotational::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_rotational::get_type() { - return ::gfx::blur::type::Rotational; + return ::streamfx::gfx::blur::type::Rotational; } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_rotational::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_rotational::render() { auto gctx = streamfx::obs::gs::context(); @@ -494,7 +497,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_rotational::re effect.get_parameter("pSize").set_float(float_t(_size)); effect.get_parameter("pAngle").set_float(float_t(m_angle / _size)); effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second)); - effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE); + effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE); // First Pass { @@ -510,34 +513,34 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_rotational::re return this->get(); } -void gfx::blur::gaussian_rotational::set_center(double_t x, double_t y) +void streamfx::gfx::blur::gaussian_rotational::set_center(double_t x, double_t y) { m_center.first = x; m_center.second = y; } -void gfx::blur::gaussian_rotational::get_center(double_t& x, double_t& y) +void streamfx::gfx::blur::gaussian_rotational::get_center(double_t& x, double_t& y) { x = m_center.first; y = m_center.second; } -double_t gfx::blur::gaussian_rotational::get_angle() +double_t streamfx::gfx::blur::gaussian_rotational::get_angle() { return double_t(D_RAD_TO_DEG(m_angle)); } -void gfx::blur::gaussian_rotational::set_angle(double_t angle) +void streamfx::gfx::blur::gaussian_rotational::set_angle(double_t angle) { m_angle = D_DEG_TO_RAD(angle); } -::gfx::blur::type gfx::blur::gaussian_zoom::get_type() +::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_zoom::get_type() { - return ::gfx::blur::type::Zoom; + return ::streamfx::gfx::blur::type::Zoom; } -std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_zoom::render() +std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_zoom::render() { auto gctx = streamfx::obs::gs::context(); @@ -574,7 +577,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_zoom::render() effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second)); effect.get_parameter("pSize").set_float(float_t(_size)); effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second)); - effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE); + effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE); // First Pass { @@ -590,13 +593,13 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_zoom::render() return this->get(); } -void gfx::blur::gaussian_zoom::set_center(double_t x, double_t y) +void streamfx::gfx::blur::gaussian_zoom::set_center(double_t x, double_t y) { m_center.first = x; m_center.second = y; } -void gfx::blur::gaussian_zoom::get_center(double_t& x, double_t& y) +void streamfx::gfx::blur::gaussian_zoom::get_center(double_t& x, double_t& y) { x = m_center.first; y = m_center.second; diff --git a/source/gfx/blur/gfx-blur-gaussian.hpp b/source/gfx/blur/gfx-blur-gaussian.hpp index 576742ce..22a4d620 100644 --- a/source/gfx/blur/gfx-blur-gaussian.hpp +++ b/source/gfx/blur/gfx-blur-gaussian.hpp @@ -24,7 +24,7 @@ #include "obs/gs/gs-rendertarget.hpp" #include "obs/gs/gs-texture.hpp" -namespace gfx { +namespace streamfx::gfx { namespace blur { class gaussian_data { streamfx::obs::gs::effect _effect; @@ -39,53 +39,53 @@ namespace gfx { std::vector const& get_kernel(std::size_t width); }; - class gaussian_factory : public ::gfx::blur::ifactory { - std::mutex _data_lock; - std::weak_ptr<::gfx::blur::gaussian_data> _data; + class gaussian_factory : public ::streamfx::gfx::blur::ifactory { + std::mutex _data_lock; + std::weak_ptr<::streamfx::gfx::blur::gaussian_data> _data; public: gaussian_factory(); virtual ~gaussian_factory() override; - virtual bool is_type_supported(::gfx::blur::type type) override; + virtual bool is_type_supported(::streamfx::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_size(::gfx::blur::type type) override; + virtual double_t get_min_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_size(::gfx::blur::type type) override; + virtual double_t get_step_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_size(::gfx::blur::type type) override; + virtual double_t get_max_size(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_angle(::gfx::blur::type type) override; + virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_angle(::gfx::blur::type type) override; + virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_angle(::gfx::blur::type type) override; + virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override; - virtual bool is_step_scale_supported(::gfx::blur::type type) override; + virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_x(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override; - virtual double_t get_min_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_step_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override; - virtual double_t get_max_step_scale_y(::gfx::blur::type type) override; + virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override; - std::shared_ptr<::gfx::blur::gaussian_data> data(); + std::shared_ptr<::streamfx::gfx::blur::gaussian_data> data(); public: // Singleton - static ::gfx::blur::gaussian_factory& get(); + static ::streamfx::gfx::blur::gaussian_factory& get(); }; - class gaussian : public ::gfx::blur::base { + class gaussian : public ::streamfx::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::gaussian_data> _data; + std::shared_ptr<::streamfx::gfx::blur::gaussian_data> _data; double_t _size; std::pair _step_scale; @@ -101,7 +101,7 @@ namespace gfx { virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override; - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_size() override; @@ -120,14 +120,14 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override; }; - class gaussian_directional : public ::gfx::blur::gaussian, public ::gfx::blur::base_angle { + class gaussian_directional : public ::streamfx::gfx::blur::gaussian, public ::streamfx::gfx::blur::base_angle { double_t m_angle; public: gaussian_directional(); virtual ~gaussian_directional() override; - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual double_t get_angle() override; virtual void set_angle(double_t angle) override; @@ -135,14 +135,14 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; - class gaussian_rotational : public ::gfx::blur::gaussian, - public ::gfx::blur::base_angle, - public ::gfx::blur::base_center { + class gaussian_rotational : public ::streamfx::gfx::blur::gaussian, + public ::streamfx::gfx::blur::base_angle, + public ::streamfx::gfx::blur::base_center { std::pair m_center; double_t m_angle; public: - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual void set_center(double_t x, double_t y) override; virtual void get_center(double_t& x, double_t& y) override; @@ -153,11 +153,11 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; - class gaussian_zoom : public ::gfx::blur::gaussian, public ::gfx::blur::base_center { + class gaussian_zoom : public ::streamfx::gfx::blur::gaussian, public ::streamfx::gfx::blur::base_center { std::pair m_center; public: - virtual ::gfx::blur::type get_type() override; + virtual ::streamfx::gfx::blur::type get_type() override; virtual void set_center(double_t x, double_t y) override; virtual void get_center(double_t& x, double_t& y) override; @@ -165,4 +165,4 @@ namespace gfx { virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override; }; } // namespace blur -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/gfx-source-texture.cpp b/source/gfx/gfx-source-texture.cpp index 570fabeb..ab12632e 100644 --- a/source/gfx/gfx-source-texture.cpp +++ b/source/gfx/gfx-source-texture.cpp @@ -19,7 +19,7 @@ #include #include "obs/gs/gs-helper.hpp" -gfx::source_texture::~source_texture() +streamfx::gfx::source_texture::~source_texture() { if (_child && _parent) { obs_source_remove_active_child(_parent->get(), _child->get()); @@ -29,7 +29,7 @@ gfx::source_texture::~source_texture() _child.reset(); } -gfx::source_texture::source_texture(obs_source_t* parent) +streamfx::gfx::source_texture::source_texture(obs_source_t* parent) { if (!parent) { throw std::invalid_argument("_parent must not be null"); @@ -38,7 +38,7 @@ gfx::source_texture::source_texture(obs_source_t* parent) _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } -gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent) +streamfx::gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent) { if (!_source) { throw std::invalid_argument("source must not be null"); @@ -49,7 +49,7 @@ gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent _child = std::make_shared(_source, true, true); } -gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : source_texture(_parent) +streamfx::gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : source_texture(_parent) { if (!_name) { throw std::invalid_argument("name must not be null"); @@ -60,11 +60,12 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : } } -gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent) : source_texture(_name.c_str(), _parent) +streamfx::gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent) + : source_texture(_name.c_str(), _parent) {} -gfx::source_texture::source_texture(std::shared_ptr pchild, - std::shared_ptr pparent) +streamfx::gfx::source_texture::source_texture(std::shared_ptr pchild, + std::shared_ptr pparent) { if (!pchild) { throw std::invalid_argument("_child must not be null"); @@ -80,11 +81,12 @@ gfx::source_texture::source_texture(std::shared_ptr_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } -gfx::source_texture::source_texture(std::shared_ptr _child, obs_source_t* _parent) +streamfx::gfx::source_texture::source_texture(std::shared_ptr _child, + obs_source_t* _parent) : source_texture(_child, std::make_shared(_parent, false, false)) {} -obs_source_t* gfx::source_texture::get_object() +obs_source_t* streamfx::gfx::source_texture::get_object() { if (_child) { return _child->get(); @@ -92,12 +94,12 @@ obs_source_t* gfx::source_texture::get_object() return nullptr; } -obs_source_t* gfx::source_texture::get_parent() +obs_source_t* streamfx::gfx::source_texture::get_parent() { return _parent->get(); } -void gfx::source_texture::clear() +void streamfx::gfx::source_texture::clear() { if (_child && _parent) { obs_source_remove_active_child(_parent->get(), _child->get()); @@ -106,7 +108,7 @@ void gfx::source_texture::clear() _child.reset(); } -std::shared_ptr gfx::source_texture::render(std::size_t width, std::size_t height) +std::shared_ptr streamfx::gfx::source_texture::render(std::size_t width, std::size_t height) { if ((width == 0) || (width >= 16384)) { throw std::runtime_error("Width too large or too small."); diff --git a/source/gfx/gfx-source-texture.hpp b/source/gfx/gfx-source-texture.hpp index 70743ef0..0b00349d 100644 --- a/source/gfx/gfx-source-texture.hpp +++ b/source/gfx/gfx-source-texture.hpp @@ -22,7 +22,7 @@ #include "obs/gs/gs-texture.hpp" #include "obs/obs-source.hpp" -namespace gfx { +namespace streamfx::gfx { class source_texture { std::shared_ptr _parent; std::shared_ptr _child; @@ -92,4 +92,4 @@ namespace gfx { return factory_instance; } }; -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/lut/gfx-lut-consumer.cpp b/source/gfx/lut/gfx-lut-consumer.cpp index b03762a8..56a1f74d 100644 --- a/source/gfx/lut/gfx-lut-consumer.cpp +++ b/source/gfx/lut/gfx-lut-consumer.cpp @@ -22,17 +22,18 @@ #include "obs/gs/gs-helper.hpp" -gfx::lut::consumer::consumer() +streamfx::gfx::lut::consumer::consumer() { - _data = gfx::lut::data::instance(); + _data = streamfx::gfx::lut::data::instance(); if (!_data->consumer_effect()) throw std::runtime_error("Unable to get LUT consumer effect."); } -gfx::lut::consumer::~consumer() {} +streamfx::gfx::lut::consumer::~consumer() {} -std::shared_ptr gfx::lut::consumer::prepare(gfx::lut::color_depth depth, - std::shared_ptr lut) +std::shared_ptr + streamfx::gfx::lut::consumer::prepare(streamfx::gfx::lut::color_depth depth, + std::shared_ptr lut) { auto gctx = streamfx::obs::gs::context(); @@ -62,8 +63,9 @@ std::shared_ptr gfx::lut::consumer::prepare(gfx::lut: return effect; } -void gfx::lut::consumer::consume(gfx::lut::color_depth depth, std::shared_ptr lut, - std::shared_ptr texture) +void streamfx::gfx::lut::consumer::consume(streamfx::gfx::lut::color_depth depth, + std::shared_ptr lut, + std::shared_ptr texture) { auto gctx = streamfx::obs::gs::context(); diff --git a/source/gfx/lut/gfx-lut-consumer.hpp b/source/gfx/lut/gfx-lut-consumer.hpp index be77af83..c407e9b4 100644 --- a/source/gfx/lut/gfx-lut-consumer.hpp +++ b/source/gfx/lut/gfx-lut-consumer.hpp @@ -25,18 +25,18 @@ #include "obs/gs/gs-effect.hpp" #include "obs/gs/gs-texture.hpp" -namespace gfx::lut { +namespace streamfx::gfx::lut { class consumer { - std::shared_ptr _data; + std::shared_ptr _data; public: consumer(); ~consumer(); - std::shared_ptr prepare(gfx::lut::color_depth depth, + std::shared_ptr prepare(streamfx::gfx::lut::color_depth depth, std::shared_ptr lut); - void consume(gfx::lut::color_depth depth, std::shared_ptr lut, + void consume(streamfx::gfx::lut::color_depth depth, std::shared_ptr lut, std::shared_ptr texture); }; -} // namespace gfx::lut +} // namespace streamfx::gfx::lut diff --git a/source/gfx/lut/gfx-lut-producer.cpp b/source/gfx/lut/gfx-lut-producer.cpp index 36c2c62d..0e8ddbd5 100644 --- a/source/gfx/lut/gfx-lut-producer.cpp +++ b/source/gfx/lut/gfx-lut-producer.cpp @@ -22,34 +22,34 @@ #include "obs/gs/gs-helper.hpp" -gs_color_format format_from_depth(gfx::lut::color_depth depth) +gs_color_format format_from_depth(streamfx::gfx::lut::color_depth depth) { switch (depth) { - case gfx::lut::color_depth::_2: - case gfx::lut::color_depth::_4: - case gfx::lut::color_depth::_6: - case gfx::lut::color_depth::_8: + case streamfx::gfx::lut::color_depth::_2: + case streamfx::gfx::lut::color_depth::_4: + case streamfx::gfx::lut::color_depth::_6: + case streamfx::gfx::lut::color_depth::_8: return gs_color_format::GS_RGBA; - case gfx::lut::color_depth::_10: + case streamfx::gfx::lut::color_depth::_10: return gs_color_format::GS_R10G10B10A2; - case gfx::lut::color_depth::_12: - case gfx::lut::color_depth::_14: - case gfx::lut::color_depth::_16: + case streamfx::gfx::lut::color_depth::_12: + case streamfx::gfx::lut::color_depth::_14: + case streamfx::gfx::lut::color_depth::_16: return gs_color_format::GS_RGBA16; } return GS_RGBA32F; } -gfx::lut::producer::producer() +streamfx::gfx::lut::producer::producer() { - _data = gfx::lut::data::instance(); + _data = streamfx::gfx::lut::data::instance(); if (!_data->producer_effect()) throw std::runtime_error("Unable to get LUT producer effect."); } -gfx::lut::producer::~producer() {} +streamfx::gfx::lut::producer::~producer() {} -std::shared_ptr gfx::lut::producer::produce(gfx::lut::color_depth depth) +std::shared_ptr streamfx::gfx::lut::producer::produce(streamfx::gfx::lut::color_depth depth) { auto gctx = streamfx::obs::gs::context(); diff --git a/source/gfx/lut/gfx-lut-producer.hpp b/source/gfx/lut/gfx-lut-producer.hpp index 152ea86e..3478faf2 100644 --- a/source/gfx/lut/gfx-lut-producer.hpp +++ b/source/gfx/lut/gfx-lut-producer.hpp @@ -25,15 +25,15 @@ #include "obs/gs/gs-effect.hpp" #include "obs/gs/gs-rendertarget.hpp" -namespace gfx::lut { +namespace streamfx::gfx::lut { class producer { - std::shared_ptr _data; + std::shared_ptr _data; std::shared_ptr _rt; public: producer(); ~producer(); - std::shared_ptr produce(gfx::lut::color_depth depth); + std::shared_ptr produce(streamfx::gfx::lut::color_depth depth); }; -} // namespace gfx::lut +} // namespace streamfx::gfx::lut diff --git a/source/gfx/lut/gfx-lut.cpp b/source/gfx/lut/gfx-lut.cpp index 83283199..f6346666 100644 --- a/source/gfx/lut/gfx-lut.cpp +++ b/source/gfx/lut/gfx-lut.cpp @@ -27,24 +27,24 @@ using namespace streamfx; -#define LOCAL_PREFIX " " +#define ST_PREFIX " " -std::shared_ptr gfx::lut::data::instance() +std::shared_ptr streamfx::gfx::lut::data::instance() { - static std::weak_ptr _instance; - static std::mutex _mutex; + static std::weak_ptr _instance; + static std::mutex _mutex; std::lock_guard lock(_mutex); auto reference = _instance.lock(); if (!reference) { - reference = std::shared_ptr(new gfx::lut::data()); + reference = std::shared_ptr(new streamfx::gfx::lut::data()); _instance = reference; } return reference; } -gfx::lut::data::data() : _producer_effect(), _consumer_effect() +streamfx::gfx::lut::data::data() : _producer_effect(), _consumer_effect() { auto gctx = streamfx::obs::gs::context(); @@ -53,7 +53,7 @@ gfx::lut::data::data() : _producer_effect(), _consumer_effect() try { _producer_effect = std::make_shared(lut_producer_path); } catch (std::exception const& ex) { - DLOG_ERROR(LOCAL_PREFIX "Loading LUT Producer effect failed: %s", ex.what()); + DLOG_ERROR(ST_PREFIX "Loading LUT Producer effect failed: %s", ex.what()); } } @@ -62,12 +62,12 @@ gfx::lut::data::data() : _producer_effect(), _consumer_effect() try { _consumer_effect = std::make_shared(lut_consumer_path); } catch (std::exception const& ex) { - DLOG_ERROR(LOCAL_PREFIX "Loading LUT Consumer effect failed: %s", ex.what()); + DLOG_ERROR(ST_PREFIX "Loading LUT Consumer effect failed: %s", ex.what()); } } } -gfx::lut::data::~data() +streamfx::gfx::lut::data::~data() { auto gctx = streamfx::obs::gs::context(); _producer_effect.reset(); diff --git a/source/gfx/lut/gfx-lut.hpp b/source/gfx/lut/gfx-lut.hpp index dc7811e5..6296c833 100644 --- a/source/gfx/lut/gfx-lut.hpp +++ b/source/gfx/lut/gfx-lut.hpp @@ -23,7 +23,7 @@ #include "obs/gs/gs-effect.hpp" -namespace gfx::lut { +namespace streamfx::gfx::lut { class data { std::shared_ptr _producer_effect; std::shared_ptr _consumer_effect; @@ -59,4 +59,4 @@ namespace gfx::lut { _14 = 14, _16 = 16, }; -} // namespace gfx::lut +} // namespace streamfx::gfx::lut diff --git a/source/gfx/shader/gfx-shader-param-basic.cpp b/source/gfx/shader/gfx-shader-param-basic.cpp index 929d5c75..2025d184 100644 --- a/source/gfx/shader/gfx-shader-param-basic.cpp +++ b/source/gfx/shader/gfx-shader-param-basic.cpp @@ -60,7 +60,7 @@ inline bool get_annotation_float(streamfx::obs::gs::effect_parameter param, std: return false; } -gfx::shader::basic_field_type gfx::shader::get_field_type_from_string(std::string v) +streamfx::gfx::shader::basic_field_type streamfx::gfx::shader::get_field_type_from_string(std::string v) { std::map matches = { {"input", basic_field_type::Input}, @@ -76,7 +76,7 @@ gfx::shader::basic_field_type gfx::shader::get_field_type_from_string(std::strin return basic_field_type::Input; } -gfx::shader::basic_parameter::basic_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) +streamfx::gfx::shader::basic_parameter::basic_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) : parameter(param, prefix), _field_type(basic_field_type::Input), _suffix(), _keys(), _names(), _min(), _max(), _step(), _values() { @@ -153,14 +153,15 @@ gfx::shader::basic_parameter::basic_parameter(streamfx::obs::gs::effect_paramete } } -gfx::shader::basic_parameter::~basic_parameter() {} +streamfx::gfx::shader::basic_parameter::~basic_parameter() {} -void gfx::shader::basic_parameter::load_parameter_data(streamfx::obs::gs::effect_parameter parameter, basic_data& data) +void streamfx::gfx::shader::basic_parameter::load_parameter_data(streamfx::obs::gs::effect_parameter parameter, + basic_data& data) { parameter.get_default_value(&data.i32, 1); } -gfx::shader::bool_parameter::bool_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) +streamfx::gfx::shader::bool_parameter::bool_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) : basic_parameter(param, prefix) { _min.resize(0); @@ -171,9 +172,9 @@ gfx::shader::bool_parameter::bool_parameter(streamfx::obs::gs::effect_parameter _data.resize(get_size(), 1); } -gfx::shader::bool_parameter::~bool_parameter() {} +streamfx::gfx::shader::bool_parameter::~bool_parameter() {} -void gfx::shader::bool_parameter::defaults(obs_data_t* settings) +void streamfx::gfx::shader::bool_parameter::defaults(obs_data_t* settings) { // TODO: Support for bool[] if (get_size() == 1) { @@ -181,7 +182,7 @@ void gfx::shader::bool_parameter::defaults(obs_data_t* settings) } } -void gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t* settings) +void streamfx::gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t* settings) { if (!is_visible()) return; @@ -197,7 +198,7 @@ void gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t } } -void gfx::shader::bool_parameter::update(obs_data_t* settings) +void streamfx::gfx::shader::bool_parameter::update(obs_data_t* settings) { if (is_automatic()) return; @@ -208,12 +209,12 @@ void gfx::shader::bool_parameter::update(obs_data_t* settings) } } -void gfx::shader::bool_parameter::assign() +void streamfx::gfx::shader::bool_parameter::assign() { get_parameter().set_value(_data.data(), _data.size()); } -gfx::shader::float_parameter::float_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) +streamfx::gfx::shader::float_parameter::float_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) : basic_parameter(param, prefix) { _data.resize(get_size()); @@ -249,9 +250,9 @@ gfx::shader::float_parameter::float_parameter(streamfx::obs::gs::effect_paramete } } -gfx::shader::float_parameter::~float_parameter() {} +streamfx::gfx::shader::float_parameter::~float_parameter() {} -void gfx::shader::float_parameter::defaults(obs_data_t* settings) +void streamfx::gfx::shader::float_parameter::defaults(obs_data_t* settings) { std::vector defaults; defaults.resize(get_size()); @@ -262,27 +263,28 @@ void gfx::shader::float_parameter::defaults(obs_data_t* settings) } } -static inline obs_property_t* build_float_property(gfx::shader::basic_field_type ft, obs_properties_t* props, +static inline obs_property_t* build_float_property(streamfx::gfx::shader::basic_field_type ft, obs_properties_t* props, const char* key, const char* name, float_t min, float_t max, - float_t step, std::list edata) + float_t step, + std::list edata) { switch (ft) { - case gfx::shader::basic_field_type::Enum: { + case streamfx::gfx::shader::basic_field_type::Enum: { auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_FLOAT); for (auto& el : edata) { obs_property_list_add_float(p, el.name.c_str(), el.data.f32); } return p; } - case gfx::shader::basic_field_type::Slider: + case streamfx::gfx::shader::basic_field_type::Slider: return obs_properties_add_float_slider(props, key, name, min, max, step); default: - case gfx::shader::basic_field_type::Input: + case streamfx::gfx::shader::basic_field_type::Input: return obs_properties_add_float(props, key, name, min, max, step); } } -void gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_t* settings) +void streamfx::gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_t* settings) { if (!is_visible()) return; @@ -305,41 +307,41 @@ void gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_ } } -void gfx::shader::float_parameter::update(obs_data_t* settings) +void streamfx::gfx::shader::float_parameter::update(obs_data_t* settings) { for (std::size_t idx = 0; idx < get_size(); idx++) { _data[idx].f32 = static_cast(obs_data_get_double(settings, key_at(idx).data())) * _scale[idx].f32; } } -void gfx::shader::float_parameter::assign() +void streamfx::gfx::shader::float_parameter::assign() { if (is_automatic()) return; get_parameter().set_value(_data.data(), get_size()); } -static inline obs_property_t* build_int_property(gfx::shader::basic_field_type ft, obs_properties_t* props, +static inline obs_property_t* build_int_property(streamfx::gfx::shader::basic_field_type ft, obs_properties_t* props, const char* key, const char* name, int32_t min, int32_t max, - int32_t step, std::list edata) + int32_t step, std::list edata) { switch (ft) { - case gfx::shader::basic_field_type::Enum: { + case streamfx::gfx::shader::basic_field_type::Enum: { auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); for (auto& el : edata) { obs_property_list_add_int(p, el.name.c_str(), el.data.i32); } return p; } - case gfx::shader::basic_field_type::Slider: + case streamfx::gfx::shader::basic_field_type::Slider: return obs_properties_add_int_slider(props, key, name, min, max, step); default: - case gfx::shader::basic_field_type::Input: + case streamfx::gfx::shader::basic_field_type::Input: return obs_properties_add_int(props, key, name, min, max, step); } } -gfx::shader::int_parameter::int_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) +streamfx::gfx::shader::int_parameter::int_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) : basic_parameter(param, prefix) { _data.resize(get_size()); @@ -375,9 +377,9 @@ gfx::shader::int_parameter::int_parameter(streamfx::obs::gs::effect_parameter pa } } -gfx::shader::int_parameter::~int_parameter() {} +streamfx::gfx::shader::int_parameter::~int_parameter() {} -void gfx::shader::int_parameter::defaults(obs_data_t* settings) +void streamfx::gfx::shader::int_parameter::defaults(obs_data_t* settings) { std::vector defaults; defaults.resize(get_size()); @@ -387,7 +389,7 @@ void gfx::shader::int_parameter::defaults(obs_data_t* settings) } } -void gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t* settings) +void streamfx::gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t* settings) { if (!is_visible()) return; @@ -410,14 +412,14 @@ void gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t* } } -void gfx::shader::int_parameter::update(obs_data_t* settings) +void streamfx::gfx::shader::int_parameter::update(obs_data_t* settings) { for (std::size_t idx = 0; idx < get_size(); idx++) { _data[idx].i32 = static_cast(obs_data_get_int(settings, key_at(idx).data()) * _scale[idx].i32); } } -void gfx::shader::int_parameter::assign() +void streamfx::gfx::shader::int_parameter::assign() { if (is_automatic()) return; diff --git a/source/gfx/shader/gfx-shader-param-basic.hpp b/source/gfx/shader/gfx-shader-param-basic.hpp index fd9b888f..facfb6ae 100644 --- a/source/gfx/shader/gfx-shader-param-basic.hpp +++ b/source/gfx/shader/gfx-shader-param-basic.hpp @@ -21,7 +21,7 @@ #include "gfx-shader-param.hpp" #include "obs/gs/gs-effect-parameter.hpp" -namespace gfx { +namespace streamfx::gfx { namespace shader { enum class basic_field_type { Input, @@ -143,4 +143,4 @@ namespace gfx { }; } // namespace shader -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/shader/gfx-shader-param.cpp b/source/gfx/shader/gfx-shader-param.cpp index 88c0ab1f..3d9db414 100644 --- a/source/gfx/shader/gfx-shader-param.cpp +++ b/source/gfx/shader/gfx-shader-param.cpp @@ -20,17 +20,18 @@ #include #include "gfx-shader-param-basic.hpp" -#define ANNO_ORDER "order" -#define ANNO_VISIBILITY "visible" -#define ANNO_AUTOMATIC "automatic" -#define ANNO_NAME "name" -#define ANNO_DESCRIPTION "description" -#define ANNO_TYPE "type" -#define ANNO_SIZE "size" +#define ST_ANNO_ORDER "order" +#define ST_ANNO_VISIBILITY "visible" +#define ST_ANNO_AUTOMATIC "automatic" +#define ST_ANNO_NAME "name" +#define ST_ANNO_DESCRIPTION "description" +#define ST_ANNO_TYPE "type" +#define ST_ANNO_SIZE "size" typedef streamfx::obs::gs::effect_parameter::type eptype; -gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(streamfx::obs::gs::effect_parameter::type type) +streamfx::gfx::shader::parameter_type + streamfx::gfx::shader::get_type_from_effect_type(streamfx::obs::gs::effect_parameter::type type) { switch (type) { case eptype::Boolean: @@ -55,7 +56,7 @@ gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(streamfx::obs } } -std::size_t gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_parameter::type type) +std::size_t streamfx::gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_parameter::type type) { switch (type) { default: @@ -82,7 +83,7 @@ std::size_t gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_p } } -gfx::shader::parameter_type gfx::shader::get_type_from_string(std::string v) +streamfx::gfx::shader::parameter_type streamfx::gfx::shader::get_type_from_string(std::string v) { if ((v == "bool") || (v == "boolean")) { return parameter_type::Boolean; @@ -110,7 +111,7 @@ gfx::shader::parameter_type gfx::shader::get_type_from_string(std::string v) throw std::invalid_argument("Invalid parameter type string."); } -gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std::string key_prefix) +streamfx::gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std::string key_prefix) : _param(param), _order(0), _key(_param.get_name()), _visible(true), _automatic(false), _name(_key), _description() { { @@ -120,46 +121,46 @@ gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std } // Read Order - if (auto anno = _param.get_annotation(ANNO_VISIBILITY); anno) { + if (auto anno = _param.get_annotation(ST_ANNO_VISIBILITY); anno) { _visible = anno.get_default_bool(); } - if (auto anno = _param.get_annotation(ANNO_AUTOMATIC); anno) { + if (auto anno = _param.get_annotation(ST_ANNO_AUTOMATIC); anno) { _automatic = anno.get_default_bool(); } // Read Order - if (auto anno = _param.get_annotation(ANNO_ORDER); anno) { + if (auto anno = _param.get_annotation(ST_ANNO_ORDER); anno) { _order = anno.get_default_int(); } // Read Name - if (auto anno = _param.get_annotation(ANNO_NAME); anno) { + if (auto anno = _param.get_annotation(ST_ANNO_NAME); anno) { if (std::string v = anno.get_default_string(); v.length() > 0) { _name = v; } else { - throw std::out_of_range("'" ANNO_NAME "' annotation has zero length."); + throw std::out_of_range("'" ST_ANNO_NAME "' annotation has zero length."); } } // Read Description - if (auto anno = _param.get_annotation(ANNO_DESCRIPTION); anno) { + if (auto anno = _param.get_annotation(ST_ANNO_DESCRIPTION); anno) { if (std::string v = anno.get_default_string(); v.length() > 0) { _description = v; } else { - throw std::out_of_range("'" ANNO_DESCRIPTION "' annotation has zero length."); + throw std::out_of_range("'" ST_ANNO_DESCRIPTION "' annotation has zero length."); } } // Read Type override. _type = get_type_from_effect_type(_param.get_type()); - if (auto anno = _param.get_annotation(ANNO_TYPE); anno) { + if (auto anno = _param.get_annotation(ST_ANNO_TYPE); anno) { // We have a type override. _type = get_type_from_string(anno.get_default_string()); } // Read Size override. _size = get_length_from_effect_type(_param.get_type()); - if (auto anno = _param.get_annotation(ANNO_SIZE); anno) { + if (auto anno = _param.get_annotation(ST_ANNO_SIZE); anno) { std::size_t ov = static_cast(anno.get_default_int()); if (ov > 0) _size = ov; @@ -167,34 +168,34 @@ gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std _size = std::clamp(_size, size_t{1}, size_t{32}); } -void gfx::shader::parameter::defaults(obs_data_t* settings) {} +void streamfx::gfx::shader::parameter::defaults(obs_data_t* settings) {} -void gfx::shader::parameter::properties(obs_properties_t* props, obs_data_t* settings) {} +void streamfx::gfx::shader::parameter::properties(obs_properties_t* props, obs_data_t* settings) {} -void gfx::shader::parameter::update(obs_data_t* settings) {} +void streamfx::gfx::shader::parameter::update(obs_data_t* settings) {} -void gfx::shader::parameter::assign() {} +void streamfx::gfx::shader::parameter::assign() {} -std::shared_ptr - gfx::shader::parameter::make_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) +std::shared_ptr + streamfx::gfx::shader::parameter::make_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix) { if (!param) { throw std::runtime_error("Bad call to make_parameter. This is a bug in the plugin."); } parameter_type real_type = get_type_from_effect_type(param.get_type()); - if (auto anno = param.get_annotation(ANNO_TYPE); anno) { + if (auto anno = param.get_annotation(ST_ANNO_TYPE); anno) { // We have a type override. real_type = get_type_from_string(param.get_default_string()); } switch (real_type) { case parameter_type::Boolean: - return std::make_shared(param, prefix); + return std::make_shared(param, prefix); case parameter_type::Integer: - return std::make_shared(param, prefix); + return std::make_shared(param, prefix); case parameter_type::Float: - return std::make_shared(param, prefix); + return std::make_shared(param, prefix); default: return nullptr; } diff --git a/source/gfx/shader/gfx-shader-param.hpp b/source/gfx/shader/gfx-shader-param.hpp index 21b62d8d..5fb77747 100644 --- a/source/gfx/shader/gfx-shader-param.hpp +++ b/source/gfx/shader/gfx-shader-param.hpp @@ -20,7 +20,7 @@ #include #include "obs/gs/gs-effect-parameter.hpp" -namespace gfx { +namespace streamfx::gfx { namespace shader { enum class parameter_type { // Unknown type, could be anything. @@ -141,4 +141,4 @@ namespace gfx { std::string prefix); }; } // namespace shader -} // namespace gfx +} // namespace streamfx::gfx diff --git a/source/gfx/shader/gfx-shader.cpp b/source/gfx/shader/gfx-shader.cpp index 7f75c310..a9172509 100644 --- a/source/gfx/shader/gfx-shader.cpp +++ b/source/gfx/shader/gfx-shader.cpp @@ -33,7 +33,7 @@ #define ST_SHADER_SEED ST_SHADER ".Seed" #define ST_PARAMETERS ST ".Parameters" -gfx::shader::shader::shader(obs_source_t* self, shader_mode mode) +streamfx::gfx::shader::shader::shader(obs_source_t* self, shader_mode mode) : _self(self), _mode(mode), _base_width(1), _base_height(1), _active(true), _shader(), _shader_file(), _shader_tech("Draw"), _shader_file_mt(), _shader_file_sz(), _shader_file_tick(0), @@ -52,9 +52,9 @@ gfx::shader::shader::shader(obs_source_t* self, shader_mode mode) } } -gfx::shader::shader::~shader() {} +streamfx::gfx::shader::shader::~shader() {} -bool gfx::shader::shader::is_shader_different(const std::filesystem::path& file) +bool streamfx::gfx::shader::shader::is_shader_different(const std::filesystem::path& file) try { if (std::filesystem::exists(file)) { // Check if the file name differs. @@ -78,7 +78,7 @@ try { return false; } -bool gfx::shader::shader::is_technique_different(const std::string& tech) +bool streamfx::gfx::shader::shader::is_technique_different(const std::string& tech) { // Is the technique different? if (tech != _shader_tech) @@ -87,8 +87,8 @@ bool gfx::shader::shader::is_technique_different(const std::string& tech) return false; } -bool gfx::shader::shader::load_shader(const std::filesystem::path& file, const std::string& tech, bool& shader_dirty, - bool& param_dirty) +bool streamfx::gfx::shader::shader::load_shader(const std::filesystem::path& file, const std::string& tech, + bool& shader_dirty, bool& param_dirty) try { if (!std::filesystem::exists(file)) return false; @@ -142,7 +142,7 @@ try { if (fnd != _shader_params.end()) continue; - auto param = gfx::shader::parameter::make_parameter(el, ST_PARAMETERS); + auto param = streamfx::gfx::shader::parameter::make_parameter(el, ST_PARAMETERS); if (param) { _shader_params.insert_or_assign(el.get_name(), param); @@ -161,7 +161,7 @@ try { if (fnd != _shader_params.end()) continue; - auto param = gfx::shader::parameter::make_parameter(el, ST_PARAMETERS); + auto param = streamfx::gfx::shader::parameter::make_parameter(el, ST_PARAMETERS); if (param) { _shader_params.insert_or_assign(el.get_name(), param); @@ -180,7 +180,7 @@ try { return false; } -void gfx::shader::shader::defaults(obs_data_t* data) +void streamfx::gfx::shader::shader::defaults(obs_data_t* data) { obs_data_set_default_string(data, ST_SHADER_FILE, ""); obs_data_set_default_string(data, ST_SHADER_TECHNIQUE, ""); @@ -189,7 +189,7 @@ void gfx::shader::shader::defaults(obs_data_t* data) obs_data_set_default_int(data, ST_SHADER_SEED, static_cast(time(NULL))); } -void gfx::shader::shader::properties(obs_properties_t* pr) +void streamfx::gfx::shader::shader::properties(obs_properties_t* pr) { _have_current_params = false; @@ -216,7 +216,7 @@ void gfx::shader::shader::properties(obs_properties_t* pr) obs_properties_add_button2( grp, ST_REFRESH, D_TRANSLATE(ST_REFRESH), [](obs_properties_t* props, obs_property_t* prop, void* priv) { - return reinterpret_cast(priv)->on_refresh_properties(props, prop); + return reinterpret_cast(priv)->on_refresh_properties(props, prop); }, this); } @@ -249,7 +249,7 @@ void gfx::shader::shader::properties(obs_properties_t* pr) on_refresh_properties(pr, nullptr); } -bool gfx::shader::shader::on_refresh_properties(obs_properties_t* props, obs_property_t* prop) +bool streamfx::gfx::shader::shader::on_refresh_properties(obs_properties_t* props, obs_property_t* prop) { if (_shader) { // Clear list of techniques and rebuild it. obs_property_t* p_tech_list = obs_properties_get(props, ST_SHADER_TECHNIQUE); @@ -278,8 +278,8 @@ bool gfx::shader::shader::on_refresh_properties(obs_properties_t* props, obs_pro return true; } -bool gfx::shader::shader::on_shader_or_technique_modified(obs_properties_t* props, obs_property_t* prop, - obs_data_t* data) +bool streamfx::gfx::shader::shader::on_shader_or_technique_modified(obs_properties_t* props, obs_property_t* prop, + obs_data_t* data) { bool shader_dirty = false; bool param_dirty = false; @@ -314,7 +314,7 @@ bool gfx::shader::shader::on_shader_or_technique_modified(obs_properties_t* prop return shader_dirty || param_dirty || !_have_current_params; } -bool gfx::shader::shader::update_shader(obs_data_t* data, bool& shader_dirty, bool& param_dirty) +bool streamfx::gfx::shader::shader::update_shader(obs_data_t* data, bool& shader_dirty, bool& param_dirty) { const char* file_c = obs_data_get_string(data, ST_SHADER_FILE); std::string file = file_c ? file_c : ""; @@ -324,22 +324,22 @@ bool gfx::shader::shader::update_shader(obs_data_t* data, bool& shader_dirty, bo return load_shader(file, tech, shader_dirty, param_dirty); } -inline std::pair parse_text_as_size(const char* text) +inline std::pair parse_text_as_size(const char* text) { double_t v = 0; if (sscanf(text, "%lf", &v) == 1) { const char* prc_chr = strrchr(text, '%'); if (prc_chr && (*prc_chr == '%')) { - return {gfx::shader::size_type::Percent, v / 100.0}; + return {streamfx::gfx::shader::size_type::Percent, v / 100.0}; } else { - return {gfx::shader::size_type::Pixel, v}; + return {streamfx::gfx::shader::size_type::Pixel, v}; } } else { - return {gfx::shader::size_type::Percent, 1.0}; + return {streamfx::gfx::shader::size_type::Percent, 1.0}; } } -void gfx::shader::shader::update(obs_data_t* data) +void streamfx::gfx::shader::shader::update(obs_data_t* data) { bool v1, v2; update_shader(data, v1, v2); @@ -368,7 +368,7 @@ void gfx::shader::shader::update(obs_data_t* data) } } -uint32_t gfx::shader::shader::width() +uint32_t streamfx::gfx::shader::shader::width() { switch (_mode) { case shader_mode::Transition: @@ -392,7 +392,7 @@ uint32_t gfx::shader::shader::width() } } -uint32_t gfx::shader::shader::height() +uint32_t streamfx::gfx::shader::shader::height() { switch (_mode) { case shader_mode::Transition: @@ -416,17 +416,17 @@ uint32_t gfx::shader::shader::height() } } -uint32_t gfx::shader::shader::base_width() +uint32_t streamfx::gfx::shader::shader::base_width() { return _base_width; } -uint32_t gfx::shader::shader::base_height() +uint32_t streamfx::gfx::shader::shader::base_height() { return _base_height; } -bool gfx::shader::shader::tick(float_t time) +bool streamfx::gfx::shader::shader::tick(float_t time) { _shader_file_tick = static_cast(static_cast(_shader_file_tick) + static_cast(time)); if (_shader_file_tick >= 1.0f / 3.0f) { @@ -459,7 +459,7 @@ bool gfx::shader::shader::tick(float_t time) return false; } -void gfx::shader::shader::prepare_render() +void streamfx::gfx::shader::shader::prepare_render() { if (!_shader) return; @@ -503,7 +503,7 @@ void gfx::shader::shader::prepare_render() return; } -void gfx::shader::shader::render(gs_effect* effect) +void streamfx::gfx::shader::shader::render(gs_effect* effect) { if (!_shader) return; @@ -538,13 +538,13 @@ void gfx::shader::shader::render(gs_effect* effect) } } -void gfx::shader::shader::set_size(uint32_t w, uint32_t h) +void streamfx::gfx::shader::shader::set_size(uint32_t w, uint32_t h) { _base_width = w; _base_height = h; } -void gfx::shader::shader::set_input_a(std::shared_ptr tex) +void streamfx::gfx::shader::shader::set_input_a(std::shared_ptr tex) { if (!_shader) return; @@ -564,7 +564,7 @@ void gfx::shader::shader::set_input_a(std::shared_ptr tex) +void streamfx::gfx::shader::shader::set_input_b(std::shared_ptr tex) { if (!_shader) return; @@ -584,7 +584,7 @@ void gfx::shader::shader::set_input_b(std::shared_ptr(self, ::gfx::shader::shader_mode::Source); + _fx = std::make_shared<::streamfx::gfx::shader::shader>(self, ::streamfx::gfx::shader::shader_mode::Source); update(data); } @@ -121,7 +121,7 @@ const char* shader_factory::get_name() void shader_factory::get_defaults2(obs_data_t* data) { - ::gfx::shader::shader::defaults(data); + ::streamfx::gfx::shader::shader::defaults(data); } obs_properties_t* shader_factory::get_properties2(shader_instance* data) diff --git a/source/sources/source-shader.hpp b/source/sources/source-shader.hpp index deebcc14..77fffdc0 100644 --- a/source/sources/source-shader.hpp +++ b/source/sources/source-shader.hpp @@ -26,7 +26,7 @@ namespace streamfx::source::shader { class shader_instance : public obs::source_instance { - std::shared_ptr _fx; + std::shared_ptr _fx; public: shader_instance(obs_data_t* data, obs_source_t* self); diff --git a/source/transitions/transition-shader.cpp b/source/transitions/transition-shader.cpp index 8e797315..83a3e62a 100644 --- a/source/transitions/transition-shader.cpp +++ b/source/transitions/transition-shader.cpp @@ -31,7 +31,7 @@ static constexpr std::string_view HELP_URL = shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self) { - _fx = std::make_shared(self, gfx::shader::shader_mode::Transition); + _fx = std::make_shared(self, streamfx::gfx::shader::shader_mode::Transition); update(data); } @@ -142,7 +142,7 @@ const char* shader_factory::get_name() void shader_factory::get_defaults2(obs_data_t* data) { - gfx::shader::shader::defaults(data); + streamfx::gfx::shader::shader::defaults(data); } obs_properties_t* shader_factory::get_properties2(shader::shader_instance* data) diff --git a/source/transitions/transition-shader.hpp b/source/transitions/transition-shader.hpp index 9e3d66cb..6c4e3a83 100644 --- a/source/transitions/transition-shader.hpp +++ b/source/transitions/transition-shader.hpp @@ -26,7 +26,7 @@ namespace streamfx::transition::shader { class shader_instance : public obs::source_instance { - std::shared_ptr _fx; + std::shared_ptr _fx; public: shader_instance(obs_data_t* data, obs_source_t* self);