diff --git a/source/filters/filter-blur.cpp b/source/filters/filter-blur.cpp index 9bdb63f6..5c481d6a 100644 --- a/source/filters/filter-blur.cpp +++ b/source/filters/filter-blur.cpp @@ -46,35 +46,35 @@ #endif // Translation Strings -#define SOURCE_NAME "Filter.Blur" +#define ST "Filter.Blur" -#define P_TYPE "Filter.Blur.Type" -#define P_SUBTYPE "Filter.Blur.SubType" -#define P_SIZE "Filter.Blur.Size" -#define P_ANGLE "Filter.Blur.Angle" -#define P_CENTER "Filter.Blur.Center" -#define P_CENTER_X "Filter.Blur.Center.X" -#define P_CENTER_Y "Filter.Blur.Center.Y" -#define P_STEPSCALE "Filter.Blur.StepScale" -#define P_STEPSCALE_X "Filter.Blur.StepScale.X" -#define P_STEPSCALE_Y "Filter.Blur.StepScale.Y" -#define P_MASK "Filter.Blur.Mask" -#define P_MASK_TYPE "Filter.Blur.Mask.Type" -#define P_MASK_TYPE_REGION "Filter.Blur.Mask.Type.Region" -#define P_MASK_TYPE_IMAGE "Filter.Blur.Mask.Type.Image" -#define P_MASK_TYPE_SOURCE "Filter.Blur.Mask.Type.Source" -#define P_MASK_REGION_LEFT "Filter.Blur.Mask.Region.Left" -#define P_MASK_REGION_RIGHT "Filter.Blur.Mask.Region.Right" -#define P_MASK_REGION_TOP "Filter.Blur.Mask.Region.Top" -#define P_MASK_REGION_BOTTOM "Filter.Blur.Mask.Region.Bottom" -#define P_MASK_REGION_FEATHER "Filter.Blur.Mask.Region.Feather" -#define P_MASK_REGION_FEATHER_SHIFT "Filter.Blur.Mask.Region.Feather.Shift" -#define P_MASK_REGION_INVERT "Filter.Blur.Mask.Region.Invert" -#define P_MASK_IMAGE "Filter.Blur.Mask.Image" -#define P_MASK_SOURCE "Filter.Blur.Mask.Source" -#define P_MASK_COLOR "Filter.Blur.Mask.Color" -#define P_MASK_ALPHA "Filter.Blur.Mask.Alpha" -#define P_MASK_MULTIPLIER "Filter.Blur.Mask.Multiplier" +#define ST_TYPE "Filter.Blur.Type" +#define ST_SUBTYPE "Filter.Blur.SubType" +#define ST_SIZE "Filter.Blur.Size" +#define ST_ANGLE "Filter.Blur.Angle" +#define ST_CENTER "Filter.Blur.Center" +#define ST_CENTER_X "Filter.Blur.Center.X" +#define ST_CENTER_Y "Filter.Blur.Center.Y" +#define ST_STEPSCALE "Filter.Blur.StepScale" +#define ST_STEPSCALE_X "Filter.Blur.StepScale.X" +#define ST_STEPSCALE_Y "Filter.Blur.StepScale.Y" +#define ST_MASK "Filter.Blur.Mask" +#define ST_MASK_TYPE "Filter.Blur.Mask.Type" +#define ST_MASK_TYPE_REGION "Filter.Blur.Mask.Type.Region" +#define ST_MASK_TYPE_IMAGE "Filter.Blur.Mask.Type.Image" +#define ST_MASK_TYPE_SOURCE "Filter.Blur.Mask.Type.Source" +#define ST_MASK_REGION_LEFT "Filter.Blur.Mask.Region.Left" +#define ST_MASK_REGION_RIGHT "Filter.Blur.Mask.Region.Right" +#define ST_MASK_REGION_TOP "Filter.Blur.Mask.Region.Top" +#define ST_MASK_REGION_BOTTOM "Filter.Blur.Mask.Region.Bottom" +#define ST_MASK_REGION_FEATHER "Filter.Blur.Mask.Region.Feather" +#define ST_MASK_REGION_FEATHER_SHIFT "Filter.Blur.Mask.Region.Feather.Shift" +#define ST_MASK_REGION_INVERT "Filter.Blur.Mask.Region.Invert" +#define ST_MASK_IMAGE "Filter.Blur.Mask.Image" +#define ST_MASK_SOURCE "Filter.Blur.Mask.Source" +#define ST_MASK_COLOR "Filter.Blur.Mask.Color" +#define ST_MASK_ALPHA "Filter.Blur.Mask.Alpha" +#define ST_MASK_MULTIPLIER "Filter.Blur.Mask.Multiplier" struct local_blur_type_t { std::function<::gfx::blur::ifactory&()> fn; @@ -100,10 +100,10 @@ static std::map list_of_subtypes = { }; // Initializer & Finalizer -INITIALIZER(filterBlurFactoryInitializer) +P_INITIALIZER(filterBlurFactoryInitializer) { - initializerFunctions.push_back([] { filter::blur::blur_factory::initialize(); }); - finalizerFunctions.push_back([] { filter::blur::blur_factory::finalize(); }); + initializer_functions.push_back([] { filter::blur::blur_factory::initialize(); }); + finalizer_functions.push_back([] { filter::blur::blur_factory::finalize(); }); } static std::shared_ptr factory_instance = nullptr; @@ -125,29 +125,29 @@ std::shared_ptr filter::blur::blur_factory::get() filter::blur::blur_factory::blur_factory() { - memset(&source_info, 0, sizeof(obs_source_info)); - source_info.id = "obs-stream-effects-filter-blur"; - source_info.type = OBS_SOURCE_TYPE_FILTER; - source_info.output_flags = OBS_SOURCE_VIDEO; - source_info.get_name = get_name; - source_info.get_defaults = get_defaults; - source_info.get_properties = get_properties; + memset(&_source_info, 0, sizeof(obs_source_info)); + _source_info.id = "obs-stream-effects-filter-blur"; + _source_info.type = OBS_SOURCE_TYPE_FILTER; + _source_info.output_flags = OBS_SOURCE_VIDEO; + _source_info.get_name = get_name; + _source_info.get_defaults = get_defaults; + _source_info.get_properties = get_properties; - source_info.create = create; - source_info.destroy = destroy; - source_info.update = update; - source_info.activate = activate; - source_info.deactivate = deactivate; - source_info.video_tick = video_tick; - source_info.video_render = video_render; - source_info.load = load; + _source_info.create = create; + _source_info.destroy = destroy; + _source_info.update = update; + _source_info.activate = activate; + _source_info.deactivate = deactivate; + _source_info.video_tick = video_tick; + _source_info.video_render = video_render; + _source_info.load = load; - obs_register_source(&source_info); + obs_register_source(&_source_info); // Translation Cache /// File Filter for Images - translation_map.insert({std::string("image-filter"), std::string(P_TRANSLATE(S_FILETYPE_IMAGES)) - + std::string(" (" T_FILEFILTERS_IMAGE ");;") + _translation_map.insert({std::string("image-filter"), std::string(D_TRANSLATE(S_FILETYPE_IMAGES)) + + std::string(" (" S_FILEFILTERS_IMAGE ");;") + std::string("* (*.*)")}); } @@ -158,20 +158,20 @@ void filter::blur::blur_factory::on_list_fill() auto gctx = gs::context(); { - char* file = obs_module_file("effects/color-conversion.effect"); + char* file = obs_module_file("effects/color-conversion._effect"); try { - color_converter_effect = std::make_shared(file); + _color_converter_effect = std::make_shared(file); } catch (std::runtime_error& ex) { - P_LOG_ERROR(" Loading effect '%s' failed with error(s): %s", file, ex.what()); + P_LOG_ERROR(" Loading _effect '%s' failed with error(s): %s", file, ex.what()); } bfree(file); } { - char* file = obs_module_file("effects/mask.effect"); + char* file = obs_module_file("effects/mask._effect"); try { - mask_effect = std::make_shared(file); + _mask_effect = std::make_shared(file); } catch (std::runtime_error& ex) { - P_LOG_ERROR(" Loading effect '%s' failed with error(s): %s", file, ex.what()); + P_LOG_ERROR(" Loading _effect '%s' failed with error(s): %s", file, ex.what()); } bfree(file); } @@ -180,15 +180,15 @@ void filter::blur::blur_factory::on_list_fill() void filter::blur::blur_factory::on_list_empty() { auto gctx = gs::context(); - color_converter_effect.reset(); - mask_effect.reset(); + _color_converter_effect.reset(); + _mask_effect.reset(); } std::string const& filter::blur::blur_factory::get_translation(std::string const key) { static std::string none(""); - auto found = translation_map.find(key); - if (found != translation_map.end()) { + auto found = _translation_map.find(key); + if (found != _translation_map.end()) { return found->second; } return none; @@ -196,19 +196,19 @@ std::string const& filter::blur::blur_factory::get_translation(std::string const void* filter::blur::blur_factory::create(obs_data_t* data, obs_source_t* parent) { - if (get()->sources.empty()) { + if (get()->_sources.empty()) { get()->on_list_fill(); } filter::blur::blur_instance* ptr = new filter::blur::blur_instance(data, parent); - get()->sources.push_back(ptr); + get()->_sources.push_back(ptr); return ptr; } void filter::blur::blur_factory::destroy(void* inptr) { filter::blur::blur_instance* ptr = reinterpret_cast(inptr); - get()->sources.remove(ptr); - if (get()->sources.empty()) { + get()->_sources.remove(ptr); + if (get()->_sources.empty()) { get()->on_list_empty(); } delete ptr; @@ -217,36 +217,36 @@ void filter::blur::blur_factory::destroy(void* inptr) void filter::blur::blur_factory::get_defaults(obs_data_t* data) { // Type, Subtype - obs_data_set_default_string(data, P_TYPE, "box"); - obs_data_set_default_string(data, P_SUBTYPE, "area"); + obs_data_set_default_string(data, ST_TYPE, "box"); + obs_data_set_default_string(data, ST_SUBTYPE, "area"); // Parameters - obs_data_set_default_int(data, P_SIZE, 5); - obs_data_set_default_double(data, P_ANGLE, 0.); - obs_data_set_default_double(data, P_CENTER_X, 50.); - obs_data_set_default_double(data, P_CENTER_Y, 50.); - obs_data_set_default_bool(data, P_STEPSCALE, false); - obs_data_set_default_double(data, P_STEPSCALE_X, 1.); - obs_data_set_default_double(data, P_STEPSCALE_Y, 1.); + obs_data_set_default_int(data, ST_SIZE, 5); + obs_data_set_default_double(data, ST_ANGLE, 0.); + obs_data_set_default_double(data, ST_CENTER_X, 50.); + obs_data_set_default_double(data, ST_CENTER_Y, 50.); + obs_data_set_default_bool(data, ST_STEPSCALE, false); + obs_data_set_default_double(data, ST_STEPSCALE_X, 1.); + obs_data_set_default_double(data, ST_STEPSCALE_Y, 1.); // Masking - obs_data_set_default_bool(data, P_MASK, false); - obs_data_set_default_int(data, P_MASK_TYPE, mask_type::Region); - obs_data_set_default_double(data, P_MASK_REGION_LEFT, 0.0); - obs_data_set_default_double(data, P_MASK_REGION_RIGHT, 0.0); - obs_data_set_default_double(data, P_MASK_REGION_TOP, 0.0); - obs_data_set_default_double(data, P_MASK_REGION_BOTTOM, 0.0); - obs_data_set_default_double(data, P_MASK_REGION_FEATHER, 0.0); - obs_data_set_default_double(data, P_MASK_REGION_FEATHER_SHIFT, 0.0); - obs_data_set_default_bool(data, P_MASK_REGION_INVERT, false); + obs_data_set_default_bool(data, ST_MASK, false); + obs_data_set_default_int(data, ST_MASK_TYPE, mask_type::Region); + obs_data_set_default_double(data, ST_MASK_REGION_LEFT, 0.0); + obs_data_set_default_double(data, ST_MASK_REGION_RIGHT, 0.0); + obs_data_set_default_double(data, ST_MASK_REGION_TOP, 0.0); + obs_data_set_default_double(data, ST_MASK_REGION_BOTTOM, 0.0); + obs_data_set_default_double(data, ST_MASK_REGION_FEATHER, 0.0); + obs_data_set_default_double(data, ST_MASK_REGION_FEATHER_SHIFT, 0.0); + obs_data_set_default_bool(data, ST_MASK_REGION_INVERT, false); { char* default_file = obs_module_file("white.png"); - obs_data_set_default_string(data, P_MASK_IMAGE, default_file); + obs_data_set_default_string(data, ST_MASK_IMAGE, default_file); bfree(default_file); } - obs_data_set_default_string(data, P_MASK_SOURCE, ""); - obs_data_set_default_int(data, P_MASK_COLOR, 0xFFFFFFFFull); - obs_data_set_default_double(data, P_MASK_MULTIPLIER, 1.0); + obs_data_set_default_string(data, ST_MASK_SOURCE, ""); + obs_data_set_default_int(data, ST_MASK_COLOR, 0xFFFFFFFFull); + obs_data_set_default_double(data, ST_MASK_MULTIPLIER, 1.0); } obs_properties_t* filter::blur::blur_factory::get_properties(void* inptr) @@ -266,7 +266,7 @@ void filter::blur::blur_factory::load(void* inptr, obs_data_t* settings) const char* filter::blur::blur_factory::get_name(void*) { - return P_TRANSLATE(SOURCE_NAME); + return D_TRANSLATE(ST); } uint32_t filter::blur::blur_factory::get_width(void* inptr) @@ -301,25 +301,25 @@ void filter::blur::blur_factory::video_render(void* inptr, gs_effect_t* effect) std::shared_ptr filter::blur::blur_factory::get_color_converter_effect() { - return color_converter_effect; + return _color_converter_effect; } std::shared_ptr filter::blur::blur_factory::get_mask_effect() { - return mask_effect; + return _mask_effect; } filter::blur::blur_instance::blur_instance(obs_data_t* settings, obs_source_t* parent) - : m_self(parent), m_source_rendered(false), m_output_rendered(false) + : _self(parent), _source_rendered(false), _output_rendered(false) { - m_self = parent; + _self = parent; // Create RenderTargets try { - this->m_source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - this->m_output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } catch (std::exception& ex) { - P_LOG_ERROR(" Failed to create rendertargets, error %s.", obs_source_get_name(m_self), + P_LOG_ERROR(" Failed to create rendertargets, error %s.", obs_source_get_name(_self), ex.what()); } @@ -328,9 +328,9 @@ filter::blur::blur_instance::blur_instance(obs_data_t* settings, obs_source_t* p filter::blur::blur_instance::~blur_instance() { - this->m_mask.source.source_texture.reset(); - this->m_source_rt.reset(); - this->m_output_texture.reset(); + this->_mask.source.source_texture.reset(); + this->_source_rt.reset(); + this->_output_texture.reset(); } bool filter::blur::blur_instance::apply_mask_parameters(std::shared_ptr effect, @@ -344,32 +344,32 @@ bool filter::blur::blur_instance::apply_mask_parameters(std::shared_ptrhas_parameter("mask_region_left")) { - effect->get_parameter("mask_region_left").set_float(m_mask.region.left); + effect->get_parameter("mask_region_left").set_float(_mask.region.left); } if (effect->has_parameter("mask_region_right")) { - effect->get_parameter("mask_region_right").set_float(m_mask.region.right); + effect->get_parameter("mask_region_right").set_float(_mask.region.right); } if (effect->has_parameter("mask_region_top")) { - effect->get_parameter("mask_region_top").set_float(m_mask.region.top); + effect->get_parameter("mask_region_top").set_float(_mask.region.top); } if (effect->has_parameter("mask_region_bottom")) { - effect->get_parameter("mask_region_bottom").set_float(m_mask.region.bottom); + effect->get_parameter("mask_region_bottom").set_float(_mask.region.bottom); } if (effect->has_parameter("mask_region_feather")) { - effect->get_parameter("mask_region_feather").set_float(m_mask.region.feather); + effect->get_parameter("mask_region_feather").set_float(_mask.region.feather); } if (effect->has_parameter("mask_region_feather_shift")) { - effect->get_parameter("mask_region_feather_shift").set_float(m_mask.region.feather_shift); + effect->get_parameter("mask_region_feather_shift").set_float(_mask.region.feather_shift); } } // Image - if (m_mask.type == mask_type::Image) { + if (_mask.type == mask_type::Image) { if (effect->has_parameter("mask_image")) { - if (m_mask.image.texture) { - effect->get_parameter("mask_image").set_texture(m_mask.image.texture); + if (_mask.image.texture) { + effect->get_parameter("mask_image").set_texture(_mask.image.texture); } else { effect->get_parameter("mask_image").set_texture(nullptr); } @@ -377,10 +377,10 @@ bool filter::blur::blur_instance::apply_mask_parameters(std::shared_ptrhas_parameter("mask_image")) { - if (m_mask.source.texture) { - effect->get_parameter("mask_image").set_texture(m_mask.source.texture); + if (_mask.source.texture) { + effect->get_parameter("mask_image").set_texture(_mask.source.texture); } else { effect->get_parameter("mask_image").set_texture(nullptr); } @@ -389,10 +389,10 @@ bool filter::blur::blur_instance::apply_mask_parameters(std::shared_ptrhas_parameter("mask_color")) { - effect->get_parameter("mask_color").set_float4(m_mask.color.r, m_mask.color.g, m_mask.color.b, m_mask.color.a); + effect->get_parameter("mask_color").set_float4(_mask.color.r, _mask.color.g, _mask.color.b, _mask.color.a); } if (effect->has_parameter("mask_multiplier")) { - effect->get_parameter("mask_multiplier").set_float(m_mask.multiplier); + effect->get_parameter("mask_multiplier").set_float(_mask.multiplier); } return true; @@ -403,8 +403,8 @@ bool filter::blur::blur_instance::modified_properties(void*, obs_properties_t* p { obs_property_t* p; const char* propname = obs_property_name(prop); - const char* vtype = obs_data_get_string(settings, P_TYPE); - const char* vsubtype = obs_data_get_string(settings, P_SUBTYPE); + const char* vtype = obs_data_get_string(settings, ST_TYPE); + const char* vsubtype = obs_data_get_string(settings, ST_SUBTYPE); // Find new Type auto type_found = list_of_types.find(vtype); @@ -419,8 +419,8 @@ bool filter::blur::blur_instance::modified_properties(void*, obs_properties_t* p } // Blur Type - if (strcmp(propname, P_TYPE) == 0) { - obs_property_t* prop_subtype = obs_properties_get(props, P_SUBTYPE); + if (strcmp(propname, ST_TYPE) == 0) { + obs_property_t* prop_subtype = obs_properties_get(props, ST_SUBTYPE); /// Disable unsupported items. size_t subvalue_idx = 0; @@ -445,7 +445,7 @@ bool filter::blur::blur_instance::modified_properties(void*, obs_properties_t* p if (obs_property_list_item_disabled(prop_subtype, subvalue_idx)) { for (size_t idx = 0, edx = obs_property_list_item_count(prop_subtype); idx < edx; idx++) { if (!obs_property_list_item_disabled(prop_subtype, idx)) { - obs_data_set_string(settings, P_SUBTYPE, obs_property_list_item_string(prop_subtype, idx)); + obs_data_set_string(settings, ST_SUBTYPE, obs_property_list_item_string(prop_subtype, idx)); // Find new Subtype auto subtype_found2 = list_of_subtypes.find(vsubtype); @@ -464,36 +464,36 @@ bool filter::blur::blur_instance::modified_properties(void*, obs_properties_t* p // Update hover text with new descriptions. if (type_found != list_of_types.end()) { if (type_found->first == "box") { - obs_property_set_long_description(obs_properties_get(props, P_TYPE), P_TRANSLATE(P_DESC(S_BLUR_TYPE_BOX))); + obs_property_set_long_description(obs_properties_get(props, ST_TYPE), D_TRANSLATE(D_DESC(S_BLUR_TYPE_BOX))); } else if (type_found->first == "box_linear") { - obs_property_set_long_description(obs_properties_get(props, P_TYPE), - P_TRANSLATE(P_DESC(S_BLUR_TYPE_BOX_LINEAR))); + obs_property_set_long_description(obs_properties_get(props, ST_TYPE), + D_TRANSLATE(D_DESC(S_BLUR_TYPE_BOX_LINEAR))); } else if (type_found->first == "gaussian") { - obs_property_set_long_description(obs_properties_get(props, P_TYPE), - P_TRANSLATE(P_DESC(S_BLUR_TYPE_GAUSSIAN))); + obs_property_set_long_description(obs_properties_get(props, ST_TYPE), + D_TRANSLATE(D_DESC(S_BLUR_TYPE_GAUSSIAN))); } else if (type_found->first == "gaussian_linear") { - obs_property_set_long_description(obs_properties_get(props, P_TYPE), - P_TRANSLATE(P_DESC(S_BLUR_TYPE_GAUSSIAN_LINEAR))); + obs_property_set_long_description(obs_properties_get(props, ST_TYPE), + D_TRANSLATE(D_DESC(S_BLUR_TYPE_GAUSSIAN_LINEAR))); } } else { - obs_property_set_long_description(obs_properties_get(props, P_TYPE), P_TRANSLATE(P_DESC(P_TYPE))); + obs_property_set_long_description(obs_properties_get(props, ST_TYPE), D_TRANSLATE(D_DESC(ST_TYPE))); } if (subtype_found != list_of_subtypes.end()) { if (subtype_found->first == "area") { - obs_property_set_long_description(obs_properties_get(props, P_SUBTYPE), - P_TRANSLATE(P_DESC(S_BLUR_SUBTYPE_AREA))); + obs_property_set_long_description(obs_properties_get(props, ST_SUBTYPE), + D_TRANSLATE(D_DESC(S_BLUR_SUBTYPE_AREA))); } else if (subtype_found->first == "directional") { - obs_property_set_long_description(obs_properties_get(props, P_SUBTYPE), - P_TRANSLATE(P_DESC(S_BLUR_SUBTYPE_DIRECTIONAL))); + obs_property_set_long_description(obs_properties_get(props, ST_SUBTYPE), + D_TRANSLATE(D_DESC(S_BLUR_SUBTYPE_DIRECTIONAL))); } else if (subtype_found->first == "rotational") { - obs_property_set_long_description(obs_properties_get(props, P_SUBTYPE), - P_TRANSLATE(P_DESC(S_BLUR_SUBTYPE_ROTATIONAL))); + obs_property_set_long_description(obs_properties_get(props, ST_SUBTYPE), + D_TRANSLATE(D_DESC(S_BLUR_SUBTYPE_ROTATIONAL))); } else if (subtype_found->first == "zoom") { - obs_property_set_long_description(obs_properties_get(props, P_SUBTYPE), - P_TRANSLATE(P_DESC(S_BLUR_SUBTYPE_ZOOM))); + obs_property_set_long_description(obs_properties_get(props, ST_SUBTYPE), + D_TRANSLATE(D_DESC(S_BLUR_SUBTYPE_ZOOM))); } } else { - obs_property_set_long_description(obs_properties_get(props, P_SUBTYPE), P_TRANSLATE(P_DESC(P_SUBTYPE))); + obs_property_set_long_description(obs_properties_get(props, ST_SUBTYPE), D_TRANSLATE(D_DESC(ST_SUBTYPE))); } // Blur Sub-Type @@ -503,33 +503,33 @@ bool filter::blur::blur_instance::modified_properties(void*, obs_properties_t* p bool has_center_support = (subtype_found->second.type == ::gfx::blur::type::Rotational) || (subtype_found->second.type == ::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, P_STEPSCALE) && has_stepscale_support; + bool show_scaling = obs_data_get_bool(settings, ST_STEPSCALE) && has_stepscale_support; /// Size - p = obs_properties_get(props, P_SIZE); + p = obs_properties_get(props, ST_SIZE); obs_property_float_set_limits(p, type_found->second.fn().get_min_size(subtype_found->second.type), type_found->second.fn().get_max_size(subtype_found->second.type), type_found->second.fn().get_step_size(subtype_found->second.type)); /// Angle - p = obs_properties_get(props, P_ANGLE); + p = obs_properties_get(props, ST_ANGLE); obs_property_set_visible(p, has_angle_support); obs_property_float_set_limits(p, type_found->second.fn().get_min_angle(subtype_found->second.type), type_found->second.fn().get_max_angle(subtype_found->second.type), type_found->second.fn().get_step_angle(subtype_found->second.type)); /// Center, Radius - obs_property_set_visible(obs_properties_get(props, P_CENTER_X), has_center_support); - obs_property_set_visible(obs_properties_get(props, P_CENTER_Y), has_center_support); + obs_property_set_visible(obs_properties_get(props, ST_CENTER_X), has_center_support); + obs_property_set_visible(obs_properties_get(props, ST_CENTER_Y), has_center_support); /// Step Scaling - obs_property_set_visible(obs_properties_get(props, P_STEPSCALE), has_stepscale_support); - p = obs_properties_get(props, P_STEPSCALE_X); + obs_property_set_visible(obs_properties_get(props, ST_STEPSCALE), has_stepscale_support); + p = obs_properties_get(props, ST_STEPSCALE_X); obs_property_set_visible(p, show_scaling); obs_property_float_set_limits(p, type_found->second.fn().get_min_step_scale_x(subtype_found->second.type), type_found->second.fn().get_max_step_scale_x(subtype_found->second.type), type_found->second.fn().get_step_step_scale_x(subtype_found->second.type)); - p = obs_properties_get(props, P_STEPSCALE_Y); + p = obs_properties_get(props, ST_STEPSCALE_Y); obs_property_set_visible(p, show_scaling); obs_property_float_set_limits(p, type_found->second.fn().get_min_step_scale_x(subtype_found->second.type), type_found->second.fn().get_max_step_scale_x(subtype_found->second.type), @@ -537,24 +537,24 @@ bool filter::blur::blur_instance::modified_properties(void*, obs_properties_t* p } { // Masking - bool show_mask = obs_data_get_bool(settings, P_MASK); - mask_type mtype = static_cast(obs_data_get_int(settings, P_MASK_TYPE)); + 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; bool show_image = (mtype == mask_type::Image) && show_mask; bool show_source = (mtype == mask_type::Source) && show_mask; - obs_property_set_visible(obs_properties_get(props, P_MASK_TYPE), show_mask); - obs_property_set_visible(obs_properties_get(props, P_MASK_REGION_LEFT), show_region); - obs_property_set_visible(obs_properties_get(props, P_MASK_REGION_TOP), show_region); - obs_property_set_visible(obs_properties_get(props, P_MASK_REGION_RIGHT), show_region); - obs_property_set_visible(obs_properties_get(props, P_MASK_REGION_BOTTOM), show_region); - obs_property_set_visible(obs_properties_get(props, P_MASK_REGION_FEATHER), show_region); - obs_property_set_visible(obs_properties_get(props, P_MASK_REGION_FEATHER_SHIFT), show_region); - obs_property_set_visible(obs_properties_get(props, P_MASK_REGION_INVERT), show_region); - obs_property_set_visible(obs_properties_get(props, P_MASK_IMAGE), show_image); - obs_property_set_visible(obs_properties_get(props, P_MASK_SOURCE), show_source); - obs_property_set_visible(obs_properties_get(props, P_MASK_COLOR), show_image || show_source); - obs_property_set_visible(obs_properties_get(props, P_MASK_ALPHA), show_image || show_source); - obs_property_set_visible(obs_properties_get(props, P_MASK_MULTIPLIER), show_image || show_source); + obs_property_set_visible(obs_properties_get(props, ST_MASK_TYPE), show_mask); + obs_property_set_visible(obs_properties_get(props, ST_MASK_REGION_LEFT), show_region); + obs_property_set_visible(obs_properties_get(props, ST_MASK_REGION_TOP), show_region); + obs_property_set_visible(obs_properties_get(props, ST_MASK_REGION_RIGHT), show_region); + obs_property_set_visible(obs_properties_get(props, ST_MASK_REGION_BOTTOM), show_region); + obs_property_set_visible(obs_properties_get(props, ST_MASK_REGION_FEATHER), show_region); + obs_property_set_visible(obs_properties_get(props, ST_MASK_REGION_FEATHER_SHIFT), show_region); + obs_property_set_visible(obs_properties_get(props, ST_MASK_REGION_INVERT), show_region); + obs_property_set_visible(obs_properties_get(props, ST_MASK_IMAGE), show_image); + obs_property_set_visible(obs_properties_get(props, ST_MASK_SOURCE), show_source); + obs_property_set_visible(obs_properties_get(props, ST_MASK_COLOR), show_image || show_source); + obs_property_set_visible(obs_properties_get(props, ST_MASK_ALPHA), show_image || show_source); + obs_property_set_visible(obs_properties_get(props, ST_MASK_MULTIPLIER), show_image || show_source); } return true; @@ -576,32 +576,32 @@ void filter::blur::blur_instance::translate_old_settings(obs_data_t* settings) /// Blur Type int64_t old_blur = obs_data_get_int(settings, "Filter.Blur.Type"); if (old_blur == 0) { // Box - obs_data_set_string(settings, P_TYPE, "box"); + obs_data_set_string(settings, ST_TYPE, "box"); } else if (old_blur == 1) { // Gaussian - obs_data_set_string(settings, P_TYPE, "gaussian"); + obs_data_set_string(settings, ST_TYPE, "gaussian"); } else if (old_blur == 2) { // Bilateral, no longer included. - obs_data_set_string(settings, P_TYPE, "box"); + obs_data_set_string(settings, ST_TYPE, "box"); } else if (old_blur == 3) { // Box Linear - obs_data_set_string(settings, P_TYPE, "box_linear"); + obs_data_set_string(settings, ST_TYPE, "box_linear"); } else if (old_blur == 4) { // Gaussian Linear - obs_data_set_string(settings, P_TYPE, "gaussian_linear"); + obs_data_set_string(settings, ST_TYPE, "gaussian_linear"); } else { - obs_data_set_string(settings, P_TYPE, "box"); + obs_data_set_string(settings, ST_TYPE, "box"); } obs_data_unset_user_value(settings, "Filter.Blur.Type"); /// Directional Blur bool directional = obs_data_get_bool(settings, "Filter.Blur.Directional"); if (directional) { - obs_data_set_string(settings, P_SUBTYPE, "directional"); + obs_data_set_string(settings, ST_SUBTYPE, "directional"); } else { - obs_data_set_string(settings, P_SUBTYPE, "area"); + obs_data_set_string(settings, ST_SUBTYPE, "area"); } obs_data_unset_user_value(settings, "Filter.Blur.Directional"); /// Directional Blur Angle double_t angle = obs_data_get_double(settings, "Filter.Blur.Directional.Angle"); - obs_data_set_double(settings, P_ANGLE, angle); + obs_data_set_double(settings, ST_ANGLE, angle); obs_data_unset_user_value(settings, "Filter.Blur.Directional.Angle"); } @@ -615,87 +615,87 @@ obs_properties_t* filter::blur::blur_instance::get_properties() // Blur Type and Sub-Type { - p = obs_properties_add_list(pr, P_TYPE, P_TRANSLATE(P_TYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_TYPE))); + p = obs_properties_add_list(pr, ST_TYPE, D_TRANSLATE(ST_TYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_TYPE))); obs_property_set_modified_callback2(p, modified_properties, this); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_TYPE_BOX), "box"); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_TYPE_BOX_LINEAR), "box_linear"); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_TYPE_GAUSSIAN), "gaussian"); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_TYPE_GAUSSIAN_LINEAR), "gaussian_linear"); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_TYPE_DUALFILTERING), "dual_filtering"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_TYPE_BOX), "box"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_TYPE_BOX_LINEAR), "box_linear"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_TYPE_GAUSSIAN), "gaussian"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_TYPE_GAUSSIAN_LINEAR), "gaussian_linear"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_TYPE_DUALFILTERING), "dual_filtering"); - p = obs_properties_add_list(pr, P_SUBTYPE, P_TRANSLATE(P_SUBTYPE), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_SUBTYPE, D_TRANSLATE(ST_SUBTYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SUBTYPE))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SUBTYPE))); obs_property_set_modified_callback2(p, modified_properties, this); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_SUBTYPE_AREA), "area"); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_SUBTYPE_DIRECTIONAL), "directional"); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_SUBTYPE_ROTATIONAL), "rotational"); - obs_property_list_add_string(p, P_TRANSLATE(S_BLUR_SUBTYPE_ZOOM), "zoom"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_SUBTYPE_AREA), "area"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_SUBTYPE_DIRECTIONAL), "directional"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_SUBTYPE_ROTATIONAL), "rotational"); + obs_property_list_add_string(p, D_TRANSLATE(S_BLUR_SUBTYPE_ZOOM), "zoom"); } // Blur Parameters { - p = obs_properties_add_float_slider(pr, P_SIZE, P_TRANSLATE(P_SIZE), 1, 32767, 1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SIZE))); + p = obs_properties_add_float_slider(pr, ST_SIZE, D_TRANSLATE(ST_SIZE), 1, 32767, 1); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SIZE))); - p = obs_properties_add_float_slider(pr, P_ANGLE, P_TRANSLATE(P_ANGLE), -180.0, 180.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_ANGLE))); + p = obs_properties_add_float_slider(pr, ST_ANGLE, D_TRANSLATE(ST_ANGLE), -180.0, 180.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_ANGLE))); - p = obs_properties_add_float_slider(pr, P_CENTER_X, P_TRANSLATE(P_CENTER_X), 0.00, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_CENTER_X))); - p = obs_properties_add_float_slider(pr, P_CENTER_Y, P_TRANSLATE(P_CENTER_Y), 0.00, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_CENTER_Y))); + p = obs_properties_add_float_slider(pr, ST_CENTER_X, D_TRANSLATE(ST_CENTER_X), 0.00, 100.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CENTER_X))); + p = obs_properties_add_float_slider(pr, ST_CENTER_Y, D_TRANSLATE(ST_CENTER_Y), 0.00, 100.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CENTER_Y))); - p = obs_properties_add_bool(pr, P_STEPSCALE, P_TRANSLATE(P_STEPSCALE)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_STEPSCALE))); + p = obs_properties_add_bool(pr, ST_STEPSCALE, D_TRANSLATE(ST_STEPSCALE)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_STEPSCALE))); obs_property_set_modified_callback2(p, modified_properties, this); - p = obs_properties_add_float_slider(pr, P_STEPSCALE_X, P_TRANSLATE(P_STEPSCALE_X), 0.0, 1000.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_STEPSCALE_X))); - p = obs_properties_add_float_slider(pr, P_STEPSCALE_Y, P_TRANSLATE(P_STEPSCALE_Y), 0.0, 1000.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_STEPSCALE_Y))); + p = obs_properties_add_float_slider(pr, ST_STEPSCALE_X, D_TRANSLATE(ST_STEPSCALE_X), 0.0, 1000.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_STEPSCALE_X))); + p = obs_properties_add_float_slider(pr, ST_STEPSCALE_Y, D_TRANSLATE(ST_STEPSCALE_Y), 0.0, 1000.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_STEPSCALE_Y))); } // Masking { - p = obs_properties_add_bool(pr, P_MASK, P_TRANSLATE(P_MASK)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK))); + p = obs_properties_add_bool(pr, ST_MASK, D_TRANSLATE(ST_MASK)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK))); obs_property_set_modified_callback2(p, modified_properties, this); - p = obs_properties_add_list(pr, P_MASK_TYPE, P_TRANSLATE(P_MASK_TYPE), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_MASK_TYPE, D_TRANSLATE(ST_MASK_TYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_TYPE))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_TYPE))); obs_property_set_modified_callback2(p, modified_properties, this); - obs_property_list_add_int(p, P_TRANSLATE(P_MASK_TYPE_REGION), mask_type::Region); - obs_property_list_add_int(p, P_TRANSLATE(P_MASK_TYPE_IMAGE), mask_type::Image); - obs_property_list_add_int(p, P_TRANSLATE(P_MASK_TYPE_SOURCE), mask_type::Source); + obs_property_list_add_int(p, D_TRANSLATE(ST_MASK_TYPE_REGION), mask_type::Region); + obs_property_list_add_int(p, D_TRANSLATE(ST_MASK_TYPE_IMAGE), mask_type::Image); + obs_property_list_add_int(p, D_TRANSLATE(ST_MASK_TYPE_SOURCE), mask_type::Source); /// Region - p = obs_properties_add_float_slider(pr, P_MASK_REGION_LEFT, P_TRANSLATE(P_MASK_REGION_LEFT), 0.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_REGION_LEFT))); - p = obs_properties_add_float_slider(pr, P_MASK_REGION_TOP, P_TRANSLATE(P_MASK_REGION_TOP), 0.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_REGION_TOP))); - p = obs_properties_add_float_slider(pr, P_MASK_REGION_RIGHT, P_TRANSLATE(P_MASK_REGION_RIGHT), 0.0, 100.0, + p = obs_properties_add_float_slider(pr, ST_MASK_REGION_LEFT, D_TRANSLATE(ST_MASK_REGION_LEFT), 0.0, 100.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_LEFT))); + p = obs_properties_add_float_slider(pr, ST_MASK_REGION_TOP, D_TRANSLATE(ST_MASK_REGION_TOP), 0.0, 100.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_TOP))); + p = obs_properties_add_float_slider(pr, ST_MASK_REGION_RIGHT, D_TRANSLATE(ST_MASK_REGION_RIGHT), 0.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_REGION_RIGHT))); - p = obs_properties_add_float_slider(pr, P_MASK_REGION_BOTTOM, P_TRANSLATE(P_MASK_REGION_BOTTOM), 0.0, 100.0, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_RIGHT))); + p = obs_properties_add_float_slider(pr, ST_MASK_REGION_BOTTOM, D_TRANSLATE(ST_MASK_REGION_BOTTOM), 0.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_REGION_BOTTOM))); - p = obs_properties_add_float_slider(pr, P_MASK_REGION_FEATHER, P_TRANSLATE(P_MASK_REGION_FEATHER), 0.0, 50.0, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_BOTTOM))); + p = obs_properties_add_float_slider(pr, ST_MASK_REGION_FEATHER, D_TRANSLATE(ST_MASK_REGION_FEATHER), 0.0, 50.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_REGION_FEATHER))); - p = obs_properties_add_float_slider(pr, P_MASK_REGION_FEATHER_SHIFT, P_TRANSLATE(P_MASK_REGION_FEATHER_SHIFT), + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_FEATHER))); + p = obs_properties_add_float_slider(pr, ST_MASK_REGION_FEATHER_SHIFT, D_TRANSLATE(ST_MASK_REGION_FEATHER_SHIFT), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_REGION_FEATHER_SHIFT))); - p = obs_properties_add_bool(pr, P_MASK_REGION_INVERT, P_TRANSLATE(P_MASK_REGION_INVERT)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_REGION_INVERT))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_FEATHER_SHIFT))); + p = obs_properties_add_bool(pr, ST_MASK_REGION_INVERT, D_TRANSLATE(ST_MASK_REGION_INVERT)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_INVERT))); /// Image - p = obs_properties_add_path(pr, P_MASK_IMAGE, P_TRANSLATE(P_MASK_IMAGE), OBS_PATH_FILE, + p = obs_properties_add_path(pr, ST_MASK_IMAGE, D_TRANSLATE(ST_MASK_IMAGE), OBS_PATH_FILE, filter::blur::blur_factory::get()->get_translation("image-filter").c_str(), nullptr); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_IMAGE))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_IMAGE))); /// Source - p = obs_properties_add_list(pr, P_MASK_SOURCE, P_TRANSLATE(P_MASK_SOURCE), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_MASK_SOURCE, D_TRANSLATE(ST_MASK_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_SOURCE))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_SOURCE))); obs_property_list_add_string(p, "", ""); obs::source_tracker::get()->enumerate( [&p](std::string name, obs_source_t*) { @@ -711,12 +711,12 @@ obs_properties_t* filter::blur::blur_instance::get_properties() obs::source_tracker::filter_scenes); /// Shared - p = obs_properties_add_color(pr, P_MASK_COLOR, P_TRANSLATE(P_MASK_COLOR)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_COLOR))); - p = obs_properties_add_float_slider(pr, P_MASK_ALPHA, P_TRANSLATE(P_MASK_ALPHA), 0.0, 100.0, 0.1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_ALPHA))); - p = obs_properties_add_float_slider(pr, P_MASK_MULTIPLIER, P_TRANSLATE(P_MASK_MULTIPLIER), 0.0, 10.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_MASK_MULTIPLIER))); + p = obs_properties_add_color(pr, ST_MASK_COLOR, D_TRANSLATE(ST_MASK_COLOR)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_COLOR))); + p = obs_properties_add_float_slider(pr, ST_MASK_ALPHA, D_TRANSLATE(ST_MASK_ALPHA), 0.0, 100.0, 0.1); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_ALPHA))); + p = obs_properties_add_float_slider(pr, ST_MASK_MULTIPLIER, D_TRANSLATE(ST_MASK_MULTIPLIER), 0.0, 10.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_MULTIPLIER))); } return pr; @@ -728,17 +728,17 @@ void filter::blur::blur_instance::update(obs_data_t* settings) this->translate_old_settings(settings); { // Blur Type - const char* blur_type = obs_data_get_string(settings, P_TYPE); - const char* blur_subtype = obs_data_get_string(settings, P_SUBTYPE); - const char* last_blur_type = obs_data_get_string(settings, P_TYPE ".last"); + const char* blur_type = obs_data_get_string(settings, ST_TYPE); + const char* blur_subtype = obs_data_get_string(settings, ST_SUBTYPE); + const char* last_blur_type = obs_data_get_string(settings, ST_TYPE ".last"); auto type_found = list_of_types.find(blur_type); if (type_found != list_of_types.end()) { auto subtype_found = list_of_subtypes.find(blur_subtype); if (subtype_found != list_of_subtypes.end()) { - if ((strcmp(last_blur_type, blur_type) != 0) || (m_blur->get_type() != subtype_found->second.type)) { + if ((strcmp(last_blur_type, blur_type) != 0) || (_blur->get_type() != subtype_found->second.type)) { if (type_found->second.fn().is_type_supported(subtype_found->second.type)) { - m_blur = type_found->second.fn().create(subtype_found->second.type); + _blur = type_found->second.fn().create(subtype_found->second.type); } } } @@ -746,46 +746,46 @@ void filter::blur::blur_instance::update(obs_data_t* settings) } { // Blur Parameters - this->m_blur_size = obs_data_get_double(settings, P_SIZE); - this->m_blur_angle = obs_data_get_double(settings, P_ANGLE); - this->m_blur_center.first = obs_data_get_double(settings, P_CENTER_X) / 100.0; - this->m_blur_center.second = obs_data_get_double(settings, P_CENTER_Y) / 100.0; + this->_blur_size = obs_data_get_double(settings, ST_SIZE); + this->_blur_angle = obs_data_get_double(settings, ST_ANGLE); + this->_blur_center.first = obs_data_get_double(settings, ST_CENTER_X) / 100.0; + this->_blur_center.second = obs_data_get_double(settings, ST_CENTER_Y) / 100.0; // Scaling - this->m_blur_step_scaling = obs_data_get_bool(settings, P_STEPSCALE); - this->m_blur_step_scale.first = obs_data_get_double(settings, P_STEPSCALE_X) / 100.0; - this->m_blur_step_scale.second = obs_data_get_double(settings, P_STEPSCALE_Y) / 100.0; + this->_blur_step_scaling = obs_data_get_bool(settings, ST_STEPSCALE); + this->_blur_step_scale.first = obs_data_get_double(settings, ST_STEPSCALE_X) / 100.0; + this->_blur_step_scale.second = obs_data_get_double(settings, ST_STEPSCALE_Y) / 100.0; } { // Masking - m_mask.enabled = obs_data_get_bool(settings, P_MASK); - if (m_mask.enabled) { - m_mask.type = static_cast(obs_data_get_int(settings, P_MASK_TYPE)); - switch (m_mask.type) { + _mask.enabled = obs_data_get_bool(settings, ST_MASK); + if (_mask.enabled) { + _mask.type = static_cast(obs_data_get_int(settings, ST_MASK_TYPE)); + switch (_mask.type) { case mask_type::Region: - m_mask.region.left = float_t(obs_data_get_double(settings, P_MASK_REGION_LEFT) / 100.0); - m_mask.region.top = float_t(obs_data_get_double(settings, P_MASK_REGION_TOP) / 100.0); - m_mask.region.right = 1.0f - float_t(obs_data_get_double(settings, P_MASK_REGION_RIGHT) / 100.0); - m_mask.region.bottom = 1.0f - float_t(obs_data_get_double(settings, P_MASK_REGION_BOTTOM) / 100.0); - m_mask.region.feather = float_t(obs_data_get_double(settings, P_MASK_REGION_FEATHER) / 100.0); - m_mask.region.feather_shift = - float_t(obs_data_get_double(settings, P_MASK_REGION_FEATHER_SHIFT) / 100.0); - m_mask.region.invert = obs_data_get_bool(settings, P_MASK_REGION_INVERT); + _mask.region.left = float_t(obs_data_get_double(settings, ST_MASK_REGION_LEFT) / 100.0); + _mask.region.top = float_t(obs_data_get_double(settings, ST_MASK_REGION_TOP) / 100.0); + _mask.region.right = 1.0f - float_t(obs_data_get_double(settings, ST_MASK_REGION_RIGHT) / 100.0); + _mask.region.bottom = 1.0f - float_t(obs_data_get_double(settings, ST_MASK_REGION_BOTTOM) / 100.0); + _mask.region.feather = float_t(obs_data_get_double(settings, ST_MASK_REGION_FEATHER) / 100.0); + _mask.region.feather_shift = + float_t(obs_data_get_double(settings, ST_MASK_REGION_FEATHER_SHIFT) / 100.0); + _mask.region.invert = obs_data_get_bool(settings, ST_MASK_REGION_INVERT); break; case mask_type::Image: - m_mask.image.path = obs_data_get_string(settings, P_MASK_IMAGE); + _mask.image.path = obs_data_get_string(settings, ST_MASK_IMAGE); break; case mask_type::Source: - m_mask.source.name = obs_data_get_string(settings, P_MASK_SOURCE); + _mask.source.name = obs_data_get_string(settings, ST_MASK_SOURCE); break; } - if ((m_mask.type == mask_type::Image) || (m_mask.type == mask_type::Source)) { - uint32_t color = static_cast(obs_data_get_int(settings, P_MASK_COLOR)); - m_mask.color.r = ((color >> 0) & 0xFF) / 255.0f; - m_mask.color.g = ((color >> 8) & 0xFF) / 255.0f; - m_mask.color.b = ((color >> 16) & 0xFF) / 255.0f; - m_mask.color.a = static_cast(obs_data_get_double(settings, P_MASK_ALPHA)); - m_mask.multiplier = float_t(obs_data_get_double(settings, P_MASK_MULTIPLIER)); + if ((_mask.type == mask_type::Image) || (_mask.type == mask_type::Source)) { + uint32_t color = static_cast(obs_data_get_int(settings, ST_MASK_COLOR)); + _mask.color.r = ((color >> 0) & 0xFF) / 255.0f; + _mask.color.g = ((color >> 8) & 0xFF) / 255.0f; + _mask.color.b = ((color >> 16) & 0xFF) / 255.0f; + _mask.color.a = static_cast(obs_data_get_double(settings, ST_MASK_ALPHA)); + _mask.multiplier = float_t(obs_data_get_double(settings, ST_MASK_MULTIPLIER)); } } } @@ -813,56 +813,56 @@ void filter::blur::blur_instance::deactivate() {} void filter::blur::blur_instance::video_tick(float) { // Blur - if (m_blur) { - m_blur->set_size(m_blur_size); - if (m_blur_step_scaling) { - m_blur->set_step_scale(m_blur_step_scale.first, m_blur_step_scale.second); + if (_blur) { + _blur->set_size(_blur_size); + if (_blur_step_scaling) { + _blur->set_step_scale(_blur_step_scale.first, _blur_step_scale.second); } else { - m_blur->set_step_scale(1.0, 1.0); + _blur->set_step_scale(1.0, 1.0); } - if ((m_blur->get_type() == ::gfx::blur::type::Directional) - || (m_blur->get_type() == ::gfx::blur::type::Rotational)) { - auto obj = std::dynamic_pointer_cast<::gfx::blur::ibase_angle>(m_blur); - obj->set_angle(m_blur_angle); + 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); + obj->set_angle(_blur_angle); } - if ((m_blur->get_type() == ::gfx::blur::type::Zoom) || (m_blur->get_type() == ::gfx::blur::type::Rotational)) { - auto obj = std::dynamic_pointer_cast<::gfx::blur::ibase_center>(m_blur); - obj->set_center(m_blur_center.first, m_blur_center.second); + 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); + obj->set_center(_blur_center.first, _blur_center.second); } } // Load Mask - if (m_mask.type == mask_type::Image) { - if (m_mask.image.path_old != m_mask.image.path) { + if (_mask.type == mask_type::Image) { + if (_mask.image.path_old != _mask.image.path) { try { - m_mask.image.texture = std::make_shared(m_mask.image.path); - m_mask.image.path_old = m_mask.image.path; + _mask.image.texture = std::make_shared(_mask.image.path); + _mask.image.path_old = _mask.image.path; } catch (...) { - P_LOG_ERROR(" Instance '%s' failed to load image '%s'.", obs_source_get_name(m_self), - m_mask.image.path.c_str()); + P_LOG_ERROR(" Instance '%s' failed to load image '%s'.", obs_source_get_name(_self), + _mask.image.path.c_str()); } } - } else if (m_mask.type == mask_type::Source) { - if (m_mask.source.name_old != m_mask.source.name) { + } else if (_mask.type == mask_type::Source) { + if (_mask.source.name_old != _mask.source.name) { try { - m_mask.source.source_texture = std::make_shared(m_mask.source.name, m_self); - m_mask.source.is_scene = (obs_scene_from_source(m_mask.source.source_texture->get_object()) != nullptr); - m_mask.source.name_old = m_mask.source.name; + _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 (...) { - P_LOG_ERROR(" Instance '%s' failed to grab source '%s'.", obs_source_get_name(m_self), - m_mask.source.name.c_str()); + P_LOG_ERROR(" Instance '%s' failed to grab source '%s'.", obs_source_get_name(_self), + _mask.source.name.c_str()); } } } - m_source_rendered = false; - m_output_rendered = false; + _source_rendered = false; + _output_rendered = false; } void filter::blur::blur_instance::video_render(gs_effect_t* effect) { - obs_source_t* parent = obs_filter_get_parent(this->m_self); - obs_source_t* target = obs_filter_get_target(this->m_self); + obs_source_t* parent = obs_filter_get_parent(this->_self); + obs_source_t* target = obs_filter_get_target(this->_self); gs_effect_t* defaultEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); uint32_t baseW = obs_source_get_base_width(target); uint32_t baseH = obs_source_get_base_height(target); @@ -873,17 +873,17 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) vec4_set(&black, 0, 0, 0, 0); // Verify that we can actually run first. - if (!target || !parent || !this->m_self || !this->m_blur || (baseW == 0) || (baseH == 0)) { - obs_source_skip_video_filter(this->m_self); + if (!target || !parent || !this->_self || !this->_blur || (baseW == 0) || (baseH == 0)) { + obs_source_skip_video_filter(this->_self); return; } - if (!m_source_rendered) { + if (!_source_rendered) { // Source To Texture { - if (obs_source_process_filter_begin(this->m_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { + if (obs_source_process_filter_begin(this->_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { { - auto op = this->m_source_rt->render(baseW, baseH); + auto op = this->_source_rt->render(baseW, baseH); gs_blend_state_push(); gs_reset_blend_state(); @@ -906,31 +906,31 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) //gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0); // Render - obs_source_process_filter_end(this->m_self, defaultEffect, baseW, baseH); + obs_source_process_filter_end(this->_self, defaultEffect, baseW, baseH); gs_blend_state_pop(); } - m_source_texture = this->m_source_rt->get_texture(); - if (!m_source_texture) { - obs_source_skip_video_filter(this->m_self); + _source_texture = this->_source_rt->get_texture(); + if (!_source_texture) { + obs_source_skip_video_filter(this->_self); return; } } else { - obs_source_skip_video_filter(this->m_self); + obs_source_skip_video_filter(this->_self); return; } } - m_source_rendered = true; + _source_rendered = true; } - if (!m_output_rendered) { - m_blur->set_input(m_source_texture); - m_output_texture = m_blur->render(); + if (!_output_rendered) { + _blur->set_input(_source_texture); + _output_texture = _blur->render(); // Mask - if (m_mask.enabled) { + if (_mask.enabled) { gs_blend_state_push(); gs_reset_blend_state(); gs_enable_color(true, true, true, true); @@ -945,16 +945,16 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); std::string technique = ""; - switch (this->m_mask.type) { + switch (this->_mask.type) { case Region: - if (this->m_mask.region.feather > std::numeric_limits::epsilon()) { - if (this->m_mask.region.invert) { + if (this->_mask.region.feather > std::numeric_limits::epsilon()) { + if (this->_mask.region.invert) { technique = "RegionFeatherInverted"; } else { technique = "RegionFeather"; } } else { - if (this->m_mask.region.invert) { + if (this->_mask.region.invert) { technique = "RegionInverted"; } else { technique = "Region"; @@ -967,9 +967,9 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) break; } - if (m_mask.source.source_texture) { - uint32_t source_width = obs_source_get_width(this->m_mask.source.source_texture->get_object()); - uint32_t source_height = obs_source_get_height(this->m_mask.source.source_texture->get_object()); + if (_mask.source.source_texture) { + uint32_t source_width = obs_source_get_width(this->_mask.source.source_texture->get_object()); + uint32_t source_height = obs_source_get_height(this->_mask.source.source_texture->get_object()); if (source_width == 0) { source_width = baseW; @@ -977,7 +977,7 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) if (source_height == 0) { source_height = baseH; } - if (this->m_mask.source.is_scene) { + if (this->_mask.source.is_scene) { obs_video_info ovi; if (obs_get_video_info(&ovi)) { source_width = ovi.base_width; @@ -985,34 +985,34 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) } } - this->m_mask.source.texture = this->m_mask.source.source_texture->render(source_width, source_height); + this->_mask.source.texture = this->_mask.source.source_texture->render(source_width, source_height); } std::shared_ptr mask_effect = blur_factory::get()->get_mask_effect(); - apply_mask_parameters(mask_effect, m_source_texture->get_object(), m_output_texture->get_object()); + apply_mask_parameters(mask_effect, _source_texture->get_object(), _output_texture->get_object()); try { - auto op = this->m_output_rt->render(baseW, baseH); + auto op = this->_output_rt->render(baseW, baseH); gs_ortho(0, (float)baseW, 0, (float)baseH, -1, 1); // Render while (gs_effect_loop(mask_effect->get_object(), technique.c_str())) { - gs_draw_sprite(m_output_texture->get_object(), 0, baseW, baseH); + gs_draw_sprite(_output_texture->get_object(), 0, baseW, baseH); } } catch (const std::exception&) { gs_blend_state_pop(); - obs_source_skip_video_filter(this->m_self); + obs_source_skip_video_filter(this->_self); return; } gs_blend_state_pop(); - if (!(m_output_texture = this->m_output_rt->get_texture())) { - obs_source_skip_video_filter(this->m_self); + if (!(_output_texture = this->_output_rt->get_texture())) { + obs_source_skip_video_filter(this->_self); return; } } - m_output_rendered = true; + _output_rendered = true; } // Draw source @@ -1032,14 +1032,14 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) gs_eparam_t* param = gs_effect_get_param_by_name(finalEffect, "image"); if (!param) { - P_LOG_ERROR(" Failed to set image param.", obs_source_get_name(this->m_self)); - obs_source_skip_video_filter(m_self); + P_LOG_ERROR(" Failed to set image param.", obs_source_get_name(this->_self)); + obs_source_skip_video_filter(_self); return; } else { - gs_effect_set_texture(param, m_output_texture->get_object()); + gs_effect_set_texture(param, _output_texture->get_object()); } while (gs_effect_loop(finalEffect, technique)) { - gs_draw_sprite(m_output_texture->get_object(), 0, baseW, baseH); + gs_draw_sprite(_output_texture->get_object(), 0, baseW, baseH); } } } diff --git a/source/filters/filter-blur.hpp b/source/filters/filter-blur.hpp index 37a546db..aa9fd137 100644 --- a/source/filters/filter-blur.hpp +++ b/source/filters/filter-blur.hpp @@ -52,12 +52,12 @@ namespace filter { }; class blur_factory { - obs_source_info source_info; - std::list sources; - std::shared_ptr color_converter_effect; - std::shared_ptr mask_effect; + obs_source_info _source_info; + std::list _sources; + std::shared_ptr _color_converter_effect; + std::shared_ptr _mask_effect; - std::map translation_map; + std::map _translation_map; public: // Singleton static void initialize(); @@ -98,25 +98,25 @@ namespace filter { }; class blur_instance { - obs_source_t* m_self; + obs_source_t* _self; // Input - std::shared_ptr m_source_rt; - std::shared_ptr m_source_texture; - bool m_source_rendered; + std::shared_ptr _source_rt; + std::shared_ptr _source_texture; + bool _source_rendered; // Rendering - std::shared_ptr m_output_texture; - std::shared_ptr m_output_rt; - bool m_output_rendered; + std::shared_ptr _output_texture; + std::shared_ptr _output_rt; + bool _output_rendered; // Blur - std::shared_ptr<::gfx::blur::ibase> m_blur; - double_t m_blur_size; - double_t m_blur_angle; - std::pair m_blur_center; - bool m_blur_step_scaling; - std::pair m_blur_step_scale; + 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; // Masking struct { @@ -150,7 +150,7 @@ namespace filter { float_t a; } color; float_t multiplier; - } m_mask; + } _mask; public: blur_instance(obs_data_t* settings, obs_source_t* self); diff --git a/source/filters/filter-color-grade.cpp b/source/filters/filter-color-grade.cpp index 201bd741..1285e726 100644 --- a/source/filters/filter-color-grade.cpp +++ b/source/filters/filter-color-grade.cpp @@ -61,15 +61,15 @@ #define TONE_HIG Highlight // Initializer & Finalizer -INITIALIZER(FilterColorGradeInit) +P_INITIALIZER(FilterColorGradeInit) { - initializerFunctions.push_back([] { filter::color_grade::color_grade_factory::initialize(); }); - finalizerFunctions.push_back([] { filter::color_grade::color_grade_factory::finalize(); }); + initializer_functions.push_back([] { filter::color_grade::color_grade_factory::initialize(); }); + finalizer_functions.push_back([] { filter::color_grade::color_grade_factory::finalize(); }); } const char* get_name(void*) { - return P_TRANSLATE(ST); + return D_TRANSLATE(ST); } void get_defaults(obs_data_t* data) @@ -152,13 +152,13 @@ obs_properties_t* get_properties(void*) if (util::are_property_groups_broken()) { auto p = - obs_properties_add_list(pr, ST_TOOL, P_TRANSLATE(ST_TOOL), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_list_add_string(p, P_TRANSLATE(ST_LIFT), ST_LIFT); - obs_property_list_add_string(p, P_TRANSLATE(ST_GAMMA), ST_GAMMA); - obs_property_list_add_string(p, P_TRANSLATE(ST_GAIN), ST_GAIN); - obs_property_list_add_string(p, P_TRANSLATE(ST_OFFSET), ST_OFFSET); - obs_property_list_add_string(p, P_TRANSLATE(ST_TINT), ST_TINT); - obs_property_list_add_string(p, P_TRANSLATE(ST_CORRECTION), ST_CORRECTION); + obs_properties_add_list(pr, ST_TOOL, D_TRANSLATE(ST_TOOL), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); + obs_property_list_add_string(p, D_TRANSLATE(ST_LIFT), ST_LIFT); + obs_property_list_add_string(p, D_TRANSLATE(ST_GAMMA), ST_GAMMA); + obs_property_list_add_string(p, D_TRANSLATE(ST_GAIN), ST_GAIN); + obs_property_list_add_string(p, D_TRANSLATE(ST_OFFSET), ST_OFFSET); + obs_property_list_add_string(p, D_TRANSLATE(ST_TINT), ST_TINT); + obs_property_list_add_string(p, D_TRANSLATE(ST_CORRECTION), ST_CORRECTION); obs_property_set_modified_callback(p, &tool_modified); } @@ -166,80 +166,80 @@ obs_properties_t* get_properties(void*) obs_properties_t* grp = pr; if (!util::are_property_groups_broken()) { grp = obs_properties_create(); - obs_properties_add_group(pr, ST_LIFT, P_TRANSLATE(ST_LIFT), OBS_GROUP_NORMAL, grp); + obs_properties_add_group(pr, ST_LIFT, D_TRANSLATE(ST_LIFT), OBS_GROUP_NORMAL, grp); } - obs_properties_add_float_slider(grp, ST_LIFT_(RED), P_TRANSLATE(ST_LIFT_(RED)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_LIFT_(GREEN), P_TRANSLATE(ST_LIFT_(GREEN)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_LIFT_(BLUE), P_TRANSLATE(ST_LIFT_(BLUE)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_LIFT_(ALL), P_TRANSLATE(ST_LIFT_(ALL)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_LIFT_(RED), D_TRANSLATE(ST_LIFT_(RED)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_LIFT_(GREEN), D_TRANSLATE(ST_LIFT_(GREEN)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_LIFT_(BLUE), D_TRANSLATE(ST_LIFT_(BLUE)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_LIFT_(ALL), D_TRANSLATE(ST_LIFT_(ALL)), -1000.0, 1000.0, 0.01); } { obs_properties_t* grp = pr; if (!util::are_property_groups_broken()) { grp = obs_properties_create(); - obs_properties_add_group(pr, ST_GAMMA, P_TRANSLATE(ST_GAMMA), OBS_GROUP_NORMAL, grp); + obs_properties_add_group(pr, ST_GAMMA, D_TRANSLATE(ST_GAMMA), OBS_GROUP_NORMAL, grp); } - obs_properties_add_float_slider(grp, ST_GAMMA_(RED), P_TRANSLATE(ST_GAMMA_(RED)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_GAMMA_(GREEN), P_TRANSLATE(ST_GAMMA_(GREEN)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_GAMMA_(BLUE), P_TRANSLATE(ST_GAMMA_(BLUE)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_GAMMA_(ALL), P_TRANSLATE(ST_GAMMA_(ALL)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAMMA_(RED), D_TRANSLATE(ST_GAMMA_(RED)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAMMA_(GREEN), D_TRANSLATE(ST_GAMMA_(GREEN)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAMMA_(BLUE), D_TRANSLATE(ST_GAMMA_(BLUE)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAMMA_(ALL), D_TRANSLATE(ST_GAMMA_(ALL)), -1000.0, 1000.0, 0.01); } { obs_properties_t* grp = pr; if (!util::are_property_groups_broken()) { grp = obs_properties_create(); - obs_properties_add_group(pr, ST_GAIN, P_TRANSLATE(ST_GAIN), OBS_GROUP_NORMAL, grp); + obs_properties_add_group(pr, ST_GAIN, D_TRANSLATE(ST_GAIN), OBS_GROUP_NORMAL, grp); } - obs_properties_add_float_slider(grp, ST_GAIN_(RED), P_TRANSLATE(ST_GAIN_(RED)), 0.01, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_GAIN_(GREEN), P_TRANSLATE(ST_GAIN_(GREEN)), 0.01, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_GAIN_(BLUE), P_TRANSLATE(ST_GAIN_(BLUE)), 0.01, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_GAIN_(ALL), P_TRANSLATE(ST_GAIN_(ALL)), 0.01, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAIN_(RED), D_TRANSLATE(ST_GAIN_(RED)), 0.01, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAIN_(GREEN), D_TRANSLATE(ST_GAIN_(GREEN)), 0.01, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAIN_(BLUE), D_TRANSLATE(ST_GAIN_(BLUE)), 0.01, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_GAIN_(ALL), D_TRANSLATE(ST_GAIN_(ALL)), 0.01, 1000.0, 0.01); } { obs_properties_t* grp = pr; if (!util::are_property_groups_broken()) { grp = obs_properties_create(); - obs_properties_add_group(pr, ST_OFFSET, P_TRANSLATE(ST_OFFSET), OBS_GROUP_NORMAL, grp); + obs_properties_add_group(pr, ST_OFFSET, D_TRANSLATE(ST_OFFSET), OBS_GROUP_NORMAL, grp); } - obs_properties_add_float_slider(grp, ST_OFFSET_(RED), P_TRANSLATE(ST_OFFSET_(RED)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_OFFSET_(GREEN), P_TRANSLATE(ST_OFFSET_(GREEN)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_OFFSET_(BLUE), P_TRANSLATE(ST_OFFSET_(BLUE)), -1000.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_OFFSET_(ALL), P_TRANSLATE(ST_OFFSET_(ALL)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_OFFSET_(RED), D_TRANSLATE(ST_OFFSET_(RED)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_OFFSET_(GREEN), D_TRANSLATE(ST_OFFSET_(GREEN)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_OFFSET_(BLUE), D_TRANSLATE(ST_OFFSET_(BLUE)), -1000.0, 1000.0, 0.01); + obs_properties_add_float_slider(grp, ST_OFFSET_(ALL), D_TRANSLATE(ST_OFFSET_(ALL)), -1000.0, 1000.0, 0.01); } { obs_properties_t* grp = pr; if (!util::are_property_groups_broken()) { grp = obs_properties_create(); - obs_properties_add_group(pr, ST_TINT, P_TRANSLATE(ST_TINT), OBS_GROUP_NORMAL, grp); + obs_properties_add_group(pr, ST_TINT, D_TRANSLATE(ST_TINT), OBS_GROUP_NORMAL, grp); } - obs_properties_add_float_slider(grp, ST_TINT_(TONE_LOW, RED), P_TRANSLATE(ST_TINT_(TONE_LOW, RED)), 0, 1000.0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_LOW, RED), D_TRANSLATE(ST_TINT_(TONE_LOW, RED)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_LOW, GREEN), P_TRANSLATE(ST_TINT_(TONE_LOW, GREEN)), 0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_LOW, GREEN), D_TRANSLATE(ST_TINT_(TONE_LOW, GREEN)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_LOW, BLUE), P_TRANSLATE(ST_TINT_(TONE_LOW, BLUE)), 0, 1000.0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_LOW, BLUE), D_TRANSLATE(ST_TINT_(TONE_LOW, BLUE)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_MID, RED), P_TRANSLATE(ST_TINT_(TONE_MID, RED)), 0, 1000.0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_MID, RED), D_TRANSLATE(ST_TINT_(TONE_MID, RED)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_MID, GREEN), P_TRANSLATE(ST_TINT_(TONE_MID, GREEN)), 0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_MID, GREEN), D_TRANSLATE(ST_TINT_(TONE_MID, GREEN)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_MID, BLUE), P_TRANSLATE(ST_TINT_(TONE_MID, BLUE)), 0, 1000.0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_MID, BLUE), D_TRANSLATE(ST_TINT_(TONE_MID, BLUE)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_HIG, RED), P_TRANSLATE(ST_TINT_(TONE_HIG, RED)), 0, 1000.0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_HIG, RED), D_TRANSLATE(ST_TINT_(TONE_HIG, RED)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_HIG, GREEN), P_TRANSLATE(ST_TINT_(TONE_HIG, GREEN)), 0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_HIG, GREEN), D_TRANSLATE(ST_TINT_(TONE_HIG, GREEN)), 0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_TINT_(TONE_HIG, BLUE), P_TRANSLATE(ST_TINT_(TONE_HIG, BLUE)), 0, 1000.0, + obs_properties_add_float_slider(grp, ST_TINT_(TONE_HIG, BLUE), D_TRANSLATE(ST_TINT_(TONE_HIG, BLUE)), 0, 1000.0, 0.01); } @@ -247,15 +247,15 @@ obs_properties_t* get_properties(void*) obs_properties_t* grp = pr; if (!util::are_property_groups_broken()) { grp = obs_properties_create(); - obs_properties_add_group(pr, ST_CORRECTION, P_TRANSLATE(ST_CORRECTION), OBS_GROUP_NORMAL, grp); + obs_properties_add_group(pr, ST_CORRECTION, D_TRANSLATE(ST_CORRECTION), OBS_GROUP_NORMAL, grp); } - obs_properties_add_float_slider(grp, ST_CORRECTION_(HUE), P_TRANSLATE(ST_CORRECTION_(HUE)), -180, 180.0, 0.01); - obs_properties_add_float_slider(grp, ST_CORRECTION_(SATURATION), P_TRANSLATE(ST_CORRECTION_(SATURATION)), 0.0, + obs_properties_add_float_slider(grp, ST_CORRECTION_(HUE), D_TRANSLATE(ST_CORRECTION_(HUE)), -180, 180.0, 0.01); + obs_properties_add_float_slider(grp, ST_CORRECTION_(SATURATION), D_TRANSLATE(ST_CORRECTION_(SATURATION)), 0.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_CORRECTION_(LIGHTNESS), P_TRANSLATE(ST_CORRECTION_(LIGHTNESS)), 0.0, + obs_properties_add_float_slider(grp, ST_CORRECTION_(LIGHTNESS), D_TRANSLATE(ST_CORRECTION_(LIGHTNESS)), 0.0, 1000.0, 0.01); - obs_properties_add_float_slider(grp, ST_CORRECTION_(CONTRAST), P_TRANSLATE(ST_CORRECTION_(CONTRAST)), 0.0, + obs_properties_add_float_slider(grp, ST_CORRECTION_(CONTRAST), D_TRANSLATE(ST_CORRECTION_(CONTRAST)), 0.0, 1000.0, 0.01); } @@ -374,12 +374,12 @@ filter::color_grade::color_grade_instance::color_grade_instance(obs_data_t* data update(data); { - char* file = obs_module_file("effects/color-grade.effect"); + char* file = obs_module_file("effects/color-grade._effect"); try { _effect = std::make_shared(file); bfree(file); } catch (std::runtime_error& ex) { - P_LOG_ERROR(" Loading effect '%s' failed with error(s): %s", file, ex.what()); + P_LOG_ERROR(" Loading _effect '%s' failed with error(s): %s", file, ex.what()); bfree(file); throw ex; } diff --git a/source/filters/filter-custom-shader.cpp b/source/filters/filter-custom-shader.cpp index 0f31fafa..1194e5be 100644 --- a/source/filters/filter-custom-shader.cpp +++ b/source/filters/filter-custom-shader.cpp @@ -59,10 +59,10 @@ enum class ShaderType : int64_t { Text, File }; static filter::CustomShader* handler; -INITIALIZER(HandlerInit) +P_INITIALIZER(HandlerInit) { - initializerFunctions.push_back([] { handler = new filter::CustomShader(); }); - finalizerFunctions.push_back([] { delete handler; }); + initializer_functions.push_back([] { handler = new filter::CustomShader(); }); + finalizer_functions.push_back([] { delete handler; }); } filter::CustomShader::CustomShader() @@ -91,7 +91,7 @@ filter::CustomShader::~CustomShader() {} const char* filter::CustomShader::get_name(void*) { - return P_TRANSLATE(S); + return D_TRANSLATE(S); } void filter::CustomShader::get_defaults(obs_data_t* data) @@ -153,7 +153,7 @@ void filter::CustomShader::video_render(void* ptr, gs_effect_t* effect) filter::CustomShader::Instance::Instance(obs_data_t* data, obs_source_t* source) : gfx::effect_source(data, source) { - m_defaultShaderPath = "shaders/filter/example.effect"; + m_defaultShaderPath = "shaders/filter/example._effect"; m_renderTarget = std::make_shared(GS_RGBA, GS_ZS_NONE); update(data); } diff --git a/source/filters/filter-displacement.cpp b/source/filters/filter-displacement.cpp index 9869342f..43b0123f 100644 --- a/source/filters/filter-displacement.cpp +++ b/source/filters/filter-displacement.cpp @@ -21,11 +21,17 @@ #include #include "strings.hpp" +#define ST "Filter.Displacement" +#define ST_FILE "Filter.Displacement.File" +#define ST_FILE_TYPES "Filter.Displacement.File.Types" +#define ST_RATIO "Filter.Displacement.Ratio" +#define ST_SCALE "Filter.Displacement.Scale" + // Initializer & Finalizer -INITIALIZER(FilterDisplacementInit) +P_INITIALIZER(FilterDisplacementInit) { - initializerFunctions.push_back([] { filter::displacement::displacement_factory::initialize(); }); - finalizerFunctions.push_back([] { filter::displacement::displacement_factory::finalize(); }); + initializer_functions.push_back([] { filter::displacement::displacement_factory::initialize(); }); + finalizer_functions.push_back([] { filter::displacement::displacement_factory::finalize(); }); } static std::shared_ptr factory_instance = nullptr; @@ -47,32 +53,32 @@ std::shared_ptr filter::displacement filter::displacement::displacement_factory::displacement_factory() { - memset(&sourceInfo, 0, sizeof(obs_source_info)); - sourceInfo.id = "obs-stream-effects-filter-displacement"; - sourceInfo.type = OBS_SOURCE_TYPE_FILTER; - sourceInfo.output_flags = OBS_SOURCE_VIDEO; - sourceInfo.get_name = get_name; - sourceInfo.get_defaults = get_defaults; - sourceInfo.get_properties = get_properties; + memset(&_source_info, 0, sizeof(obs_source_info)); + _source_info.id = "obs-stream-effects-filter-displacement"; + _source_info.type = OBS_SOURCE_TYPE_FILTER; + _source_info.output_flags = OBS_SOURCE_VIDEO; + _source_info.get_name = get_name; + _source_info.get_defaults = get_defaults; + _source_info.get_properties = get_properties; - sourceInfo.create = create; - sourceInfo.destroy = destroy; - sourceInfo.update = update; - sourceInfo.activate = activate; - sourceInfo.deactivate = deactivate; - sourceInfo.show = show; - sourceInfo.hide = hide; - sourceInfo.video_tick = video_tick; - sourceInfo.video_render = video_render; + _source_info.create = create; + _source_info.destroy = destroy; + _source_info.update = update; + _source_info.activate = activate; + _source_info.deactivate = deactivate; + _source_info.show = show; + _source_info.hide = hide; + _source_info.video_tick = video_tick; + _source_info.video_render = video_render; - obs_register_source(&sourceInfo); + obs_register_source(&_source_info); } filter::displacement::displacement_factory::~displacement_factory() {} const char* filter::displacement::displacement_factory::get_name(void*) { - return P_TRANSLATE(S_FILTER_DISPLACEMENT); + return D_TRANSLATE(ST); } void* filter::displacement::displacement_factory::create(obs_data_t* data, obs_source_t* source) @@ -98,9 +104,9 @@ uint32_t filter::displacement::displacement_factory::get_height(void* ptr) void filter::displacement::displacement_factory::get_defaults(obs_data_t* data) { char* disp = obs_module_file("filter-displacement/neutral.png"); - obs_data_set_default_string(data, S_FILTER_DISPLACEMENT_FILE, disp); - obs_data_set_default_double(data, S_FILTER_DISPLACEMENT_RATIO, 0); - obs_data_set_default_double(data, S_FILTER_DISPLACEMENT_SCALE, 0); + obs_data_set_default_string(data, ST_FILE, disp); + obs_data_set_default_double(data, ST_RATIO, 0); + obs_data_set_default_double(data, ST_SCALE, 0); bfree(disp); } @@ -112,11 +118,11 @@ obs_properties_t* filter::displacement::displacement_factory::get_properties(voi if (ptr) path = reinterpret_cast(ptr)->get_file(); - obs_properties_add_path(pr, S_FILTER_DISPLACEMENT_FILE, P_TRANSLATE(S_FILTER_DISPLACEMENT_FILE), - obs_path_type::OBS_PATH_FILE, P_TRANSLATE(S_FILTER_DISPLACEMENT_FILE_TYPES), path.c_str()); - obs_properties_add_float_slider(pr, S_FILTER_DISPLACEMENT_RATIO, P_TRANSLATE(S_FILTER_DISPLACEMENT_RATIO), 0, 1, + obs_properties_add_path(pr, ST_FILE, D_TRANSLATE(ST_FILE), + obs_path_type::OBS_PATH_FILE, D_TRANSLATE(ST_FILE_TYPES), path.c_str()); + obs_properties_add_float_slider(pr, ST_RATIO, D_TRANSLATE(ST_RATIO), 0, 1, 0.01); - obs_properties_add_float_slider(pr, S_FILTER_DISPLACEMENT_SCALE, P_TRANSLATE(S_FILTER_DISPLACEMENT_SCALE), -1000, + obs_properties_add_float_slider(pr, ST_SCALE, D_TRANSLATE(ST_SCALE), -1000, 1000, 0.01); return pr; } @@ -166,41 +172,41 @@ void filter::displacement::displacement_instance::validate_file_texture(std::str } // File name different - if (file != m_file_name) { + if (file != _file_name) { do_update = true; - m_file_name = file; + _file_name = file; } // Timestamp verification struct stat stats; - if (os_stat(m_file_name.c_str(), &stats) != 0) { - do_update = do_update || (stats.st_ctime != m_file_create_time); - do_update = do_update || (stats.st_mtime != m_file_modified_time); - do_update = do_update || (static_cast(stats.st_size) != m_file_size); - m_file_create_time = stats.st_ctime; - m_file_modified_time = stats.st_mtime; - m_file_size = static_cast(stats.st_size); + if (os_stat(_file_name.c_str(), &stats) != 0) { + do_update = do_update || (stats.st_ctime != _file_create_time); + do_update = do_update || (stats.st_mtime != _file_modified_time); + do_update = do_update || (static_cast(stats.st_size) != _file_size); + _file_create_time = stats.st_ctime; + _file_modified_time = stats.st_mtime; + _file_size = static_cast(stats.st_size); } - do_update = !m_file_texture || do_update; + do_update = !_file_texture || do_update; if (do_update) { try { - m_file_texture = std::make_shared(m_file_name); + _file_texture = std::make_shared(_file_name); } catch (...) { } } } filter::displacement::displacement_instance::displacement_instance(obs_data_t* data, obs_source_t* context) - : m_self(context), m_timer(0), m_effect(nullptr), m_distance(0), m_file_create_time(0), m_file_modified_time(0), - m_file_size(0) + : _self(context), _timer(0), _effect(nullptr), _distance(0), _file_create_time(0), _file_modified_time(0), + _file_size(0) { - char* effectFile = obs_module_file("effects/displace.effect"); + char* effectFile = obs_module_file("effects/displace._effect"); try { - m_effect = std::make_shared(effectFile); + _effect = std::make_shared(effectFile); } catch (...) { - P_LOG_ERROR(" Failed to load displacement effect.", obs_source_get_name(m_self)); + P_LOG_ERROR(" Failed to load displacement _effect.", obs_source_get_name(_self)); } bfree(effectFile); @@ -209,17 +215,17 @@ filter::displacement::displacement_instance::displacement_instance(obs_data_t* d filter::displacement::displacement_instance::~displacement_instance() { - m_effect.reset(); - m_file_texture.reset(); + _effect.reset(); + _file_texture.reset(); } void filter::displacement::displacement_instance::update(obs_data_t* data) { - validate_file_texture(obs_data_get_string(data, S_FILTER_DISPLACEMENT_FILE)); + validate_file_texture(obs_data_get_string(data, ST_FILE)); - m_distance = float_t(obs_data_get_double(data, S_FILTER_DISPLACEMENT_RATIO)); - vec2_set(&m_displacement_scale, float_t(obs_data_get_double(data, S_FILTER_DISPLACEMENT_SCALE)), - float_t(obs_data_get_double(data, S_FILTER_DISPLACEMENT_SCALE))); + _distance = float_t(obs_data_get_double(data, ST_RATIO)); + vec2_set(&_displacement_scale, float_t(obs_data_get_double(data, ST_SCALE)), + float_t(obs_data_get_double(data, ST_SCALE))); } uint32_t filter::displacement::displacement_instance::get_width() @@ -242,10 +248,10 @@ void filter::displacement::displacement_instance::hide() {} void filter::displacement::displacement_instance::video_tick(float time) { - m_timer += time; - if (m_timer >= 1.0f) { - m_timer -= 1.0f; - validate_file_texture(m_file_name); + _timer += time; + if (_timer >= 1.0f) { + _timer -= 1.0f; + validate_file_texture(_file_name); } } @@ -256,36 +262,36 @@ static float interp(float a, float b, float v) void filter::displacement::displacement_instance::video_render(gs_effect_t*) { - obs_source_t* parent = obs_filter_get_parent(m_self); - obs_source_t* target = obs_filter_get_target(m_self); + obs_source_t* parent = obs_filter_get_parent(_self); + obs_source_t* target = obs_filter_get_target(_self); uint32_t baseW = obs_source_get_base_width(target), baseH = obs_source_get_base_height(target); // Skip rendering if our target, parent or context is not valid. - if (!parent || !target || !baseW || !baseH || !m_file_texture) { - obs_source_skip_video_filter(m_self); + if (!parent || !target || !baseW || !baseH || !_file_texture) { + obs_source_skip_video_filter(_self); return; } - if (!obs_source_process_filter_begin(m_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { - obs_source_skip_video_filter(m_self); + if (!obs_source_process_filter_begin(_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { + obs_source_skip_video_filter(_self); return; } - if (m_effect->has_parameter("texelScale")) { - m_effect->get_parameter("texelScale") - .set_float2(interp((1.0f / baseW), 1.0f, m_distance), interp((1.0f / baseH), 1.0f, m_distance)); + if (_effect->has_parameter("texelScale")) { + _effect->get_parameter("texelScale") + .set_float2(interp((1.0f / baseW), 1.0f, _distance), interp((1.0f / baseH), 1.0f, _distance)); } - if (m_effect->has_parameter("displacementScale")) { - m_effect->get_parameter("displacementScale").set_float2(m_displacement_scale); + if (_effect->has_parameter("displacementScale")) { + _effect->get_parameter("displacementScale").set_float2(_displacement_scale); } - if (m_effect->has_parameter("displacementMap")) { - m_effect->get_parameter("displacementMap").set_texture(m_file_texture); + if (_effect->has_parameter("displacementMap")) { + _effect->get_parameter("displacementMap").set_texture(_file_texture); } - obs_source_process_filter_end(m_self, m_effect->get_object(), baseW, baseH); + obs_source_process_filter_end(_self, _effect->get_object(), baseW, baseH); } std::string filter::displacement::displacement_instance::get_file() { - return m_file_name; + return _file_name; } diff --git a/source/filters/filter-displacement.hpp b/source/filters/filter-displacement.hpp index a5832fbd..3bf19417 100644 --- a/source/filters/filter-displacement.hpp +++ b/source/filters/filter-displacement.hpp @@ -34,16 +34,10 @@ #pragma warning(pop) #endif -#define S_FILTER_DISPLACEMENT "Filter.Displacement" -#define S_FILTER_DISPLACEMENT_FILE "Filter.Displacement.File" -#define S_FILTER_DISPLACEMENT_FILE_TYPES "Filter.Displacement.File.Types" -#define S_FILTER_DISPLACEMENT_RATIO "Filter.Displacement.Ratio" -#define S_FILTER_DISPLACEMENT_SCALE "Filter.Displacement.Scale" - namespace filter { namespace displacement { class displacement_factory { - obs_source_info sourceInfo; + obs_source_info _source_info; public: // Singleton static void initialize(); @@ -72,20 +66,20 @@ namespace filter { }; class displacement_instance { - obs_source_t* m_self; - float_t m_timer; + obs_source_t* _self; + float_t _timer; // Rendering - std::shared_ptr m_effect; - float_t m_distance; - vec2 m_displacement_scale; + std::shared_ptr _effect; + float_t _distance; + vec2 _displacement_scale; // Displacement Map - std::string m_file_name; - std::shared_ptr m_file_texture; - time_t m_file_create_time; - time_t m_file_modified_time; - size_t m_file_size; + std::string _file_name; + std::shared_ptr _file_texture; + time_t _file_create_time; + time_t _file_modified_time; + size_t _file_size; void validate_file_texture(std::string file); diff --git a/source/filters/filter-dynamic-mask.cpp b/source/filters/filter-dynamic-mask.cpp index 44d35d9b..6e47f24b 100644 --- a/source/filters/filter-dynamic-mask.cpp +++ b/source/filters/filter-dynamic-mask.cpp @@ -30,13 +30,13 @@ // - Green Mask Output // - Alpha Mask Output -#define SOURCE_NAME "Filter.DynamicMask" +#define ST "Filter.DynamicMask" -#define S_INPUT "Filter.DynamicMask.Input" -#define S_CHANNEL "Filter.DynamicMask.Channel" -#define S_CHANNEL_VALUE "Filter.DynamicMask.Channel.Value" -#define S_CHANNEL_MULTIPLIER "Filter.DynamicMask.Channel.Multiplier" -#define S_CHANNEL_INPUT "Filter.DynamicMask.Channel.Input" +#define ST_INPUT "Filter.DynamicMask.Input" +#define ST_CHANNEL "Filter.DynamicMask.Channel" +#define ST_CHANNEL_VALUE "Filter.DynamicMask.Channel.Value" +#define ST_CHANNEL_MULTIPLIER "Filter.DynamicMask.Channel.Multiplier" +#define ST_CHANNEL_INPUT "Filter.DynamicMask.Channel.Input" static std::pair channel_translations[] = { {filter::dynamic_mask::channel::Red, S_CHANNEL_RED}, @@ -45,10 +45,10 @@ static std::pair channel_translation {filter::dynamic_mask::channel::Alpha, S_CHANNEL_ALPHA}, }; -INITIALIZER(FilterDynamicMaskInit) +P_INITIALIZER(FilterDynamicMaskInit) { - initializerFunctions.push_back([] { filter::dynamic_mask::dynamic_mask_factory::initialize(); }); - finalizerFunctions.push_back([] { filter::dynamic_mask::dynamic_mask_factory::finalize(); }); + initializer_functions.push_back([] { filter::dynamic_mask::dynamic_mask_factory::initialize(); }); + finalizer_functions.push_back([] { filter::dynamic_mask::dynamic_mask_factory::finalize(); }); } static std::shared_ptr factory_instance = nullptr; @@ -70,73 +70,73 @@ std::shared_ptr filter::dynamic_mask filter::dynamic_mask::dynamic_mask_factory::dynamic_mask_factory() { - memset(&sourceInfo, 0, sizeof(obs_source_info)); - sourceInfo.id = "obs-stream-effects-filter-dynamic-mask"; - sourceInfo.type = OBS_SOURCE_TYPE_FILTER; - sourceInfo.output_flags = OBS_SOURCE_VIDEO; + memset(&_source_info, 0, sizeof(obs_source_info)); + _source_info.id = "obs-stream-effects-filter-dynamic-mask"; + _source_info.type = OBS_SOURCE_TYPE_FILTER; + _source_info.output_flags = OBS_SOURCE_VIDEO; - sourceInfo.get_name = [](void*) { return P_TRANSLATE(SOURCE_NAME); }; + _source_info.get_name = [](void*) { return D_TRANSLATE(ST); }; - sourceInfo.create = [](obs_data_t* settings, obs_source_t* source) { + _source_info.create = [](obs_data_t* settings, obs_source_t* source) { return reinterpret_cast(new filter::dynamic_mask::dynamic_mask_instance(settings, source)); }; - sourceInfo.destroy = [](void* _ptr) { + _source_info.destroy = [](void* _ptr) { delete reinterpret_cast(_ptr); }; - sourceInfo.get_defaults2 = [](void*, obs_data_t* settings) { - obs_data_set_default_int(settings, S_CHANNEL, static_cast(channel::Red)); + _source_info.get_defaults2 = [](void*, obs_data_t* settings) { + obs_data_set_default_int(settings, ST_CHANNEL, static_cast(channel::Red)); for (auto kv : channel_translations) { - obs_data_set_default_double(settings, (std::string(S_CHANNEL_VALUE) + "." + kv.second).c_str(), 1.0); - obs_data_set_default_double(settings, (std::string(S_CHANNEL_MULTIPLIER) + "." + kv.second).c_str(), 1.0); + obs_data_set_default_double(settings, (std::string(ST_CHANNEL_VALUE) + "." + kv.second).c_str(), 1.0); + obs_data_set_default_double(settings, (std::string(ST_CHANNEL_MULTIPLIER) + "." + kv.second).c_str(), 1.0); for (auto kv2 : channel_translations) { obs_data_set_default_double( - settings, (std::string(S_CHANNEL_INPUT) + "." + kv.second + "." + kv2.second).c_str(), 0.0); + settings, (std::string(ST_CHANNEL_INPUT) + "." + kv.second + "." + kv2.second).c_str(), 0.0); } } }; - sourceInfo.get_properties2 = [](void* _ptr, void* _type_data_ptr) { + _source_info.get_properties2 = [](void* _ptr, void* _type_data_ptr) { obs_properties_t* props = obs_properties_create_param(_type_data_ptr, nullptr); reinterpret_cast(_ptr)->get_properties(props); return props; }; - sourceInfo.update = [](void* _ptr, obs_data_t* settings) { + _source_info.update = [](void* _ptr, obs_data_t* settings) { reinterpret_cast(_ptr)->update(settings); }; - sourceInfo.load = [](void* _ptr, obs_data_t* settings) { + _source_info.load = [](void* _ptr, obs_data_t* settings) { reinterpret_cast(_ptr)->load(settings); }; - sourceInfo.save = [](void* _ptr, obs_data_t* settings) { + _source_info.save = [](void* _ptr, obs_data_t* settings) { reinterpret_cast(_ptr)->save(settings); }; - sourceInfo.video_tick = [](void* _ptr, float_t _seconds) { + _source_info.video_tick = [](void* _ptr, float_t _seconds) { reinterpret_cast(_ptr)->video_tick(_seconds); }; - sourceInfo.video_render = [](void* _ptr, gs_effect_t* _effect) { + _source_info.video_render = [](void* _ptr, gs_effect_t* _effect) { reinterpret_cast(_ptr)->video_render(_effect); }; - obs_register_source(&sourceInfo); + obs_register_source(&_source_info); } filter::dynamic_mask::dynamic_mask_factory::~dynamic_mask_factory() {} -filter::dynamic_mask::dynamic_mask_instance::dynamic_mask_instance(obs_data_t* data, obs_source_t* self) : self(self) +filter::dynamic_mask::dynamic_mask_instance::dynamic_mask_instance(obs_data_t* data, obs_source_t* self) : _self(self) { this->update(data); - this->filter_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - this->final_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_filter_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_final_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); { - char* file = obs_module_file("effects/channel-mask.effect"); + char* file = obs_module_file("effects/channel-mask._effect"); try { - this->effect = std::make_shared(file); + this->_effect = std::make_shared(file); } catch (std::exception& ex) { - P_LOG_ERROR("Loading channel mask effect failed with error(s):\n%s", ex.what()); + P_LOG_ERROR("Loading channel mask _effect failed with error(s):\n%s", ex.what()); } - assert(this->effect != nullptr); + assert(this->_effect != nullptr); bfree(file); } } @@ -157,17 +157,17 @@ void filter::dynamic_mask::dynamic_mask_instance::get_properties(obs_properties_ { obs_property_t* p; - this->translation_map.clear(); + this->_translation_map.clear(); { - p = obs_properties_add_list(properties, S_INPUT, P_TRANSLATE(S_INPUT), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(properties, ST_INPUT, D_TRANSLATE(ST_INPUT), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_INPUT))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_INPUT))); obs_property_list_add_string(p, "", ""); obs::source_tracker::get()->enumerate( [&p](std::string name, obs_source_t*) { std::stringstream sstr; - sstr << name << " (" << P_TRANSLATE(S_SOURCETYPE_SOURCE) << ")"; + sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SOURCE) << ")"; obs_property_list_add_string(p, sstr.str().c_str(), name.c_str()); return false; }, @@ -175,7 +175,7 @@ void filter::dynamic_mask::dynamic_mask_instance::get_properties(obs_properties_ obs::source_tracker::get()->enumerate( [&p](std::string name, obs_source_t*) { std::stringstream sstr; - sstr << name << " (" << P_TRANSLATE(S_SOURCETYPE_SCENE) << ")"; + sstr << name << " (" << D_TRANSLATE(S_SOURCETYPE_SCENE) << ")"; obs_property_list_add_string(p, sstr.str().c_str(), name.c_str()); return false; }, @@ -183,62 +183,62 @@ void filter::dynamic_mask::dynamic_mask_instance::get_properties(obs_properties_ } { - p = obs_properties_add_list(properties, S_CHANNEL, P_TRANSLATE(S_CHANNEL), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(properties, ST_CHANNEL, D_TRANSLATE(ST_CHANNEL), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_CHANNEL))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CHANNEL))); for (auto kv : channel_translations) { - obs_property_list_add_int(p, P_TRANSLATE(kv.second), static_cast(kv.first)); + obs_property_list_add_int(p, D_TRANSLATE(kv.second), static_cast(kv.first)); } obs_property_set_modified_callback2(p, modified, this); for (auto kv : channel_translations) { - std::string color = P_TRANSLATE(kv.second); + std::string color = D_TRANSLATE(kv.second); { - std::string _chv = P_TRANSLATE(S_CHANNEL_VALUE); + std::string _chv = D_TRANSLATE(ST_CHANNEL_VALUE); std::vector _chv_data(_chv.size() * 2 + color.size() * 2, '\0'); sprintf_s(_chv_data.data(), _chv_data.size(), _chv.c_str(), color.c_str()); - auto _chv_key = std::tuple{kv.first, channel::Invalid, std::string(S_CHANNEL_VALUE)}; - translation_map.insert({_chv_key, std::string(_chv_data.begin(), _chv_data.end())}); - auto chv = translation_map.find(_chv_key); - std::string chv_key = std::string(S_CHANNEL_VALUE) + "." + kv.second; + auto _chv_key = std::tuple{kv.first, channel::Invalid, std::string(ST_CHANNEL_VALUE)}; + _translation_map.insert({_chv_key, std::string(_chv_data.begin(), _chv_data.end())}); + auto chv = _translation_map.find(_chv_key); + std::string chv_key = std::string(ST_CHANNEL_VALUE) + "." + kv.second; p = obs_properties_add_float_slider(properties, chv_key.c_str(), chv->second.c_str(), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_CHANNEL_VALUE))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CHANNEL_VALUE))); - std::string _chm = P_TRANSLATE(S_CHANNEL_MULTIPLIER); + std::string _chm = D_TRANSLATE(ST_CHANNEL_MULTIPLIER); std::vector _chm_data(_chm.size() * 2 + color.size() * 2, '\0'); sprintf_s(_chm_data.data(), _chm_data.size(), _chm.c_str(), color.c_str()); - auto _chm_key = std::tuple{kv.first, channel::Invalid, std::string(S_CHANNEL_MULTIPLIER)}; - translation_map.insert({_chm_key, std::string(_chm_data.begin(), _chm_data.end())}); - auto chm = translation_map.find(_chm_key); - std::string chm_key = std::string(S_CHANNEL_MULTIPLIER) + "." + kv.second; + auto _chm_key = std::tuple{kv.first, channel::Invalid, std::string(ST_CHANNEL_MULTIPLIER)}; + _translation_map.insert({_chm_key, std::string(_chm_data.begin(), _chm_data.end())}); + auto chm = _translation_map.find(_chm_key); + std::string chm_key = std::string(ST_CHANNEL_MULTIPLIER) + "." + kv.second; p = obs_properties_add_float_slider(properties, chm_key.c_str(), chm->second.c_str(), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_CHANNEL_MULTIPLIER))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CHANNEL_MULTIPLIER))); } } } { for (auto kv1 : channel_translations) { - std::string color1 = P_TRANSLATE(kv1.second); + std::string color1 = D_TRANSLATE(kv1.second); for (auto kv2 : channel_translations) { - std::string color2 = P_TRANSLATE(kv2.second); + std::string color2 = D_TRANSLATE(kv2.second); - std::string _chm = P_TRANSLATE(S_CHANNEL_INPUT); + std::string _chm = D_TRANSLATE(ST_CHANNEL_INPUT); std::vector _chm_data(_chm.size() * 2 + color1.size() * 2 + color2.size() * 2, '\0'); sprintf_s(_chm_data.data(), _chm_data.size(), _chm.c_str(), color1.c_str(), color2.c_str()); - auto _chm_key = std::tuple{kv1.first, kv2.first, std::string(S_CHANNEL_INPUT)}; - translation_map.insert({_chm_key, std::string(_chm_data.begin(), _chm_data.end())}); - auto chm = translation_map.find(_chm_key); - std::string chm_key = std::string(S_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; + auto _chm_key = std::tuple{kv1.first, kv2.first, std::string(ST_CHANNEL_INPUT)}; + _translation_map.insert({_chm_key, std::string(_chm_data.begin(), _chm_data.end())}); + auto chm = _translation_map.find(_chm_key); + std::string chm_key = std::string(ST_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; p = obs_properties_add_float_slider(properties, chm_key.c_str(), chm->second.c_str(), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_CHANNEL_INPUT))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CHANNEL_INPUT))); } } } @@ -248,54 +248,54 @@ void filter::dynamic_mask::dynamic_mask_instance::update(obs_data_t* settings) { // Update source. try { - this->input = std::make_shared(obs_data_get_string(settings, S_INPUT)); - this->input_capture = std::make_shared(this->input, self); - this->input->events.rename += std::bind(&filter::dynamic_mask::dynamic_mask_instance::input_renamed, this, + this->_input = std::make_shared(obs_data_get_string(settings, ST_INPUT)); + this->_input_capture = std::make_shared(this->_input, _self); + this->_input->events.rename += std::bind(&filter::dynamic_mask::dynamic_mask_instance::input_renamed, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); } catch (...) { - this->input.reset(); - this->input_capture.reset(); - this->input_texture.reset(); + this->_input.reset(); + this->_input_capture.reset(); + this->_input_texture.reset(); } // Update data store for (auto kv1 : channel_translations) { - auto found = this->channels.find(kv1.first); - if (found == this->channels.end()) { - this->channels.insert({kv1.first, channel_data()}); - found = this->channels.find(kv1.first); - if (found == this->channels.end()) { - assert(found != this->channels.end()); - throw std::exception("Unable to insert element into data store."); + auto found = this->_channels.find(kv1.first); + if (found == this->_channels.end()) { + this->_channels.insert({kv1.first, channel_data()}); + found = this->_channels.find(kv1.first); + if (found == this->_channels.end()) { + assert(found != this->_channels.end()); + throw std::exception("Unable to insert element into data _store."); } } - std::string chv_key = std::string(S_CHANNEL_VALUE) + "." + kv1.second; + std::string chv_key = std::string(ST_CHANNEL_VALUE) + "." + kv1.second; found->second.value = static_cast(obs_data_get_double(settings, chv_key.c_str())); - this->precalc.base.ptr[static_cast(kv1.first)] = found->second.value; + this->_precalc.base.ptr[static_cast(kv1.first)] = found->second.value; - std::string chm_key = std::string(S_CHANNEL_MULTIPLIER) + "." + kv1.second; + std::string chm_key = std::string(ST_CHANNEL_MULTIPLIER) + "." + kv1.second; found->second.scale = static_cast(obs_data_get_double(settings, chm_key.c_str())); - this->precalc.scale.ptr[static_cast(kv1.first)] = found->second.scale; + this->_precalc.scale.ptr[static_cast(kv1.first)] = found->second.scale; vec4* ch = nullptr; switch (kv1.first) { case channel::Red: - ch = &this->precalc.matrix.x; + ch = &this->_precalc.matrix.x; break; case channel::Green: - ch = &this->precalc.matrix.y; + ch = &this->_precalc.matrix.y; break; case channel::Blue: - ch = &this->precalc.matrix.z; + ch = &this->_precalc.matrix.z; break; case channel::Alpha: - ch = &this->precalc.matrix.t; + ch = &this->_precalc.matrix.t; break; } for (auto kv2 : channel_translations) { - std::string ab_key = std::string(S_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; + std::string ab_key = std::string(ST_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; found->second.values.ptr[static_cast(kv2.first)] = static_cast(obs_data_get_double(settings, ab_key.c_str())); ch->ptr[static_cast(kv2.first)] = found->second.values.ptr[static_cast(kv2.first)]; @@ -310,29 +310,29 @@ void filter::dynamic_mask::dynamic_mask_instance::load(obs_data_t* settings) void filter::dynamic_mask::dynamic_mask_instance::save(obs_data_t* settings) { - if (this->input) { - obs_data_set_string(settings, S_INPUT, obs_source_get_name(this->input->get())); + if (this->_input) { + obs_data_set_string(settings, ST_INPUT, obs_source_get_name(this->_input->get())); } for (auto kv1 : channel_translations) { - auto found = this->channels.find(kv1.first); - if (found == this->channels.end()) { - this->channels.insert({kv1.first, channel_data()}); - found = this->channels.find(kv1.first); - if (found == this->channels.end()) { - assert(found != this->channels.end()); - throw std::exception("Unable to insert element into data store."); + auto found = this->_channels.find(kv1.first); + if (found == this->_channels.end()) { + this->_channels.insert({kv1.first, channel_data()}); + found = this->_channels.find(kv1.first); + if (found == this->_channels.end()) { + assert(found != this->_channels.end()); + throw std::exception("Unable to insert element into data _store."); } } - std::string chv_key = std::string(S_CHANNEL_VALUE) + "." + kv1.second; + std::string chv_key = std::string(ST_CHANNEL_VALUE) + "." + kv1.second; obs_data_set_double(settings, chv_key.c_str(), static_cast(found->second.value)); - std::string chm_key = std::string(S_CHANNEL_MULTIPLIER) + "." + kv1.second; + std::string chm_key = std::string(ST_CHANNEL_MULTIPLIER) + "." + kv1.second; obs_data_set_double(settings, chm_key.c_str(), static_cast(found->second.scale)); for (auto kv2 : channel_translations) { - std::string ab_key = std::string(S_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; + std::string ab_key = std::string(ST_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; obs_data_set_double(settings, ab_key.c_str(), static_cast(found->second.values.ptr[static_cast(kv2.first)])); } @@ -342,24 +342,24 @@ void filter::dynamic_mask::dynamic_mask_instance::save(obs_data_t* settings) void filter::dynamic_mask::dynamic_mask_instance::input_renamed(obs::source*, std::string old_name, std::string new_name) { - obs_data_t* settings = obs_source_get_settings(self); - obs_data_set_string(settings, S_INPUT, new_name.c_str()); - obs_source_update(self, settings); + obs_data_t* settings = obs_source_get_settings(_self); + obs_data_set_string(settings, ST_INPUT, new_name.c_str()); + obs_source_update(_self, settings); } bool filter::dynamic_mask::dynamic_mask_instance::modified(void*, obs_properties_t* properties, obs_property_t*, obs_data_t* settings) { - channel mask = static_cast(obs_data_get_int(settings, S_CHANNEL)); + channel mask = static_cast(obs_data_get_int(settings, ST_CHANNEL)); for (auto kv1 : channel_translations) { - std::string chv_key = std::string(S_CHANNEL_VALUE) + "." + kv1.second; + std::string chv_key = std::string(ST_CHANNEL_VALUE) + "." + kv1.second; obs_property_set_visible(obs_properties_get(properties, chv_key.c_str()), (mask == kv1.first)); - std::string chm_key = std::string(S_CHANNEL_MULTIPLIER) + "." + kv1.second; + std::string chm_key = std::string(ST_CHANNEL_MULTIPLIER) + "." + kv1.second; obs_property_set_visible(obs_properties_get(properties, chm_key.c_str()), (mask == kv1.first)); for (auto kv2 : channel_translations) { - std::string io_key = std::string(S_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; + std::string io_key = std::string(ST_CHANNEL_INPUT) + "." + kv1.second + "." + kv2.second; obs_property_set_visible(obs_properties_get(properties, io_key.c_str()), (mask == kv1.first)); } } @@ -369,32 +369,32 @@ bool filter::dynamic_mask::dynamic_mask_instance::modified(void*, obs_properties void filter::dynamic_mask::dynamic_mask_instance::video_tick(float) { - have_input_texture = false; - have_filter_texture = false; - have_final_texture = false; + _have_input_texture = false; + _have_filter_texture = false; + _have_final_texture = false; } void filter::dynamic_mask::dynamic_mask_instance::video_render(gs_effect_t* in_effect) { - obs_source_t* parent = obs_filter_get_parent(this->self); - obs_source_t* target = obs_filter_get_target(this->self); + obs_source_t* parent = obs_filter_get_parent(this->_self); + obs_source_t* target = obs_filter_get_target(this->_self); uint32_t width = obs_source_get_base_width(target); uint32_t height = obs_source_get_base_height(target); - if (!self || !parent || !target || !width || !height || !input || !input_capture || !effect) { - obs_source_skip_video_filter(self); + if (!_self || !parent || !target || !width || !height || !_input || !_input_capture || !_effect) { + obs_source_skip_video_filter(_self); return; - } else if (!input->width() || !input->height()) { - obs_source_skip_video_filter(self); + } else if (!_input->width() || !_input->height()) { + obs_source_skip_video_filter(_self); return; } gs_effect_t* default_effect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); try { // Capture filter and input - if (!have_filter_texture) { - if (obs_source_process_filter_begin(this->self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { - auto op = this->filter_rt->render(width, height); + if (!_have_filter_texture) { + if (obs_source_process_filter_begin(this->_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { + auto op = this->_filter_rt->render(width, height); gs_blend_state_push(); gs_reset_blend_state(); @@ -413,26 +413,26 @@ void filter::dynamic_mask::dynamic_mask_instance::video_render(gs_effect_t* in_e gs_stencil_op(GS_STENCIL_BOTH, GS_KEEP, GS_KEEP, GS_KEEP); gs_ortho(0, (float)width, 0, (float)height, -1., 1.); - obs_source_process_filter_end(this->self, default_effect, width, height); + obs_source_process_filter_end(this->_self, default_effect, width, height); gs_blend_state_pop(); } else { throw std::exception("Failed to render filter."); } - this->filter_texture = this->filter_rt->get_texture(); - this->have_filter_texture = true; + this->_filter_texture = this->_filter_rt->get_texture(); + this->_have_filter_texture = true; } - if (!have_input_texture) { - this->input_texture = this->input_capture->render(input->width(), input->height()); - this->have_input_texture = true; + if (!_have_input_texture) { + this->_input_texture = this->_input_capture->render(_input->width(), _input->height()); + this->_have_input_texture = true; } // Draw source - if (!this->have_final_texture) { + if (!this->_have_final_texture) { { - auto op = this->final_rt->render(width, height); + auto op = this->_final_rt->render(width, height); gs_blend_state_push(); gs_reset_blend_state(); @@ -451,34 +451,34 @@ void filter::dynamic_mask::dynamic_mask_instance::video_render(gs_effect_t* in_e gs_stencil_op(GS_STENCIL_BOTH, GS_KEEP, GS_KEEP, GS_KEEP); gs_ortho(0, (float)width, 0, (float)height, -1., 1.); - this->effect->get_parameter("pMaskInputA").set_texture(this->filter_texture); - this->effect->get_parameter("pMaskInputB").set_texture(this->input_texture); + this->_effect->get_parameter("pMaskInputA").set_texture(this->_filter_texture); + this->_effect->get_parameter("pMaskInputB").set_texture(this->_input_texture); - this->effect->get_parameter("pMaskBase").set_float4(this->precalc.base); - this->effect->get_parameter("pMaskMatrix").set_matrix(this->precalc.matrix); - this->effect->get_parameter("pMaskMultiplier").set_float4(this->precalc.scale); + this->_effect->get_parameter("pMaskBase").set_float4(this->_precalc.base); + this->_effect->get_parameter("pMaskMatrix").set_matrix(this->_precalc.matrix); + this->_effect->get_parameter("pMaskMultiplier").set_float4(this->_precalc.scale); - while (gs_effect_loop(this->effect->get_object(), "Mask")) { + while (gs_effect_loop(this->_effect->get_object(), "Mask")) { gs_draw_sprite(0, 0, width, height); } gs_blend_state_pop(); } - this->final_texture = this->final_rt->get_texture(); - this->have_final_texture = true; + this->_final_texture = this->_final_rt->get_texture(); + this->_have_final_texture = true; } } catch (...) { - obs_source_skip_video_filter(this->self); + obs_source_skip_video_filter(this->_self); return; } - if (!have_filter_texture || !have_input_texture || !have_final_texture) { - obs_source_skip_video_filter(this->self); + if (!_have_filter_texture || !_have_input_texture || !_have_final_texture) { + obs_source_skip_video_filter(this->_self); return; } - if (!this->filter_texture->get_object() || !this->input_texture->get_object() || !this->final_texture->get_object()) { - obs_source_skip_video_filter(this->self); + if (!this->_filter_texture->get_object() || !this->_input_texture->get_object() || !this->_final_texture->get_object()) { + obs_source_skip_video_filter(this->_self); return; } @@ -497,11 +497,11 @@ void filter::dynamic_mask::dynamic_mask_instance::video_render(gs_effect_t* in_e gs_effect_t* final_effect = in_effect ? in_effect : default_effect; gs_eparam_t* param = gs_effect_get_param_by_name(final_effect, "image"); if (!param) { - P_LOG_ERROR(" Failed to set image param.", obs_source_get_name(this->self)); - obs_source_skip_video_filter(this->self); + P_LOG_ERROR(" Failed to set image param.", obs_source_get_name(this->_self)); + obs_source_skip_video_filter(this->_self); return; } else { - gs_effect_set_texture(param, this->final_texture->get_object()); + gs_effect_set_texture(param, this->_final_texture->get_object()); } while (gs_effect_loop(final_effect, "Draw")) { gs_draw_sprite(0, 0, width, height); diff --git a/source/filters/filter-dynamic-mask.hpp b/source/filters/filter-dynamic-mask.hpp index f3bcdb2d..78025b5f 100644 --- a/source/filters/filter-dynamic-mask.hpp +++ b/source/filters/filter-dynamic-mask.hpp @@ -42,7 +42,7 @@ namespace filter { enum class channel : int8_t { Invalid = -1, Red, Green, Blue, Alpha }; class dynamic_mask_factory { - obs_source_info sourceInfo; + obs_source_info _source_info; public: // Singleton static void initialize(); @@ -55,37 +55,37 @@ namespace filter { }; class dynamic_mask_instance { - obs_source_t* self; + obs_source_t* _self; - std::map, std::string> translation_map; + std::map, std::string> _translation_map; - std::shared_ptr effect; + std::shared_ptr _effect; - bool have_filter_texture; - std::shared_ptr filter_rt; - std::shared_ptr filter_texture; + bool _have_filter_texture; + 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; + bool _have_input_texture; + std::shared_ptr _input; + std::shared_ptr _input_capture; + std::shared_ptr _input_texture; - bool have_final_texture; - std::shared_ptr final_rt; - std::shared_ptr final_texture; + bool _have_final_texture; + std::shared_ptr _final_rt; + std::shared_ptr _final_texture; struct channel_data { float_t value = 0.0; float_t scale = 1.0; vec4 values = {0}; }; - std::map channels; + std::map _channels; struct _precalc { vec4 base; vec4 scale; matrix4 matrix; - } precalc; + } _precalc; public: dynamic_mask_instance(obs_data_t* data, obs_source_t* self); diff --git a/source/filters/filter-sdf-effects.cpp b/source/filters/filter-sdf-effects.cpp index bb44c08d..2863cc21 100644 --- a/source/filters/filter-sdf-effects.cpp +++ b/source/filters/filter-sdf-effects.cpp @@ -24,51 +24,51 @@ #define LOG_PREFIX " " // Translation Strings -#define SOURCE_NAME "Filter.SDFEffects" +#define ST "Filter.SDFEffects" -#define P_SHADOW_INNER "Filter.SDFEffects.Shadow.Inner" -#define P_SHADOW_INNER_RANGE_MINIMUM "Filter.SDFEffects.Shadow.Inner.Range.Minimum" -#define P_SHADOW_INNER_RANGE_MAXIMUM "Filter.SDFEffects.Shadow.Inner.Range.Maximum" -#define P_SHADOW_INNER_OFFSET_X "Filter.SDFEffects.Shadow.Inner.Offset.X" -#define P_SHADOW_INNER_OFFSET_Y "Filter.SDFEffects.Shadow.Inner.Offset.Y" -#define P_SHADOW_INNER_COLOR "Filter.SDFEffects.Shadow.Inner.Color" -#define P_SHADOW_INNER_ALPHA "Filter.SDFEffects.Shadow.Inner.Alpha" +#define ST_SHADOW_INNER "Filter.SDFEffects.Shadow.Inner" +#define ST_SHADOW_INNER_RANGE_MINIMUM "Filter.SDFEffects.Shadow.Inner.Range.Minimum" +#define ST_SHADOW_INNER_RANGE_MAXIMUM "Filter.SDFEffects.Shadow.Inner.Range.Maximum" +#define ST_SHADOW_INNER_OFFSET_X "Filter.SDFEffects.Shadow.Inner.Offset.X" +#define ST_SHADOW_INNER_OFFSET_Y "Filter.SDFEffects.Shadow.Inner.Offset.Y" +#define ST_SHADOW_INNER_COLOR "Filter.SDFEffects.Shadow.Inner.Color" +#define ST_SHADOW_INNER_ALPHA "Filter.SDFEffects.Shadow.Inner.Alpha" -#define P_SHADOW_OUTER "Filter.SDFEffects.Shadow.Outer" -#define P_SHADOW_OUTER_RANGE_MINIMUM "Filter.SDFEffects.Shadow.Outer.Range.Minimum" -#define P_SHADOW_OUTER_RANGE_MAXIMUM "Filter.SDFEffects.Shadow.Outer.Range.Maximum" -#define P_SHADOW_OUTER_OFFSET_X "Filter.SDFEffects.Shadow.Outer.Offset.X" -#define P_SHADOW_OUTER_OFFSET_Y "Filter.SDFEffects.Shadow.Outer.Offset.Y" -#define P_SHADOW_OUTER_COLOR "Filter.SDFEffects.Shadow.Outer.Color" -#define P_SHADOW_OUTER_ALPHA "Filter.SDFEffects.Shadow.Outer.Alpha" +#define ST_SHADOW_OUTER "Filter.SDFEffects.Shadow.Outer" +#define ST_SHADOW_OUTER_RANGE_MINIMUM "Filter.SDFEffects.Shadow.Outer.Range.Minimum" +#define ST_SHADOW_OUTER_RANGE_MAXIMUM "Filter.SDFEffects.Shadow.Outer.Range.Maximum" +#define ST_SHADOW_OUTER_OFFSET_X "Filter.SDFEffects.Shadow.Outer.Offset.X" +#define ST_SHADOW_OUTER_OFFSET_Y "Filter.SDFEffects.Shadow.Outer.Offset.Y" +#define ST_SHADOW_OUTER_COLOR "Filter.SDFEffects.Shadow.Outer.Color" +#define ST_SHADOW_OUTER_ALPHA "Filter.SDFEffects.Shadow.Outer.Alpha" -#define P_GLOW_INNER "Filter.SDFEffects.Glow.Inner" -#define P_GLOW_INNER_COLOR "Filter.SDFEffects.Glow.Inner.Color" -#define P_GLOW_INNER_ALPHA "Filter.SDFEffects.Glow.Inner.Alpha" -#define P_GLOW_INNER_WIDTH "Filter.SDFEffects.Glow.Inner.Width" -#define P_GLOW_INNER_SHARPNESS "Filter.SDFEffects.Glow.Inner.Sharpness" +#define ST_GLOW_INNER "Filter.SDFEffects.Glow.Inner" +#define ST_GLOW_INNER_COLOR "Filter.SDFEffects.Glow.Inner.Color" +#define ST_GLOW_INNER_ALPHA "Filter.SDFEffects.Glow.Inner.Alpha" +#define ST_GLOW_INNER_WIDTH "Filter.SDFEffects.Glow.Inner.Width" +#define ST_GLOW_INNER_SHARPNESS "Filter.SDFEffects.Glow.Inner.Sharpness" -#define P_GLOW_OUTER "Filter.SDFEffects.Glow.Outer" -#define P_GLOW_OUTER_COLOR "Filter.SDFEffects.Glow.Outer.Color" -#define P_GLOW_OUTER_ALPHA "Filter.SDFEffects.Glow.Outer.Alpha" -#define P_GLOW_OUTER_WIDTH "Filter.SDFEffects.Glow.Outer.Width" -#define P_GLOW_OUTER_SHARPNESS "Filter.SDFEffects.Glow.Outer.Sharpness" +#define ST_GLOW_OUTER "Filter.SDFEffects.Glow.Outer" +#define ST_GLOW_OUTER_COLOR "Filter.SDFEffects.Glow.Outer.Color" +#define ST_GLOW_OUTER_ALPHA "Filter.SDFEffects.Glow.Outer.Alpha" +#define ST_GLOW_OUTER_WIDTH "Filter.SDFEffects.Glow.Outer.Width" +#define ST_GLOW_OUTER_SHARPNESS "Filter.SDFEffects.Glow.Outer.Sharpness" -#define P_OUTLINE "Filter.SDFEffects.Outline" -#define P_OUTLINE_COLOR "Filter.SDFEffects.Outline.Color" -#define P_OUTLINE_ALPHA "Filter.SDFEffects.Outline.Alpha" -#define P_OUTLINE_WIDTH "Filter.SDFEffects.Outline.Width" -#define P_OUTLINE_OFFSET "Filter.SDFEffects.Outline.Offset" -#define P_OUTLINE_SHARPNESS "Filter.SDFEffects.Outline.Sharpness" +#define ST_OUTLINE "Filter.SDFEffects.Outline" +#define ST_OUTLINE_COLOR "Filter.SDFEffects.Outline.Color" +#define ST_OUTLINE_ALPHA "Filter.SDFEffects.Outline.Alpha" +#define ST_OUTLINE_WIDTH "Filter.SDFEffects.Outline.Width" +#define ST_OUTLINE_OFFSET "Filter.SDFEffects.Outline.Offset" +#define ST_OUTLINE_SHARPNESS "Filter.SDFEffects.Outline.Sharpness" -#define P_SDF_SCALE "Filter.SDFEffects.SDF.Scale" -#define P_SDF_THRESHOLD "Filter.SDFEffects.SDF.Threshold" +#define ST_SDF_SCALE "Filter.SDFEffects.SDF.Scale" +#define ST_SDF_THRESHOLD "Filter.SDFEffects.SDF.Threshold" // Initializer & Finalizer -INITIALIZER(filterShadowFactoryInitializer) +P_INITIALIZER(filterShadowFactoryInitializer) { - initializerFunctions.push_back([] { filter::sdf_effects::sdf_effects_factory::initialize(); }); - finalizerFunctions.push_back([] { filter::sdf_effects::sdf_effects_factory::finalize(); }); + initializer_functions.push_back([] { filter::sdf_effects::sdf_effects_factory::initialize(); }); + finalizer_functions.push_back([] { filter::sdf_effects::sdf_effects_factory::finalize(); }); } static std::shared_ptr factory_instance = nullptr; @@ -90,23 +90,23 @@ std::shared_ptr filter::sdf_effects::s filter::sdf_effects::sdf_effects_factory::sdf_effects_factory() { - memset(&source_info, 0, sizeof(obs_source_info)); - source_info.id = "obs-stream-effects-filter-sdf-effects"; - source_info.type = OBS_SOURCE_TYPE_FILTER; - source_info.output_flags = OBS_SOURCE_VIDEO; - source_info.get_name = get_name; - source_info.get_defaults = get_defaults; - source_info.get_properties = get_properties; + memset(&_source_info, 0, sizeof(obs_source_info)); + _source_info.id = "obs-stream-effects-filter-sdf-effects"; + _source_info.type = OBS_SOURCE_TYPE_FILTER; + _source_info.output_flags = OBS_SOURCE_VIDEO; + _source_info.get_name = get_name; + _source_info.get_defaults = get_defaults; + _source_info.get_properties = get_properties; - source_info.create = create; - source_info.destroy = destroy; - source_info.update = update; - source_info.activate = activate; - source_info.deactivate = deactivate; - source_info.video_tick = video_tick; - source_info.video_render = video_render; + _source_info.create = create; + _source_info.destroy = destroy; + _source_info.update = update; + _source_info.activate = activate; + _source_info.deactivate = deactivate; + _source_info.video_tick = video_tick; + _source_info.video_render = video_render; - obs_register_source(&source_info); + obs_register_source(&_source_info); } filter::sdf_effects::sdf_effects_factory::~sdf_effects_factory() {} @@ -116,19 +116,19 @@ void filter::sdf_effects::sdf_effects_factory::on_list_fill() auto gctx = gs::context(); std::pair&> load_arr[] = { - {"effects/sdf/sdf-producer.effect", this->sdf_producer_effect}, - {"effects/sdf/sdf-consumer.effect", this->sdf_consumer_effect}, + {"effects/sdf/sdf-producer._effect", this->_sdf_producer_effect}, + {"effects/sdf/sdf-consumer._effect", this->_sdf_consumer_effect}, }; for (auto& kv : load_arr) { char* path = obs_module_file(kv.first); if (!path) { - P_LOG_ERROR(LOG_PREFIX "Unable to load effect '%s' as file is missing or locked.", kv.first); + P_LOG_ERROR(LOG_PREFIX "Unable to load _effect '%s' as file is missing or locked.", kv.first); continue; } try { kv.second = std::make_shared(path); } catch (std::exception& ex) { - P_LOG_ERROR(LOG_PREFIX "Failed to load effect '%s' (located at '%s') with error(s): %s", kv.first, path, + P_LOG_ERROR(LOG_PREFIX "Failed to load _effect '%s' (located at '%s') with error(s): %s", kv.first, path, ex.what()); } bfree(path); @@ -137,17 +137,17 @@ void filter::sdf_effects::sdf_effects_factory::on_list_fill() void filter::sdf_effects::sdf_effects_factory::on_list_empty() { - this->sdf_producer_effect.reset(); - this->sdf_consumer_effect.reset(); + this->_sdf_producer_effect.reset(); + this->_sdf_consumer_effect.reset(); } void* filter::sdf_effects::sdf_effects_factory::create(obs_data_t* data, obs_source_t* parent) { - if (get()->sources.empty()) { + if (get()->_sources.empty()) { get()->on_list_fill(); } filter::sdf_effects::sdf_effects_instance* ptr = new filter::sdf_effects::sdf_effects_instance(data, parent); - get()->sources.push_back(ptr); + get()->_sources.push_back(ptr); return ptr; } @@ -155,8 +155,8 @@ void filter::sdf_effects::sdf_effects_factory::destroy(void* inptr) { filter::sdf_effects::sdf_effects_instance* ptr = reinterpret_cast(inptr); - get()->sources.remove(ptr); - if (get()->sources.empty()) { + get()->_sources.remove(ptr); + if (get()->_sources.empty()) { get()->on_list_empty(); } delete ptr; @@ -164,44 +164,44 @@ void filter::sdf_effects::sdf_effects_factory::destroy(void* inptr) void filter::sdf_effects::sdf_effects_factory::get_defaults(obs_data_t* data) { - obs_data_set_default_bool(data, P_SHADOW_OUTER, false); - obs_data_set_default_int(data, P_SHADOW_OUTER_COLOR, 0x00000000); - obs_data_set_default_double(data, P_SHADOW_OUTER_ALPHA, 100.0); - obs_data_set_default_double(data, P_SHADOW_OUTER_RANGE_MINIMUM, 0.0); - obs_data_set_default_double(data, P_SHADOW_OUTER_RANGE_MAXIMUM, 4.0); - obs_data_set_default_double(data, P_SHADOW_OUTER_OFFSET_X, 0.0); - obs_data_set_default_double(data, P_SHADOW_OUTER_OFFSET_Y, 0.0); + obs_data_set_default_bool(data, ST_SHADOW_OUTER, false); + obs_data_set_default_int(data, ST_SHADOW_OUTER_COLOR, 0x00000000); + obs_data_set_default_double(data, ST_SHADOW_OUTER_ALPHA, 100.0); + obs_data_set_default_double(data, ST_SHADOW_OUTER_RANGE_MINIMUM, 0.0); + obs_data_set_default_double(data, ST_SHADOW_OUTER_RANGE_MAXIMUM, 4.0); + obs_data_set_default_double(data, ST_SHADOW_OUTER_OFFSET_X, 0.0); + obs_data_set_default_double(data, ST_SHADOW_OUTER_OFFSET_Y, 0.0); - obs_data_set_default_bool(data, P_SHADOW_INNER, false); - obs_data_set_default_int(data, P_SHADOW_INNER_COLOR, 0x00000000); - obs_data_set_default_double(data, P_SHADOW_INNER_ALPHA, 100.0); - obs_data_set_default_double(data, P_SHADOW_INNER_RANGE_MINIMUM, 0.0); - obs_data_set_default_double(data, P_SHADOW_INNER_RANGE_MAXIMUM, 4.0); - obs_data_set_default_double(data, P_SHADOW_INNER_OFFSET_X, 0.0); - obs_data_set_default_double(data, P_SHADOW_INNER_OFFSET_Y, 0.0); + obs_data_set_default_bool(data, ST_SHADOW_INNER, false); + obs_data_set_default_int(data, ST_SHADOW_INNER_COLOR, 0x00000000); + obs_data_set_default_double(data, ST_SHADOW_INNER_ALPHA, 100.0); + obs_data_set_default_double(data, ST_SHADOW_INNER_RANGE_MINIMUM, 0.0); + obs_data_set_default_double(data, ST_SHADOW_INNER_RANGE_MAXIMUM, 4.0); + obs_data_set_default_double(data, ST_SHADOW_INNER_OFFSET_X, 0.0); + obs_data_set_default_double(data, ST_SHADOW_INNER_OFFSET_Y, 0.0); - obs_data_set_default_bool(data, P_GLOW_OUTER, false); - obs_data_set_default_int(data, P_GLOW_OUTER_COLOR, 0xFFFFFFFF); - obs_data_set_default_double(data, P_GLOW_OUTER_ALPHA, 100.0); - obs_data_set_default_double(data, P_GLOW_OUTER_WIDTH, 4.0); - obs_data_set_default_double(data, P_GLOW_OUTER_SHARPNESS, 50.0); + obs_data_set_default_bool(data, ST_GLOW_OUTER, false); + obs_data_set_default_int(data, ST_GLOW_OUTER_COLOR, 0xFFFFFFFF); + obs_data_set_default_double(data, ST_GLOW_OUTER_ALPHA, 100.0); + obs_data_set_default_double(data, ST_GLOW_OUTER_WIDTH, 4.0); + obs_data_set_default_double(data, ST_GLOW_OUTER_SHARPNESS, 50.0); - obs_data_set_default_bool(data, P_GLOW_INNER, false); - obs_data_set_default_int(data, P_GLOW_INNER_COLOR, 0xFFFFFFFF); - obs_data_set_default_double(data, P_GLOW_INNER_ALPHA, 100.0); - obs_data_set_default_double(data, P_GLOW_INNER_WIDTH, 4.0); - obs_data_set_default_double(data, P_GLOW_INNER_SHARPNESS, 50.0); + obs_data_set_default_bool(data, ST_GLOW_INNER, false); + obs_data_set_default_int(data, ST_GLOW_INNER_COLOR, 0xFFFFFFFF); + obs_data_set_default_double(data, ST_GLOW_INNER_ALPHA, 100.0); + obs_data_set_default_double(data, ST_GLOW_INNER_WIDTH, 4.0); + obs_data_set_default_double(data, ST_GLOW_INNER_SHARPNESS, 50.0); - obs_data_set_default_bool(data, P_OUTLINE, false); - obs_data_set_default_int(data, P_OUTLINE_COLOR, 0x00000000); - obs_data_set_default_double(data, P_OUTLINE_ALPHA, 100.0); - obs_data_set_default_double(data, P_OUTLINE_WIDTH, 4.0); - obs_data_set_default_double(data, P_OUTLINE_OFFSET, 0.0); - obs_data_set_default_double(data, P_OUTLINE_SHARPNESS, 50.0); + obs_data_set_default_bool(data, ST_OUTLINE, false); + obs_data_set_default_int(data, ST_OUTLINE_COLOR, 0x00000000); + obs_data_set_default_double(data, ST_OUTLINE_ALPHA, 100.0); + obs_data_set_default_double(data, ST_OUTLINE_WIDTH, 4.0); + obs_data_set_default_double(data, ST_OUTLINE_OFFSET, 0.0); + obs_data_set_default_double(data, ST_OUTLINE_SHARPNESS, 50.0); obs_data_set_default_bool(data, S_ADVANCED, false); - obs_data_set_default_double(data, P_SDF_SCALE, 100.0); - obs_data_set_default_double(data, P_SDF_THRESHOLD, 50.0); + obs_data_set_default_double(data, ST_SDF_SCALE, 100.0); + obs_data_set_default_double(data, ST_SDF_THRESHOLD, 50.0); } obs_properties_t* filter::sdf_effects::sdf_effects_factory::get_properties(void* inptr) @@ -216,7 +216,7 @@ void filter::sdf_effects::sdf_effects_factory::update(void* inptr, obs_data_t* s const char* filter::sdf_effects::sdf_effects_factory::get_name(void*) { - return P_TRANSLATE(SOURCE_NAME); + return D_TRANSLATE(ST); } uint32_t filter::sdf_effects::sdf_effects_factory::get_width(void* inptr) @@ -251,71 +251,71 @@ void filter::sdf_effects::sdf_effects_factory::video_render(void* inptr, gs_effe std::shared_ptr filter::sdf_effects::sdf_effects_factory::get_sdf_producer_effect() { - return this->sdf_producer_effect; + return this->_sdf_producer_effect; } std::shared_ptr filter::sdf_effects::sdf_effects_factory::get_sdf_consumer_effect() { - return this->sdf_consumer_effect; + return this->_sdf_consumer_effect; } bool filter::sdf_effects::sdf_effects_instance::cb_modified_shadow_inside(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) { - bool v = obs_data_get_bool(settings, P_SHADOW_INNER); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_INNER_RANGE_MINIMUM), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_INNER_RANGE_MAXIMUM), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_INNER_OFFSET_X), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_INNER_OFFSET_Y), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_INNER_COLOR), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_INNER_ALPHA), v); + bool v = obs_data_get_bool(settings, ST_SHADOW_INNER); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_INNER_RANGE_MINIMUM), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_INNER_RANGE_MAXIMUM), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_INNER_OFFSET_X), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_INNER_OFFSET_Y), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_INNER_COLOR), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_INNER_ALPHA), v); return true; } bool filter::sdf_effects::sdf_effects_instance::cb_modified_shadow_outside(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) { - bool v = obs_data_get_bool(settings, P_SHADOW_OUTER); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_OUTER_RANGE_MINIMUM), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_OUTER_RANGE_MAXIMUM), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_OUTER_OFFSET_X), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_OUTER_OFFSET_Y), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_OUTER_COLOR), v); - obs_property_set_visible(obs_properties_get(props, P_SHADOW_OUTER_ALPHA), v); + bool v = obs_data_get_bool(settings, ST_SHADOW_OUTER); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_OUTER_RANGE_MINIMUM), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_OUTER_RANGE_MAXIMUM), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_OUTER_OFFSET_X), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_OUTER_OFFSET_Y), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_OUTER_COLOR), v); + obs_property_set_visible(obs_properties_get(props, ST_SHADOW_OUTER_ALPHA), v); return true; } bool filter::sdf_effects::sdf_effects_instance::cb_modified_glow_inside(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) { - bool v = obs_data_get_bool(settings, P_GLOW_INNER); - obs_property_set_visible(obs_properties_get(props, P_GLOW_INNER_COLOR), v); - obs_property_set_visible(obs_properties_get(props, P_GLOW_INNER_ALPHA), v); - obs_property_set_visible(obs_properties_get(props, P_GLOW_INNER_WIDTH), v); - obs_property_set_visible(obs_properties_get(props, P_GLOW_INNER_SHARPNESS), v); + bool v = obs_data_get_bool(settings, ST_GLOW_INNER); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_INNER_COLOR), v); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_INNER_ALPHA), v); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_INNER_WIDTH), v); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_INNER_SHARPNESS), v); return true; } bool filter::sdf_effects::sdf_effects_instance::cb_modified_glow_outside(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) { - bool v = obs_data_get_bool(settings, P_GLOW_OUTER); - obs_property_set_visible(obs_properties_get(props, P_GLOW_OUTER_COLOR), v); - obs_property_set_visible(obs_properties_get(props, P_GLOW_OUTER_ALPHA), v); - obs_property_set_visible(obs_properties_get(props, P_GLOW_OUTER_WIDTH), v); - obs_property_set_visible(obs_properties_get(props, P_GLOW_OUTER_SHARPNESS), v); + bool v = obs_data_get_bool(settings, ST_GLOW_OUTER); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_OUTER_COLOR), v); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_OUTER_ALPHA), v); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_OUTER_WIDTH), v); + obs_property_set_visible(obs_properties_get(props, ST_GLOW_OUTER_SHARPNESS), v); return true; } bool filter::sdf_effects::sdf_effects_instance::cb_modified_outline(void*, obs_properties_t* props, obs_property*, obs_data_t* settings) { - bool v = obs_data_get_bool(settings, P_OUTLINE); - obs_property_set_visible(obs_properties_get(props, P_OUTLINE_COLOR), v); - obs_property_set_visible(obs_properties_get(props, P_OUTLINE_ALPHA), v); - obs_property_set_visible(obs_properties_get(props, P_OUTLINE_WIDTH), v); - obs_property_set_visible(obs_properties_get(props, P_OUTLINE_OFFSET), v); - obs_property_set_visible(obs_properties_get(props, P_OUTLINE_SHARPNESS), v); + bool v = obs_data_get_bool(settings, ST_OUTLINE); + obs_property_set_visible(obs_properties_get(props, ST_OUTLINE_COLOR), v); + obs_property_set_visible(obs_properties_get(props, ST_OUTLINE_ALPHA), v); + obs_property_set_visible(obs_properties_get(props, ST_OUTLINE_WIDTH), v); + obs_property_set_visible(obs_properties_get(props, ST_OUTLINE_OFFSET), v); + obs_property_set_visible(obs_properties_get(props, ST_OUTLINE_SHARPNESS), v); return true; } @@ -323,25 +323,25 @@ bool filter::sdf_effects::sdf_effects_instance::cb_modified_advanced(void*, obs_ obs_data_t* settings) { bool show_advanced = obs_data_get_bool(settings, S_ADVANCED); - obs_property_set_visible(obs_properties_get(props, P_SDF_SCALE), show_advanced); - obs_property_set_visible(obs_properties_get(props, P_SDF_THRESHOLD), show_advanced); + obs_property_set_visible(obs_properties_get(props, ST_SDF_SCALE), show_advanced); + obs_property_set_visible(obs_properties_get(props, ST_SDF_THRESHOLD), show_advanced); return true; } filter::sdf_effects::sdf_effects_instance::sdf_effects_instance(obs_data_t* settings, obs_source_t* self) - : m_self(self), m_source_rendered(false), m_sdf_scale(1.0) + : _self(self), _source_rendered(false), _sdf_scale(1.0) { { auto gctx = gs::context(); vec4 transparent = {0}; - this->m_source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - this->m_sdf_write = std::make_shared(GS_RGBA32F, GS_ZS_NONE); - this->m_sdf_read = std::make_shared(GS_RGBA32F, GS_ZS_NONE); - this->m_output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_source_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_sdf_write = std::make_shared(GS_RGBA32F, GS_ZS_NONE); + this->_sdf_read = std::make_shared(GS_RGBA32F, GS_ZS_NONE); + this->_output_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); - std::shared_ptr initialize_rts[] = {this->m_source_rt, this->m_sdf_write, this->m_sdf_read, - this->m_output_rt}; + std::shared_ptr initialize_rts[] = {this->_source_rt, this->_sdf_write, this->_sdf_read, + this->_output_rt}; for (auto rt : initialize_rts) { auto op = rt->render(1, 1); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &transparent, 0, 0); @@ -358,121 +358,121 @@ obs_properties_t* filter::sdf_effects::sdf_effects_instance::get_properties() obs_property_t* p = nullptr; { - p = obs_properties_add_bool(props, P_SHADOW_OUTER, P_TRANSLATE(P_SHADOW_OUTER)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_OUTER))); + p = obs_properties_add_bool(props, ST_SHADOW_OUTER, D_TRANSLATE(ST_SHADOW_OUTER)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER))); obs_property_set_modified_callback2(p, cb_modified_shadow_outside, this); - p = obs_properties_add_float_slider(props, P_SHADOW_OUTER_RANGE_MINIMUM, - P_TRANSLATE(P_SHADOW_OUTER_RANGE_MINIMUM), -16.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_OUTER_RANGE_MINIMUM))); - p = obs_properties_add_float_slider(props, P_SHADOW_OUTER_RANGE_MAXIMUM, - P_TRANSLATE(P_SHADOW_OUTER_RANGE_MAXIMUM), -16.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_OUTER_RANGE_MAXIMUM))); - p = obs_properties_add_float_slider(props, P_SHADOW_OUTER_OFFSET_X, P_TRANSLATE(P_SHADOW_OUTER_OFFSET_X), + p = obs_properties_add_float_slider(props, ST_SHADOW_OUTER_RANGE_MINIMUM, + D_TRANSLATE(ST_SHADOW_OUTER_RANGE_MINIMUM), -16.0, 16.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_RANGE_MINIMUM))); + p = obs_properties_add_float_slider(props, ST_SHADOW_OUTER_RANGE_MAXIMUM, + D_TRANSLATE(ST_SHADOW_OUTER_RANGE_MAXIMUM), -16.0, 16.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_RANGE_MAXIMUM))); + p = obs_properties_add_float_slider(props, ST_SHADOW_OUTER_OFFSET_X, D_TRANSLATE(ST_SHADOW_OUTER_OFFSET_X), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_OUTER_OFFSET_X))); - p = obs_properties_add_float_slider(props, P_SHADOW_OUTER_OFFSET_Y, P_TRANSLATE(P_SHADOW_OUTER_OFFSET_Y), + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_OFFSET_X))); + p = obs_properties_add_float_slider(props, ST_SHADOW_OUTER_OFFSET_Y, D_TRANSLATE(ST_SHADOW_OUTER_OFFSET_Y), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_OUTER_OFFSET_Y))); - p = obs_properties_add_color(props, P_SHADOW_OUTER_COLOR, P_TRANSLATE(P_SHADOW_OUTER_COLOR)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_OUTER_COLOR))); - p = obs_properties_add_float_slider(props, P_SHADOW_OUTER_ALPHA, P_TRANSLATE(P_SHADOW_OUTER_ALPHA), 0.0, 100.0, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_OFFSET_Y))); + p = obs_properties_add_color(props, ST_SHADOW_OUTER_COLOR, D_TRANSLATE(ST_SHADOW_OUTER_COLOR)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_COLOR))); + p = obs_properties_add_float_slider(props, ST_SHADOW_OUTER_ALPHA, D_TRANSLATE(ST_SHADOW_OUTER_ALPHA), 0.0, 100.0, 0.1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_OUTER_ALPHA))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_ALPHA))); } { - p = obs_properties_add_bool(props, P_SHADOW_INNER, P_TRANSLATE(P_SHADOW_INNER)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_INNER))); + p = obs_properties_add_bool(props, ST_SHADOW_INNER, D_TRANSLATE(ST_SHADOW_INNER)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER))); obs_property_set_modified_callback2(p, cb_modified_shadow_inside, this); - p = obs_properties_add_float_slider(props, P_SHADOW_INNER_RANGE_MINIMUM, - P_TRANSLATE(P_SHADOW_INNER_RANGE_MINIMUM), -16.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_INNER_RANGE_MINIMUM))); - p = obs_properties_add_float_slider(props, P_SHADOW_INNER_RANGE_MAXIMUM, - P_TRANSLATE(P_SHADOW_INNER_RANGE_MAXIMUM), -16.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_INNER_RANGE_MAXIMUM))); - p = obs_properties_add_float_slider(props, P_SHADOW_INNER_OFFSET_X, P_TRANSLATE(P_SHADOW_INNER_OFFSET_X), + p = obs_properties_add_float_slider(props, ST_SHADOW_INNER_RANGE_MINIMUM, + D_TRANSLATE(ST_SHADOW_INNER_RANGE_MINIMUM), -16.0, 16.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_RANGE_MINIMUM))); + p = obs_properties_add_float_slider(props, ST_SHADOW_INNER_RANGE_MAXIMUM, + D_TRANSLATE(ST_SHADOW_INNER_RANGE_MAXIMUM), -16.0, 16.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_RANGE_MAXIMUM))); + p = obs_properties_add_float_slider(props, ST_SHADOW_INNER_OFFSET_X, D_TRANSLATE(ST_SHADOW_INNER_OFFSET_X), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_INNER_OFFSET_X))); - p = obs_properties_add_float_slider(props, P_SHADOW_INNER_OFFSET_Y, P_TRANSLATE(P_SHADOW_INNER_OFFSET_Y), + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_OFFSET_X))); + p = obs_properties_add_float_slider(props, ST_SHADOW_INNER_OFFSET_Y, D_TRANSLATE(ST_SHADOW_INNER_OFFSET_Y), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_INNER_OFFSET_Y))); - p = obs_properties_add_color(props, P_SHADOW_INNER_COLOR, P_TRANSLATE(P_SHADOW_INNER_COLOR)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_INNER_COLOR))); - p = obs_properties_add_float_slider(props, P_SHADOW_INNER_ALPHA, P_TRANSLATE(P_SHADOW_INNER_ALPHA), 0.0, 100.0, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_OFFSET_Y))); + p = obs_properties_add_color(props, ST_SHADOW_INNER_COLOR, D_TRANSLATE(ST_SHADOW_INNER_COLOR)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_COLOR))); + p = obs_properties_add_float_slider(props, ST_SHADOW_INNER_ALPHA, D_TRANSLATE(ST_SHADOW_INNER_ALPHA), 0.0, 100.0, 0.1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SHADOW_INNER_ALPHA))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_ALPHA))); } { - p = obs_properties_add_bool(props, P_GLOW_OUTER, P_TRANSLATE(P_GLOW_OUTER)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_OUTER))); + p = obs_properties_add_bool(props, ST_GLOW_OUTER, D_TRANSLATE(ST_GLOW_OUTER)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_OUTER))); obs_property_set_modified_callback2(p, cb_modified_glow_outside, this); - p = obs_properties_add_color(props, P_GLOW_OUTER_COLOR, P_TRANSLATE(P_GLOW_OUTER_COLOR)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_OUTER_COLOR))); - p = obs_properties_add_float_slider(props, P_GLOW_OUTER_ALPHA, P_TRANSLATE(P_GLOW_OUTER_ALPHA), 0.0, 100.0, + p = obs_properties_add_color(props, ST_GLOW_OUTER_COLOR, D_TRANSLATE(ST_GLOW_OUTER_COLOR)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_OUTER_COLOR))); + p = obs_properties_add_float_slider(props, ST_GLOW_OUTER_ALPHA, D_TRANSLATE(ST_GLOW_OUTER_ALPHA), 0.0, 100.0, 0.1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_OUTER_ALPHA))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_OUTER_ALPHA))); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_OUTER_WIDTH))); - p = obs_properties_add_float_slider(props, P_GLOW_OUTER_WIDTH, P_TRANSLATE(P_GLOW_OUTER_WIDTH), 0.0, 16.0, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_OUTER_WIDTH))); + p = obs_properties_add_float_slider(props, ST_GLOW_OUTER_WIDTH, D_TRANSLATE(ST_GLOW_OUTER_WIDTH), 0.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_OUTER_SHARPNESS))); - p = obs_properties_add_float_slider(props, P_GLOW_OUTER_SHARPNESS, P_TRANSLATE(P_GLOW_OUTER_SHARPNESS), 0.00, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_OUTER_SHARPNESS))); + p = obs_properties_add_float_slider(props, ST_GLOW_OUTER_SHARPNESS, D_TRANSLATE(ST_GLOW_OUTER_SHARPNESS), 0.00, 100.0, 0.01); } { - p = obs_properties_add_bool(props, P_GLOW_INNER, P_TRANSLATE(P_GLOW_INNER)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_INNER))); + p = obs_properties_add_bool(props, ST_GLOW_INNER, D_TRANSLATE(ST_GLOW_INNER)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_INNER))); obs_property_set_modified_callback2(p, cb_modified_glow_inside, this); - p = obs_properties_add_color(props, P_GLOW_INNER_COLOR, P_TRANSLATE(P_GLOW_INNER_COLOR)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_INNER_COLOR))); - p = obs_properties_add_float_slider(props, P_GLOW_INNER_ALPHA, P_TRANSLATE(P_GLOW_INNER_ALPHA), 0.0, 100.0, + p = obs_properties_add_color(props, ST_GLOW_INNER_COLOR, D_TRANSLATE(ST_GLOW_INNER_COLOR)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_INNER_COLOR))); + p = obs_properties_add_float_slider(props, ST_GLOW_INNER_ALPHA, D_TRANSLATE(ST_GLOW_INNER_ALPHA), 0.0, 100.0, 0.1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_INNER_ALPHA))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_INNER_ALPHA))); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_INNER_WIDTH))); - p = obs_properties_add_float_slider(props, P_GLOW_INNER_WIDTH, P_TRANSLATE(P_GLOW_INNER_WIDTH), 0.0, 16.0, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_INNER_WIDTH))); + p = obs_properties_add_float_slider(props, ST_GLOW_INNER_WIDTH, D_TRANSLATE(ST_GLOW_INNER_WIDTH), 0.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_GLOW_INNER_SHARPNESS))); - p = obs_properties_add_float_slider(props, P_GLOW_INNER_SHARPNESS, P_TRANSLATE(P_GLOW_INNER_SHARPNESS), 0.00, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_GLOW_INNER_SHARPNESS))); + p = obs_properties_add_float_slider(props, ST_GLOW_INNER_SHARPNESS, D_TRANSLATE(ST_GLOW_INNER_SHARPNESS), 0.00, 100.0, 0.01); } { - p = obs_properties_add_bool(props, P_OUTLINE, P_TRANSLATE(P_OUTLINE)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_OUTLINE))); + p = obs_properties_add_bool(props, ST_OUTLINE, D_TRANSLATE(ST_OUTLINE)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_OUTLINE))); obs_property_set_modified_callback2(p, cb_modified_outline, this); - p = obs_properties_add_color(props, P_OUTLINE_COLOR, P_TRANSLATE(P_OUTLINE_COLOR)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_OUTLINE_COLOR))); - p = obs_properties_add_float_slider(props, P_OUTLINE_ALPHA, P_TRANSLATE(P_OUTLINE_ALPHA), 0.0, 100.0, 0.1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_OUTLINE_ALPHA))); + p = obs_properties_add_color(props, ST_OUTLINE_COLOR, D_TRANSLATE(ST_OUTLINE_COLOR)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_OUTLINE_COLOR))); + p = obs_properties_add_float_slider(props, ST_OUTLINE_ALPHA, D_TRANSLATE(ST_OUTLINE_ALPHA), 0.0, 100.0, 0.1); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_OUTLINE_ALPHA))); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_OUTLINE_WIDTH))); - p = obs_properties_add_float_slider(props, P_OUTLINE_WIDTH, P_TRANSLATE(P_OUTLINE_WIDTH), 0.0, 16.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_OUTLINE_WIDTH))); + p = obs_properties_add_float_slider(props, ST_OUTLINE_WIDTH, D_TRANSLATE(ST_OUTLINE_WIDTH), 0.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_OUTLINE_OFFSET))); - p = obs_properties_add_float_slider(props, P_OUTLINE_OFFSET, P_TRANSLATE(P_OUTLINE_OFFSET), -16.0, 16.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_OUTLINE_OFFSET))); + p = obs_properties_add_float_slider(props, ST_OUTLINE_OFFSET, D_TRANSLATE(ST_OUTLINE_OFFSET), -16.0, 16.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_OUTLINE_SHARPNESS))); - p = obs_properties_add_float_slider(props, P_OUTLINE_SHARPNESS, P_TRANSLATE(P_OUTLINE_SHARPNESS), 0.00, 100.0, + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_OUTLINE_SHARPNESS))); + p = obs_properties_add_float_slider(props, ST_OUTLINE_SHARPNESS, D_TRANSLATE(ST_OUTLINE_SHARPNESS), 0.00, 100.0, 0.01); } { - p = obs_properties_add_bool(props, S_ADVANCED, P_TRANSLATE(S_ADVANCED)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_ADVANCED))); + p = obs_properties_add_bool(props, S_ADVANCED, D_TRANSLATE(S_ADVANCED)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(S_ADVANCED))); obs_property_set_modified_callback2(p, cb_modified_advanced, this); - p = obs_properties_add_float_slider(props, P_SDF_SCALE, P_TRANSLATE(P_SDF_SCALE), 0.1, 500.0, 0.1); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SDF_SCALE))); + p = obs_properties_add_float_slider(props, ST_SDF_SCALE, D_TRANSLATE(ST_SDF_SCALE), 0.1, 500.0, 0.1); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SDF_SCALE))); - p = obs_properties_add_float_slider(props, P_SDF_THRESHOLD, P_TRANSLATE(P_SDF_THRESHOLD), 0.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SDF_THRESHOLD))); + p = obs_properties_add_float_slider(props, ST_SDF_THRESHOLD, D_TRANSLATE(ST_SDF_THRESHOLD), 0.0, 100.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SDF_THRESHOLD))); } return props; @@ -481,9 +481,9 @@ obs_properties_t* filter::sdf_effects::sdf_effects_instance::get_properties() void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) { { - this->m_outer_shadow = - obs_data_get_bool(data, P_SHADOW_OUTER) - && (obs_data_get_double(data, P_SHADOW_OUTER_ALPHA) >= std::numeric_limits::epsilon()); + this->_outer_shadow = + obs_data_get_bool(data, ST_SHADOW_OUTER) + && (obs_data_get_double(data, ST_SHADOW_OUTER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -492,22 +492,22 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) uint8_t r, g, b, a; } c; }; - color = uint32_t(obs_data_get_int(data, P_SHADOW_OUTER_COLOR)); - this->m_outer_shadow_color.x = float_t(c.r / 255.0); - this->m_outer_shadow_color.y = float_t(c.g / 255.0); - this->m_outer_shadow_color.z = float_t(c.b / 255.0); - this->m_outer_shadow_color.w = float_t(obs_data_get_double(data, P_SHADOW_OUTER_ALPHA) / 100.0); + color = uint32_t(obs_data_get_int(data, ST_SHADOW_OUTER_COLOR)); + this->_outer_shadow_color.x = float_t(c.r / 255.0); + this->_outer_shadow_color.y = float_t(c.g / 255.0); + this->_outer_shadow_color.z = float_t(c.b / 255.0); + this->_outer_shadow_color.w = float_t(obs_data_get_double(data, ST_SHADOW_OUTER_ALPHA) / 100.0); } - this->m_outer_shadow_range_min = float_t(obs_data_get_double(data, P_SHADOW_OUTER_RANGE_MINIMUM)); - this->m_outer_shadow_range_max = float_t(obs_data_get_double(data, P_SHADOW_OUTER_RANGE_MAXIMUM)); - this->m_outer_shadow_offset_x = float_t(obs_data_get_double(data, P_SHADOW_OUTER_OFFSET_X)); - this->m_outer_shadow_offset_y = float_t(obs_data_get_double(data, P_SHADOW_OUTER_OFFSET_Y)); + this->_outer_shadow_range_min = float_t(obs_data_get_double(data, ST_SHADOW_OUTER_RANGE_MINIMUM)); + this->_outer_shadow_range_max = float_t(obs_data_get_double(data, ST_SHADOW_OUTER_RANGE_MAXIMUM)); + this->_outer_shadow_offset_x = float_t(obs_data_get_double(data, ST_SHADOW_OUTER_OFFSET_X)); + this->_outer_shadow_offset_y = float_t(obs_data_get_double(data, ST_SHADOW_OUTER_OFFSET_Y)); } { - this->m_inner_shadow = - obs_data_get_bool(data, P_SHADOW_INNER) - && (obs_data_get_double(data, P_SHADOW_INNER_ALPHA) >= std::numeric_limits::epsilon()); + this->_inner_shadow = + obs_data_get_bool(data, ST_SHADOW_INNER) + && (obs_data_get_double(data, ST_SHADOW_INNER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -516,22 +516,22 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) uint8_t r, g, b, a; } c; }; - color = uint32_t(obs_data_get_int(data, P_SHADOW_INNER_COLOR)); - this->m_inner_shadow_color.x = float_t(c.r / 255.0); - this->m_inner_shadow_color.y = float_t(c.g / 255.0); - this->m_inner_shadow_color.z = float_t(c.b / 255.0); - this->m_inner_shadow_color.w = float_t(obs_data_get_double(data, P_SHADOW_INNER_ALPHA) / 100.0); + color = uint32_t(obs_data_get_int(data, ST_SHADOW_INNER_COLOR)); + this->_inner_shadow_color.x = float_t(c.r / 255.0); + this->_inner_shadow_color.y = float_t(c.g / 255.0); + this->_inner_shadow_color.z = float_t(c.b / 255.0); + this->_inner_shadow_color.w = float_t(obs_data_get_double(data, ST_SHADOW_INNER_ALPHA) / 100.0); } - this->m_inner_shadow_range_min = float_t(obs_data_get_double(data, P_SHADOW_INNER_RANGE_MINIMUM)); - this->m_inner_shadow_range_max = float_t(obs_data_get_double(data, P_SHADOW_INNER_RANGE_MAXIMUM)); - this->m_inner_shadow_offset_x = float_t(obs_data_get_double(data, P_SHADOW_INNER_OFFSET_X)); - this->m_inner_shadow_offset_y = float_t(obs_data_get_double(data, P_SHADOW_INNER_OFFSET_Y)); + this->_inner_shadow_range_min = float_t(obs_data_get_double(data, ST_SHADOW_INNER_RANGE_MINIMUM)); + this->_inner_shadow_range_max = float_t(obs_data_get_double(data, ST_SHADOW_INNER_RANGE_MAXIMUM)); + this->_inner_shadow_offset_x = float_t(obs_data_get_double(data, ST_SHADOW_INNER_OFFSET_X)); + this->_inner_shadow_offset_y = float_t(obs_data_get_double(data, ST_SHADOW_INNER_OFFSET_Y)); } { - this->m_outer_glow = - obs_data_get_bool(data, P_GLOW_OUTER) - && (obs_data_get_double(data, P_GLOW_OUTER_ALPHA) >= std::numeric_limits::epsilon()); + this->_outer_glow = + obs_data_get_bool(data, ST_GLOW_OUTER) + && (obs_data_get_double(data, ST_GLOW_OUTER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -540,24 +540,24 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) uint8_t r, g, b, a; } c; }; - color = uint32_t(obs_data_get_int(data, P_GLOW_OUTER_COLOR)); - this->m_outer_glow_color.x = float_t(c.r / 255.0); - this->m_outer_glow_color.y = float_t(c.g / 255.0); - this->m_outer_glow_color.z = float_t(c.b / 255.0); - this->m_outer_glow_color.w = float_t(obs_data_get_double(data, P_GLOW_OUTER_ALPHA) / 100.0); + color = uint32_t(obs_data_get_int(data, ST_GLOW_OUTER_COLOR)); + this->_outer_glow_color.x = float_t(c.r / 255.0); + this->_outer_glow_color.y = float_t(c.g / 255.0); + this->_outer_glow_color.z = float_t(c.b / 255.0); + this->_outer_glow_color.w = float_t(obs_data_get_double(data, ST_GLOW_OUTER_ALPHA) / 100.0); } - this->m_outer_glow_width = float_t(obs_data_get_double(data, P_GLOW_OUTER_WIDTH)); - this->m_outer_glow_sharpness = float_t(obs_data_get_double(data, P_GLOW_OUTER_SHARPNESS) / 100.0); - this->m_outer_glow_sharpness_inv = float_t(1.0f / (1.0f - this->m_outer_glow_sharpness)); - if (this->m_outer_glow_sharpness >= (1.0f - std::numeric_limits::epsilon())) { - this->m_outer_glow_sharpness = 1.0f - std::numeric_limits::epsilon(); + this->_outer_glow_width = float_t(obs_data_get_double(data, ST_GLOW_OUTER_WIDTH)); + this->_outer_glow_sharpness = float_t(obs_data_get_double(data, ST_GLOW_OUTER_SHARPNESS) / 100.0); + this->_outer_glow_sharpness_inv = float_t(1.0f / (1.0f - this->_outer_glow_sharpness)); + if (this->_outer_glow_sharpness >= (1.0f - std::numeric_limits::epsilon())) { + this->_outer_glow_sharpness = 1.0f - std::numeric_limits::epsilon(); } } { - this->m_inner_glow = - obs_data_get_bool(data, P_GLOW_INNER) - && (obs_data_get_double(data, P_GLOW_INNER_ALPHA) >= std::numeric_limits::epsilon()); + this->_inner_glow = + obs_data_get_bool(data, ST_GLOW_INNER) + && (obs_data_get_double(data, ST_GLOW_INNER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -566,23 +566,23 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) uint8_t r, g, b, a; } c; }; - color = uint32_t(obs_data_get_int(data, P_GLOW_INNER_COLOR)); - this->m_inner_glow_color.x = float_t(c.r / 255.0); - this->m_inner_glow_color.y = float_t(c.g / 255.0); - this->m_inner_glow_color.z = float_t(c.b / 255.0); - this->m_inner_glow_color.w = float_t(obs_data_get_double(data, P_GLOW_INNER_ALPHA) / 100.0); + color = uint32_t(obs_data_get_int(data, ST_GLOW_INNER_COLOR)); + this->_inner_glow_color.x = float_t(c.r / 255.0); + this->_inner_glow_color.y = float_t(c.g / 255.0); + this->_inner_glow_color.z = float_t(c.b / 255.0); + this->_inner_glow_color.w = float_t(obs_data_get_double(data, ST_GLOW_INNER_ALPHA) / 100.0); } - this->m_inner_glow_width = float_t(obs_data_get_double(data, P_GLOW_INNER_WIDTH)); - this->m_inner_glow_sharpness = float_t(obs_data_get_double(data, P_GLOW_INNER_SHARPNESS) / 100.0); - this->m_inner_glow_sharpness_inv = float_t(1.0f / (1.0f - this->m_inner_glow_sharpness)); - if (this->m_inner_glow_sharpness >= (1.0f - std::numeric_limits::epsilon())) { - this->m_inner_glow_sharpness = 1.0f - std::numeric_limits::epsilon(); + this->_inner_glow_width = float_t(obs_data_get_double(data, ST_GLOW_INNER_WIDTH)); + this->_inner_glow_sharpness = float_t(obs_data_get_double(data, ST_GLOW_INNER_SHARPNESS) / 100.0); + this->_inner_glow_sharpness_inv = float_t(1.0f / (1.0f - this->_inner_glow_sharpness)); + if (this->_inner_glow_sharpness >= (1.0f - std::numeric_limits::epsilon())) { + this->_inner_glow_sharpness = 1.0f - std::numeric_limits::epsilon(); } } { - this->m_outline = obs_data_get_bool(data, P_OUTLINE) - && (obs_data_get_double(data, P_OUTLINE_ALPHA) >= std::numeric_limits::epsilon()); + this->_outline = obs_data_get_bool(data, ST_OUTLINE) + && (obs_data_get_double(data, ST_OUTLINE_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -591,23 +591,23 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) uint8_t r, g, b, a; } c; }; - color = uint32_t(obs_data_get_int(data, P_OUTLINE_COLOR)); - this->m_outline_color.x = float_t(c.r / 255.0); - this->m_outline_color.y = float_t(c.g / 255.0); - this->m_outline_color.z = float_t(c.b / 255.0); - this->m_outline_color.w = float_t(obs_data_get_double(data, P_OUTLINE_ALPHA) / 100.0); + color = uint32_t(obs_data_get_int(data, ST_OUTLINE_COLOR)); + this->_outline_color.x = float_t(c.r / 255.0); + this->_outline_color.y = float_t(c.g / 255.0); + this->_outline_color.z = float_t(c.b / 255.0); + this->_outline_color.w = float_t(obs_data_get_double(data, ST_OUTLINE_ALPHA) / 100.0); } - this->m_outline_width = float_t(obs_data_get_double(data, P_OUTLINE_WIDTH)); - this->m_outline_offset = float_t(obs_data_get_double(data, P_OUTLINE_OFFSET)); - this->m_outline_sharpness = float_t(obs_data_get_double(data, P_OUTLINE_SHARPNESS) / 100.0); - this->m_outline_sharpness_inv = float_t(1.0f / (1.0f - this->m_outline_sharpness)); - if (this->m_outline_sharpness >= (1.0f - std::numeric_limits::epsilon())) { - this->m_outline_sharpness = 1.0f - std::numeric_limits::epsilon(); + this->_outline_width = float_t(obs_data_get_double(data, ST_OUTLINE_WIDTH)); + this->_outline_offset = float_t(obs_data_get_double(data, ST_OUTLINE_OFFSET)); + this->_outline_sharpness = float_t(obs_data_get_double(data, ST_OUTLINE_SHARPNESS) / 100.0); + this->_outline_sharpness_inv = float_t(1.0f / (1.0f - this->_outline_sharpness)); + if (this->_outline_sharpness >= (1.0f - std::numeric_limits::epsilon())) { + this->_outline_sharpness = 1.0f - std::numeric_limits::epsilon(); } } - this->m_sdf_scale = double_t(obs_data_get_double(data, P_SDF_SCALE) / 100.0); - this->m_sdf_threshold = float_t(obs_data_get_double(data, P_SDF_THRESHOLD) / 100.0); + this->_sdf_scale = double_t(obs_data_get_double(data, ST_SDF_SCALE) / 100.0); + this->_sdf_threshold = float_t(obs_data_get_double(data, ST_SDF_THRESHOLD) / 100.0); } uint32_t filter::sdf_effects::sdf_effects_instance::get_width() @@ -631,7 +631,7 @@ void filter::sdf_effects::sdf_effects_instance::video_tick(float) // Figure out the actual source size. do { - obs_source_t* target = obs_filter_get_target(this->m_self); + obs_source_t* target = obs_filter_get_target(this->_self); if (target == nullptr) { break; } @@ -641,21 +641,21 @@ void filter::sdf_effects::sdf_effects_instance::video_tick(float) height = obs_source_get_height(target); } while (false); - this->m_source_rendered = false; - this->m_output_rendered = false; + this->_source_rendered = false; + this->_output_rendered = false; } void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect) { - obs_source_t* parent = obs_filter_get_parent(this->m_self); - obs_source_t* target = obs_filter_get_target(this->m_self); + obs_source_t* parent = obs_filter_get_parent(this->_self); + obs_source_t* target = obs_filter_get_target(this->_self); uint32_t baseW = obs_source_get_base_width(target); uint32_t baseH = obs_source_get_base_height(target); gs_effect_t* final_effect = effect ? effect : obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); gs_effect_t* default_effect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); - if (!this->m_self || !parent || !target || !baseW || !baseH || !final_effect) { - obs_source_skip_video_filter(this->m_self); + if (!this->_self || !parent || !target || !baseW || !baseH || !final_effect) { + obs_source_skip_video_filter(this->_self); return; } @@ -678,28 +678,28 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS); gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); - if (!this->m_source_rendered) { + if (!this->_source_rendered) { // Store input texture. { - auto op = m_source_rt->render(baseW, baseH); + auto op = _source_rt->render(baseW, baseH); gs_ortho(0, (float)baseW, 0, (float)baseH, -1, 1); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &color_transparent, 0, 0); - if (obs_source_process_filter_begin(this->m_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { - obs_source_process_filter_end(this->m_self, final_effect, baseW, baseH); + if (obs_source_process_filter_begin(this->_self, GS_RGBA, OBS_ALLOW_DIRECT_RENDERING)) { + obs_source_process_filter_end(this->_self, final_effect, baseW, baseH); } else { throw std::runtime_error("failed to process source"); } } - this->m_source_rt->get_texture(this->m_source_texture); - if (!this->m_source_texture) { + this->_source_rt->get_texture(this->_source_texture); + if (!this->_source_texture) { throw std::runtime_error("failed to draw source"); } // Generate SDF Buffers { - this->m_sdf_read->get_texture(this->m_sdf_texture); - if (!this->m_sdf_texture) { + this->_sdf_read->get_texture(this->_sdf_texture); + if (!this->_sdf_texture) { throw std::runtime_error("SDF Backbuffer empty"); } @@ -711,8 +711,8 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect // Scale SDF Size double_t sdfW, sdfH; - sdfW = baseW * m_sdf_scale; - sdfH = baseH * m_sdf_scale; + sdfW = baseW * _sdf_scale; + sdfH = baseH * _sdf_scale; if (sdfW <= 1) { sdfW = 1.0; } @@ -721,43 +721,43 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect } { - auto op = this->m_sdf_write->render(uint32_t(sdfW), uint32_t(sdfH)); + auto op = this->_sdf_write->render(uint32_t(sdfW), uint32_t(sdfH)); gs_ortho(0, (float)sdfW, 0, (float)sdfH, -1, 1); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &color_transparent, 0, 0); - sdf_effect->get_parameter("_image").set_texture(this->m_source_texture); + sdf_effect->get_parameter("_image").set_texture(this->_source_texture); sdf_effect->get_parameter("_size").set_float2(float_t(sdfW), float_t(sdfH)); - sdf_effect->get_parameter("_sdf").set_texture(this->m_sdf_texture); - sdf_effect->get_parameter("_threshold").set_float(this->m_sdf_threshold); + sdf_effect->get_parameter("_sdf").set_texture(this->_sdf_texture); + sdf_effect->get_parameter("_threshold").set_float(this->_sdf_threshold); while (gs_effect_loop(sdf_effect->get_object(), "Draw")) { - gs_draw_sprite(this->m_sdf_texture->get_object(), 0, uint32_t(sdfW), uint32_t(sdfH)); + gs_draw_sprite(this->_sdf_texture->get_object(), 0, uint32_t(sdfW), uint32_t(sdfH)); } } - std::swap(this->m_sdf_read, this->m_sdf_write); - this->m_sdf_read->get_texture(this->m_sdf_texture); - if (!this->m_sdf_texture) { + std::swap(this->_sdf_read, this->_sdf_write); + this->_sdf_read->get_texture(this->_sdf_texture); + if (!this->_sdf_texture) { throw std::runtime_error("SDF Backbuffer empty"); } } - this->m_source_rendered = true; + this->_source_rendered = true; } gs_blend_state_pop(); } catch (...) { gs_blend_state_pop(); - obs_source_skip_video_filter(this->m_self); + obs_source_skip_video_filter(this->_self); return; } - if (!this->m_output_rendered) { - this->m_output_texture = this->m_source_texture; + if (!this->_output_rendered) { + this->_output_texture = this->_source_texture; std::shared_ptr consumer_effect = filter::sdf_effects::sdf_effects_factory::get()->get_sdf_consumer_effect(); if (!consumer_effect) { - obs_source_skip_video_filter(this->m_self); + obs_source_skip_video_filter(this->_self); return; } @@ -777,14 +777,14 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect // Optimized Render path. try { - auto op = this->m_output_rt->render(baseW, baseH); + auto op = this->_output_rt->render(baseW, baseH); gs_ortho(0, 1, 0, 1, 0, 1); gs_enable_blending(false); gs_blend_function(GS_BLEND_ONE, GS_BLEND_ZERO); auto param = gs_effect_get_param_by_name(default_effect, "image"); if (param) { - gs_effect_set_texture(param, this->m_output_texture->get_object()); + gs_effect_set_texture(param, this->_output_texture->get_object()); } while (gs_effect_loop(default_effect, "Draw")) { gs_draw_sprite(0, 0, 1, 1); @@ -792,67 +792,67 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect gs_enable_blending(true); gs_blend_function_separate(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA, GS_BLEND_ONE, GS_BLEND_ONE); - if (this->m_outer_shadow) { - consumer_effect->get_parameter("pSDFTexture").set_texture(this->m_sdf_texture); - consumer_effect->get_parameter("pSDFThreshold").set_float(this->m_sdf_threshold); - consumer_effect->get_parameter("pImageTexture").set_texture(this->m_source_texture->get_object()); - consumer_effect->get_parameter("pShadowColor").set_float4(this->m_outer_shadow_color); - consumer_effect->get_parameter("pShadowMin").set_float(this->m_outer_shadow_range_min); - consumer_effect->get_parameter("pShadowMax").set_float(this->m_outer_shadow_range_max); + if (this->_outer_shadow) { + consumer_effect->get_parameter("pSDFTexture").set_texture(this->_sdf_texture); + consumer_effect->get_parameter("pSDFThreshold").set_float(this->_sdf_threshold); + consumer_effect->get_parameter("pImageTexture").set_texture(this->_source_texture->get_object()); + consumer_effect->get_parameter("pShadowColor").set_float4(this->_outer_shadow_color); + consumer_effect->get_parameter("pShadowMin").set_float(this->_outer_shadow_range_min); + consumer_effect->get_parameter("pShadowMax").set_float(this->_outer_shadow_range_max); consumer_effect->get_parameter("pShadowOffset") - .set_float2(this->m_outer_shadow_offset_x / float_t(baseW), - this->m_outer_shadow_offset_y / float_t(baseH)); + .set_float2(this->_outer_shadow_offset_x / float_t(baseW), + this->_outer_shadow_offset_y / float_t(baseH)); while (gs_effect_loop(consumer_effect->get_object(), "ShadowOuter")) { gs_draw_sprite(0, 0, 1, 1); } } - if (this->m_inner_shadow) { - consumer_effect->get_parameter("pSDFTexture").set_texture(this->m_sdf_texture); - consumer_effect->get_parameter("pSDFThreshold").set_float(this->m_sdf_threshold); - consumer_effect->get_parameter("pImageTexture").set_texture(this->m_source_texture->get_object()); - consumer_effect->get_parameter("pShadowColor").set_float4(this->m_inner_shadow_color); - consumer_effect->get_parameter("pShadowMin").set_float(this->m_inner_shadow_range_min); - consumer_effect->get_parameter("pShadowMax").set_float(this->m_inner_shadow_range_max); + if (this->_inner_shadow) { + consumer_effect->get_parameter("pSDFTexture").set_texture(this->_sdf_texture); + consumer_effect->get_parameter("pSDFThreshold").set_float(this->_sdf_threshold); + consumer_effect->get_parameter("pImageTexture").set_texture(this->_source_texture->get_object()); + consumer_effect->get_parameter("pShadowColor").set_float4(this->_inner_shadow_color); + consumer_effect->get_parameter("pShadowMin").set_float(this->_inner_shadow_range_min); + consumer_effect->get_parameter("pShadowMax").set_float(this->_inner_shadow_range_max); consumer_effect->get_parameter("pShadowOffset") - .set_float2(this->m_inner_shadow_offset_x / float_t(baseW), - this->m_inner_shadow_offset_y / float_t(baseH)); + .set_float2(this->_inner_shadow_offset_x / float_t(baseW), + this->_inner_shadow_offset_y / float_t(baseH)); while (gs_effect_loop(consumer_effect->get_object(), "ShadowInner")) { gs_draw_sprite(0, 0, 1, 1); } } - if (this->m_outer_glow) { - consumer_effect->get_parameter("pSDFTexture").set_texture(this->m_sdf_texture); - consumer_effect->get_parameter("pSDFThreshold").set_float(this->m_sdf_threshold); - consumer_effect->get_parameter("pImageTexture").set_texture(this->m_source_texture->get_object()); - consumer_effect->get_parameter("pGlowColor").set_float4(this->m_outer_glow_color); - consumer_effect->get_parameter("pGlowWidth").set_float(this->m_outer_glow_width); - consumer_effect->get_parameter("pGlowSharpness").set_float(this->m_outer_glow_sharpness); - consumer_effect->get_parameter("pGlowSharpnessInverse").set_float(this->m_outer_glow_sharpness_inv); + if (this->_outer_glow) { + consumer_effect->get_parameter("pSDFTexture").set_texture(this->_sdf_texture); + consumer_effect->get_parameter("pSDFThreshold").set_float(this->_sdf_threshold); + consumer_effect->get_parameter("pImageTexture").set_texture(this->_source_texture->get_object()); + consumer_effect->get_parameter("pGlowColor").set_float4(this->_outer_glow_color); + consumer_effect->get_parameter("pGlowWidth").set_float(this->_outer_glow_width); + consumer_effect->get_parameter("pGlowSharpness").set_float(this->_outer_glow_sharpness); + consumer_effect->get_parameter("pGlowSharpnessInverse").set_float(this->_outer_glow_sharpness_inv); while (gs_effect_loop(consumer_effect->get_object(), "GlowOuter")) { gs_draw_sprite(0, 0, 1, 1); } } - if (this->m_inner_glow) { - consumer_effect->get_parameter("pSDFTexture").set_texture(this->m_sdf_texture); - consumer_effect->get_parameter("pSDFThreshold").set_float(this->m_sdf_threshold); - consumer_effect->get_parameter("pImageTexture").set_texture(this->m_source_texture->get_object()); - consumer_effect->get_parameter("pGlowColor").set_float4(this->m_inner_glow_color); - consumer_effect->get_parameter("pGlowWidth").set_float(this->m_inner_glow_width); - consumer_effect->get_parameter("pGlowSharpness").set_float(this->m_inner_glow_sharpness); - consumer_effect->get_parameter("pGlowSharpnessInverse").set_float(this->m_inner_glow_sharpness_inv); + if (this->_inner_glow) { + consumer_effect->get_parameter("pSDFTexture").set_texture(this->_sdf_texture); + consumer_effect->get_parameter("pSDFThreshold").set_float(this->_sdf_threshold); + consumer_effect->get_parameter("pImageTexture").set_texture(this->_source_texture->get_object()); + consumer_effect->get_parameter("pGlowColor").set_float4(this->_inner_glow_color); + consumer_effect->get_parameter("pGlowWidth").set_float(this->_inner_glow_width); + consumer_effect->get_parameter("pGlowSharpness").set_float(this->_inner_glow_sharpness); + consumer_effect->get_parameter("pGlowSharpnessInverse").set_float(this->_inner_glow_sharpness_inv); while (gs_effect_loop(consumer_effect->get_object(), "GlowInner")) { gs_draw_sprite(0, 0, 1, 1); } } - if (this->m_outline) { - consumer_effect->get_parameter("pSDFTexture").set_texture(this->m_sdf_texture); - consumer_effect->get_parameter("pSDFThreshold").set_float(this->m_sdf_threshold); - consumer_effect->get_parameter("pImageTexture").set_texture(this->m_source_texture->get_object()); - consumer_effect->get_parameter("pOutlineColor").set_float4(this->m_outline_color); - consumer_effect->get_parameter("pOutlineWidth").set_float(this->m_outline_width); - consumer_effect->get_parameter("pOutlineOffset").set_float(this->m_outline_offset); - consumer_effect->get_parameter("pOutlineSharpness").set_float(this->m_outline_sharpness); - consumer_effect->get_parameter("pOutlineSharpnessInverse").set_float(this->m_outline_sharpness_inv); + if (this->_outline) { + consumer_effect->get_parameter("pSDFTexture").set_texture(this->_sdf_texture); + consumer_effect->get_parameter("pSDFThreshold").set_float(this->_sdf_threshold); + consumer_effect->get_parameter("pImageTexture").set_texture(this->_source_texture->get_object()); + consumer_effect->get_parameter("pOutlineColor").set_float4(this->_outline_color); + consumer_effect->get_parameter("pOutlineWidth").set_float(this->_outline_width); + consumer_effect->get_parameter("pOutlineOffset").set_float(this->_outline_offset); + consumer_effect->get_parameter("pOutlineSharpness").set_float(this->_outline_sharpness); + consumer_effect->get_parameter("pOutlineSharpnessInverse").set_float(this->_outline_sharpness_inv); while (gs_effect_loop(consumer_effect->get_object(), "Outline")) { gs_draw_sprite(0, 0, 1, 1); } @@ -860,20 +860,20 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect } catch (...) { } - this->m_output_rt->get_texture(this->m_output_texture); + this->_output_rt->get_texture(this->_output_texture); gs_blend_state_pop(); - this->m_output_rendered = true; + this->_output_rendered = true; } - if (!this->m_output_texture) { - obs_source_skip_video_filter(this->m_self); + if (!this->_output_texture) { + obs_source_skip_video_filter(this->_self); return; } gs_eparam_t* ep = gs_effect_get_param_by_name(final_effect, "image"); if (ep) { - gs_effect_set_texture(ep, this->m_output_texture->get_object()); + gs_effect_set_texture(ep, this->_output_texture->get_object()); } while (gs_effect_loop(final_effect, "Draw")) { gs_draw_sprite(0, 0, baseW, baseH); diff --git a/source/filters/filter-sdf-effects.hpp b/source/filters/filter-sdf-effects.hpp index 6823ebc7..cbe01978 100644 --- a/source/filters/filter-sdf-effects.hpp +++ b/source/filters/filter-sdf-effects.hpp @@ -41,12 +41,12 @@ namespace filter { class sdf_effects_instance; class sdf_effects_factory { - obs_source_info source_info; + obs_source_info _source_info; - std::list sources; + std::list _sources; - std::shared_ptr sdf_producer_effect; - std::shared_ptr sdf_consumer_effect; + std::shared_ptr _sdf_producer_effect; + std::shared_ptr _sdf_consumer_effect; public: // Singleton static void initialize(); @@ -83,56 +83,57 @@ namespace filter { }; class sdf_effects_instance { - obs_source_t* m_self; + obs_source_t* _self; // Input - std::shared_ptr m_source_rt; - std::shared_ptr m_source_texture; - bool m_source_rendered; + std::shared_ptr _source_rt; + std::shared_ptr _source_texture; + bool _source_rendered; // Distance Field - std::shared_ptr m_sdf_write, m_sdf_read; - std::shared_ptr m_sdf_texture; - double_t m_sdf_scale; - float_t m_sdf_threshold; + std::shared_ptr _sdf_write; + std::shared_ptr _sdf_read; + std::shared_ptr _sdf_texture; + double_t _sdf_scale; + float_t _sdf_threshold; // Effects - bool m_output_rendered; - std::shared_ptr m_output_texture; - std::shared_ptr m_output_rt; + bool _output_rendered; + std::shared_ptr _output_texture; + std::shared_ptr _output_rt; /// Inner Shadow - bool m_inner_shadow; - vec4 m_inner_shadow_color; - float_t m_inner_shadow_range_min; - float_t m_inner_shadow_range_max; - float_t m_inner_shadow_offset_x; - float_t m_inner_shadow_offset_y; + bool _inner_shadow; + vec4 _inner_shadow_color; + float_t _inner_shadow_range_min; + float_t _inner_shadow_range_max; + float_t _inner_shadow_offset_x; + float_t _inner_shadow_offset_y; /// Outer Shadow - bool m_outer_shadow; - vec4 m_outer_shadow_color; - float_t m_outer_shadow_range_min; - float_t m_outer_shadow_range_max; - float_t m_outer_shadow_offset_x; - float_t m_outer_shadow_offset_y; + bool _outer_shadow; + vec4 _outer_shadow_color; + float_t _outer_shadow_range_min; + float_t _outer_shadow_range_max; + float_t _outer_shadow_offset_x; + float_t _outer_shadow_offset_y; /// Inner Glow - bool m_inner_glow; - vec4 m_inner_glow_color; - float_t m_inner_glow_width; - float_t m_inner_glow_sharpness; - float_t m_inner_glow_sharpness_inv; + bool _inner_glow; + vec4 _inner_glow_color; + float_t _inner_glow_width; + float_t _inner_glow_sharpness; + float_t _inner_glow_sharpness_inv; /// Outer Glow - bool m_outer_glow; - vec4 m_outer_glow_color; - float_t m_outer_glow_width; - float_t m_outer_glow_sharpness; - float_t m_outer_glow_sharpness_inv; + bool _outer_glow; + vec4 _outer_glow_color; + float_t _outer_glow_width; + float_t _outer_glow_sharpness; + float_t _outer_glow_sharpness_inv; /// Outline - bool m_outline; - vec4 m_outline_color; - float_t m_outline_width; - float_t m_outline_offset; - float_t m_outline_sharpness; - float_t m_outline_sharpness_inv; + bool _outline; + vec4 _outline_color; + float_t _outline_width; + float_t _outline_offset; + float_t _outline_sharpness; + float_t _outline_sharpness_inv; static bool cb_modified_shadow_inside(void* ptr, obs_properties_t* props, obs_property* prop, obs_data_t* settings); diff --git a/source/filters/filter-transform.cpp b/source/filters/filter-transform.cpp index 366fa290..47c64796 100644 --- a/source/filters/filter-transform.cpp +++ b/source/filters/filter-transform.cpp @@ -76,10 +76,10 @@ enum RotationOrder : int64_t { }; // Initializer & Finalizer -INITIALIZER(FilterTransformInit) +P_INITIALIZER(FilterTransformInit) { - initializerFunctions.push_back([] { filter::transform::transform_factory::initialize(); }); - finalizerFunctions.push_back([] { filter::transform::transform_factory::finalize(); }); + initializer_functions.push_back([] { filter::transform::transform_factory::initialize(); }); + finalizer_functions.push_back([] { filter::transform::transform_factory::finalize(); }); } static std::shared_ptr factory_instance = nullptr; @@ -101,30 +101,30 @@ std::shared_ptr filter::transform::transfo filter::transform::transform_factory::transform_factory() { - memset(&sourceInfo, 0, sizeof(obs_source_info)); - sourceInfo.id = "obs-stream-effects-filter-transform"; - sourceInfo.type = OBS_SOURCE_TYPE_FILTER; - sourceInfo.output_flags = OBS_SOURCE_VIDEO; - sourceInfo.get_name = get_name; - sourceInfo.get_defaults = get_defaults; - sourceInfo.get_properties = get_properties; + memset(&_source_info, 0, sizeof(obs_source_info)); + _source_info.id = "obs-stream-effects-filter-transform"; + _source_info.type = OBS_SOURCE_TYPE_FILTER; + _source_info.output_flags = OBS_SOURCE_VIDEO; + _source_info.get_name = get_name; + _source_info.get_defaults = get_defaults; + _source_info.get_properties = get_properties; - sourceInfo.create = create; - sourceInfo.destroy = destroy; - sourceInfo.update = update; - sourceInfo.activate = activate; - sourceInfo.deactivate = deactivate; - sourceInfo.video_tick = video_tick; - sourceInfo.video_render = video_render; + _source_info.create = create; + _source_info.destroy = destroy; + _source_info.update = update; + _source_info.activate = activate; + _source_info.deactivate = deactivate; + _source_info.video_tick = video_tick; + _source_info.video_render = video_render; - obs_register_source(&sourceInfo); + obs_register_source(&_source_info); } filter::transform::transform_factory::~transform_factory() {} const char* filter::transform::transform_factory::get_name(void*) { - return P_TRANSLATE(ST); + return D_TRANSLATE(ST); } void filter::transform::transform_factory::get_defaults(obs_data_t* data) @@ -152,95 +152,95 @@ obs_properties_t* filter::transform::transform_factory::get_properties(void*) // Camera /// Projection Mode - p = obs_properties_add_list(pr, ST_CAMERA, P_TRANSLATE(ST_CAMERA), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_CAMERA))); - obs_property_list_add_int(p, P_TRANSLATE(ST_CAMERA_ORTHOGRAPHIC), (int64_t)CameraMode::Orthographic); - obs_property_list_add_int(p, P_TRANSLATE(ST_CAMERA_PERSPECTIVE), (int64_t)CameraMode::Perspective); + p = obs_properties_add_list(pr, ST_CAMERA, D_TRANSLATE(ST_CAMERA), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CAMERA))); + obs_property_list_add_int(p, D_TRANSLATE(ST_CAMERA_ORTHOGRAPHIC), (int64_t)CameraMode::Orthographic); + obs_property_list_add_int(p, D_TRANSLATE(ST_CAMERA_PERSPECTIVE), (int64_t)CameraMode::Perspective); obs_property_set_modified_callback(p, modified_properties); /// Field Of View - p = obs_properties_add_float_slider(pr, ST_CAMERA_FIELDOFVIEW, P_TRANSLATE(ST_CAMERA_FIELDOFVIEW), 1.0, 179.0, + p = obs_properties_add_float_slider(pr, ST_CAMERA_FIELDOFVIEW, D_TRANSLATE(ST_CAMERA_FIELDOFVIEW), 1.0, 179.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_CAMERA_FIELDOFVIEW))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_CAMERA_FIELDOFVIEW))); // Mesh /// Position { std::pair entries[] = { - std::make_pair(ST_POSITION_X, P_DESC(ST_POSITION)), - std::make_pair(ST_POSITION_Y, P_DESC(ST_POSITION)), - std::make_pair(ST_POSITION_Z, P_DESC(ST_POSITION)), + std::make_pair(ST_POSITION_X, D_DESC(ST_POSITION)), + std::make_pair(ST_POSITION_Y, D_DESC(ST_POSITION)), + std::make_pair(ST_POSITION_Z, D_DESC(ST_POSITION)), }; for (auto kv : entries) { - p = obs_properties_add_float(pr, kv.first, P_TRANSLATE(kv.first), -10000, 10000, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(kv.second)); + p = obs_properties_add_float(pr, kv.first, D_TRANSLATE(kv.first), -10000, 10000, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(kv.second)); } } /// Rotation { std::pair entries[] = { - std::make_pair(ST_ROTATION_X, P_DESC(ST_ROTATION)), - std::make_pair(ST_ROTATION_Y, P_DESC(ST_ROTATION)), - std::make_pair(ST_ROTATION_Z, P_DESC(ST_ROTATION)), + std::make_pair(ST_ROTATION_X, D_DESC(ST_ROTATION)), + std::make_pair(ST_ROTATION_Y, D_DESC(ST_ROTATION)), + std::make_pair(ST_ROTATION_Z, D_DESC(ST_ROTATION)), }; for (auto kv : entries) { - p = obs_properties_add_float_slider(pr, kv.first, P_TRANSLATE(kv.first), -180, 180, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(kv.second)); + p = obs_properties_add_float_slider(pr, kv.first, D_TRANSLATE(kv.first), -180, 180, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(kv.second)); } } /// Scale { std::pair entries[] = { - std::make_pair(ST_SCALE_X, P_DESC(ST_SCALE)), - std::make_pair(ST_SCALE_Y, P_DESC(ST_SCALE)), + std::make_pair(ST_SCALE_X, D_DESC(ST_SCALE)), + std::make_pair(ST_SCALE_Y, D_DESC(ST_SCALE)), }; for (auto kv : entries) { - p = obs_properties_add_float_slider(pr, kv.first, P_TRANSLATE(kv.first), -1000, 1000, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(kv.second)); + p = obs_properties_add_float_slider(pr, kv.first, D_TRANSLATE(kv.first), -1000, 1000, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(kv.second)); } } /// Shear { std::pair entries[] = { - std::make_pair(ST_SHEAR_X, P_DESC(ST_SHEAR)), - std::make_pair(ST_SHEAR_Y, P_DESC(ST_SHEAR)), + std::make_pair(ST_SHEAR_X, D_DESC(ST_SHEAR)), + std::make_pair(ST_SHEAR_Y, D_DESC(ST_SHEAR)), }; for (auto kv : entries) { - p = obs_properties_add_float_slider(pr, kv.first, P_TRANSLATE(kv.first), -100.0, 100.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(kv.second)); + p = obs_properties_add_float_slider(pr, kv.first, D_TRANSLATE(kv.first), -100.0, 100.0, 0.01); + obs_property_set_long_description(p, D_TRANSLATE(kv.second)); } } - p = obs_properties_add_bool(pr, S_ADVANCED, P_TRANSLATE(S_ADVANCED)); + p = obs_properties_add_bool(pr, S_ADVANCED, D_TRANSLATE(S_ADVANCED)); obs_property_set_modified_callback(p, modified_properties); - p = obs_properties_add_list(pr, ST_ROTATION_ORDER, P_TRANSLATE(ST_ROTATION_ORDER), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_ROTATION_ORDER, D_TRANSLATE(ST_ROTATION_ORDER), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_ROTATION_ORDER))); - obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_XYZ), RotationOrder::XYZ); - obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_XZY), RotationOrder::XZY); - obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_YXZ), RotationOrder::YXZ); - obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_YZX), RotationOrder::YZX); - obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_ZXY), RotationOrder::ZXY); - obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_ZYX), RotationOrder::ZYX); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_ROTATION_ORDER))); + obs_property_list_add_int(p, D_TRANSLATE(ST_ROTATION_ORDER_XYZ), RotationOrder::XYZ); + obs_property_list_add_int(p, D_TRANSLATE(ST_ROTATION_ORDER_XZY), RotationOrder::XZY); + obs_property_list_add_int(p, D_TRANSLATE(ST_ROTATION_ORDER_YXZ), RotationOrder::YXZ); + obs_property_list_add_int(p, D_TRANSLATE(ST_ROTATION_ORDER_YZX), RotationOrder::YZX); + obs_property_list_add_int(p, D_TRANSLATE(ST_ROTATION_ORDER_ZXY), RotationOrder::ZXY); + obs_property_list_add_int(p, D_TRANSLATE(ST_ROTATION_ORDER_ZYX), RotationOrder::ZYX); - p = obs_properties_add_bool(pr, ST_MIPMAPPING, P_TRANSLATE(ST_MIPMAPPING)); + p = obs_properties_add_bool(pr, ST_MIPMAPPING, D_TRANSLATE(ST_MIPMAPPING)); obs_property_set_modified_callback(p, modified_properties); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_MIPMAPPING))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MIPMAPPING))); - p = obs_properties_add_list(pr, S_MIPGENERATOR, P_TRANSLATE(S_MIPGENERATOR), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, S_MIPGENERATOR, D_TRANSLATE(S_MIPGENERATOR), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_MIPGENERATOR))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(S_MIPGENERATOR))); - obs_property_list_add_int(p, P_TRANSLATE(S_MIPGENERATOR_POINT), (long long)gs::mipmapper::generator::Point); - obs_property_list_add_int(p, P_TRANSLATE(S_MIPGENERATOR_LINEAR), (long long)gs::mipmapper::generator::Linear); - obs_property_list_add_int(p, P_TRANSLATE(S_MIPGENERATOR_SHARPEN), (long long)gs::mipmapper::generator::Sharpen); - obs_property_list_add_int(p, P_TRANSLATE(S_MIPGENERATOR_SMOOTHEN), (long long)gs::mipmapper::generator::Smoothen); - obs_property_list_add_int(p, P_TRANSLATE(S_MIPGENERATOR_BICUBIC), (long long)gs::mipmapper::generator::Bicubic); - obs_property_list_add_int(p, P_TRANSLATE(S_MIPGENERATOR_LANCZOS), (long long)gs::mipmapper::generator::Lanczos); + obs_property_list_add_int(p, D_TRANSLATE(S_MIPGENERATOR_POINT), (long long)gs::mipmapper::generator::Point); + obs_property_list_add_int(p, D_TRANSLATE(S_MIPGENERATOR_LINEAR), (long long)gs::mipmapper::generator::Linear); + obs_property_list_add_int(p, D_TRANSLATE(S_MIPGENERATOR_SHARPEN), (long long)gs::mipmapper::generator::Sharpen); + obs_property_list_add_int(p, D_TRANSLATE(S_MIPGENERATOR_SMOOTHEN), (long long)gs::mipmapper::generator::Smoothen); + obs_property_list_add_int(p, D_TRANSLATE(S_MIPGENERATOR_BICUBIC), (long long)gs::mipmapper::generator::Bicubic); + obs_property_list_add_int(p, D_TRANSLATE(S_MIPGENERATOR_LANCZOS), (long long)gs::mipmapper::generator::Lanczos); - p = obs_properties_add_float_slider(pr, S_MIPGENERATOR_INTENSITY, P_TRANSLATE(S_MIPGENERATOR_INTENSITY), 0.0, + p = obs_properties_add_float_slider(pr, S_MIPGENERATOR_INTENSITY, D_TRANSLATE(S_MIPGENERATOR_INTENSITY), 0.0, 1000.0, 0.01); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(S_MIPGENERATOR_INTENSITY))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(S_MIPGENERATOR_INTENSITY))); return pr; } @@ -316,34 +316,34 @@ void filter::transform::transform_factory::video_render(void* ptr, gs_effect_t* filter::transform::transform_instance::~transform_instance() { - m_shear.reset(); - m_scale.reset(); - m_rotation.reset(); - m_position.reset(); - m_vertex_buffer.reset(); - m_shape_texture.reset(); - m_shape_rendertarget.reset(); - m_source_texture.reset(); - m_source_rendertarget.reset(); + _shear.reset(); + _scale.reset(); + _rotation.reset(); + _position.reset(); + _vertex_buffer.reset(); + _shape_texture.reset(); + _shape_rendertarget.reset(); + _source_texture.reset(); + _source_rendertarget.reset(); } filter::transform::transform_instance::transform_instance(obs_data_t* data, obs_source_t* context) - : m_active(true), m_self(context), m_source_rendered(false), m_mipmap_enabled(false), m_mipmap_strength(50.0), - m_mipmap_generator(gs::mipmapper::generator::Linear), m_update_mesh(false), m_rotation_order(RotationOrder::ZXY), - m_camera_orthographic(true), m_camera_fov(90.0) + : _active(true), _self(context), _source_rendered(false), _mipmap_enabled(false), _mipmap_strength(50.0), + _mipmap_generator(gs::mipmapper::generator::Linear), _update_mesh(false), _rotation_order(RotationOrder::ZXY), + _camera_orthographic(true), _camera_fov(90.0) { - m_source_rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); - m_shape_rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); - m_vertex_buffer = std::make_shared(uint32_t(4u), uint8_t(1u)); + _source_rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); + _shape_rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); + _vertex_buffer = std::make_shared(uint32_t(4u), uint8_t(1u)); - m_position = std::make_unique(); - m_rotation = std::make_unique(); - m_scale = std::make_unique(); - m_shear = std::make_unique(); + _position = std::make_unique(); + _rotation = std::make_unique(); + _scale = std::make_unique(); + _shear = std::make_unique(); - vec3_set(m_position.get(), 0, 0, 0); - vec3_set(m_rotation.get(), 0, 0, 0); - vec3_set(m_scale.get(), 1, 1, 1); + vec3_set(_position.get(), 0, 0, 0); + vec3_set(_rotation.get(), 0, 0, 0); + vec3_set(_scale.get(), 1, 1, 1); update(data); } @@ -361,40 +361,40 @@ uint32_t filter::transform::transform_instance::get_height() void filter::transform::transform_instance::update(obs_data_t* data) { // Camera - m_camera_orthographic = obs_data_get_int(data, ST_CAMERA) == 0; - m_camera_fov = (float)obs_data_get_double(data, ST_CAMERA_FIELDOFVIEW); + _camera_orthographic = obs_data_get_int(data, ST_CAMERA) == 0; + _camera_fov = (float)obs_data_get_double(data, ST_CAMERA_FIELDOFVIEW); // Source - m_position->x = static_cast(obs_data_get_double(data, ST_POSITION_X) / 100.0); - m_position->y = static_cast(obs_data_get_double(data, ST_POSITION_Y) / 100.0); - m_position->z = static_cast(obs_data_get_double(data, ST_POSITION_Z) / 100.0); - m_scale->x = static_cast(obs_data_get_double(data, ST_SCALE_X) / 100.0); - m_scale->y = static_cast(obs_data_get_double(data, ST_SCALE_Y) / 100.0); - m_scale->z = 1.0f; - m_rotation_order = static_cast(obs_data_get_int(data, ST_ROTATION_ORDER)); - m_rotation->x = static_cast(obs_data_get_double(data, ST_ROTATION_X) / 180.0 * PI); - m_rotation->y = static_cast(obs_data_get_double(data, ST_ROTATION_Y) / 180.0 * PI); - m_rotation->z = static_cast(obs_data_get_double(data, ST_ROTATION_Z) / 180.0 * PI); - m_shear->x = static_cast(obs_data_get_double(data, ST_SHEAR_X) / 100.0); - m_shear->y = static_cast(obs_data_get_double(data, ST_SHEAR_Y) / 100.0); - m_shear->z = 0.0f; + _position->x = static_cast(obs_data_get_double(data, ST_POSITION_X) / 100.0); + _position->y = static_cast(obs_data_get_double(data, ST_POSITION_Y) / 100.0); + _position->z = static_cast(obs_data_get_double(data, ST_POSITION_Z) / 100.0); + _scale->x = static_cast(obs_data_get_double(data, ST_SCALE_X) / 100.0); + _scale->y = static_cast(obs_data_get_double(data, ST_SCALE_Y) / 100.0); + _scale->z = 1.0f; + _rotation_order = static_cast(obs_data_get_int(data, ST_ROTATION_ORDER)); + _rotation->x = static_cast(obs_data_get_double(data, ST_ROTATION_X) / 180.0 * S_PI); + _rotation->y = static_cast(obs_data_get_double(data, ST_ROTATION_Y) / 180.0 * S_PI); + _rotation->z = static_cast(obs_data_get_double(data, ST_ROTATION_Z) / 180.0 * S_PI); + _shear->x = static_cast(obs_data_get_double(data, ST_SHEAR_X) / 100.0); + _shear->y = static_cast(obs_data_get_double(data, ST_SHEAR_Y) / 100.0); + _shear->z = 0.0f; // Mipmapping - m_mipmap_enabled = obs_data_get_bool(data, ST_MIPMAPPING); - m_mipmap_strength = obs_data_get_double(data, S_MIPGENERATOR_INTENSITY); - m_mipmap_generator = static_cast(obs_data_get_int(data, S_MIPGENERATOR)); + _mipmap_enabled = obs_data_get_bool(data, ST_MIPMAPPING); + _mipmap_strength = obs_data_get_double(data, S_MIPGENERATOR_INTENSITY); + _mipmap_generator = static_cast(obs_data_get_int(data, S_MIPGENERATOR)); - m_update_mesh = true; + _update_mesh = true; } void filter::transform::transform_instance::activate() { - m_active = true; + _active = true; } void filter::transform::transform_instance::deactivate() { - m_active = false; + _active = false; } void filter::transform::transform_instance::video_tick(float) @@ -403,7 +403,7 @@ void filter::transform::transform_instance::video_tick(float) uint32_t height = 0; // Grab parent and target. - obs_source_t* target = obs_filter_get_target(m_self); + obs_source_t* target = obs_filter_get_target(_self); if (target) { // Grab width an height of the target source (child filter or source). width = obs_source_get_base_width(target); @@ -411,16 +411,16 @@ void filter::transform::transform_instance::video_tick(float) } // If size mismatch, force an update. - if (width != m_source_size.first) { - m_update_mesh = true; - } else if (height != m_source_size.second) { - m_update_mesh = true; + if (width != _source_size.first) { + _update_mesh = true; + } else if (height != _source_size.second) { + _update_mesh = true; } // Update Mesh - if (m_update_mesh) { - m_source_size.first = width; - m_source_size.second = height; + if (_update_mesh) { + _source_size.first = width; + _source_size.second = height; if (width == 0) { width = 1; @@ -431,99 +431,99 @@ void filter::transform::transform_instance::video_tick(float) // Calculate Aspect Ratio float_t aspectRatioX = float_t(width) / float_t(height); - if (m_camera_orthographic) + if (_camera_orthographic) aspectRatioX = 1.0; // Mesh matrix4 ident; matrix4_identity(&ident); - switch (m_rotation_order) { + switch (_rotation_order) { case RotationOrder::XYZ: // XYZ - matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, m_rotation->x); - matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, m_rotation->y); - matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, m_rotation->z); + matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, _rotation->x); + matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, _rotation->y); + matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, _rotation->z); break; case RotationOrder::XZY: // XZY - matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, m_rotation->x); - matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, m_rotation->z); - matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, m_rotation->y); + matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, _rotation->x); + matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, _rotation->z); + matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, _rotation->y); break; case RotationOrder::YXZ: // YXZ - matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, m_rotation->y); - matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, m_rotation->x); - matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, m_rotation->z); + matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, _rotation->y); + matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, _rotation->x); + matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, _rotation->z); break; case RotationOrder::YZX: // YZX - matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, m_rotation->y); - matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, m_rotation->z); - matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, m_rotation->x); + matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, _rotation->y); + matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, _rotation->z); + matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, _rotation->x); break; case RotationOrder::ZXY: // ZXY - matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, m_rotation->z); - matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, m_rotation->x); - matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, m_rotation->y); + matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, _rotation->z); + matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, _rotation->x); + matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, _rotation->y); break; case RotationOrder::ZYX: // ZYX - matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, m_rotation->z); - matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, m_rotation->y); - matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, m_rotation->x); + matrix4_rotate_aa4f(&ident, &ident, 0, 0, 1, _rotation->z); + matrix4_rotate_aa4f(&ident, &ident, 0, 1, 0, _rotation->y); + matrix4_rotate_aa4f(&ident, &ident, 1, 0, 0, _rotation->x); break; } - matrix4_translate3f(&ident, &ident, m_position->x, m_position->y, m_position->z); + matrix4_translate3f(&ident, &ident, _position->x, _position->y, _position->z); /// Calculate vertex position once only. - float_t p_x = aspectRatioX * m_scale->x; - float_t p_y = 1.0f * m_scale->y; + float_t p_x = aspectRatioX * _scale->x; + float_t p_y = 1.0f * _scale->y; /// Generate mesh { - auto vtx = m_vertex_buffer->at(0); + auto vtx = _vertex_buffer->at(0); *vtx.color = 0xFFFFFFFF; vec4_set(vtx.uv[0], 0, 0, 0, 0); - vec3_set(vtx.position, -p_x + m_shear->x, -p_y - m_shear->y, 0); + vec3_set(vtx.position, -p_x + _shear->x, -p_y - _shear->y, 0); vec3_transform(vtx.position, vtx.position, &ident); } { - auto vtx = m_vertex_buffer->at(1); + auto vtx = _vertex_buffer->at(1); *vtx.color = 0xFFFFFFFF; vec4_set(vtx.uv[0], 1, 0, 0, 0); - vec3_set(vtx.position, p_x + m_shear->x, -p_y + m_shear->y, 0); + vec3_set(vtx.position, p_x + _shear->x, -p_y + _shear->y, 0); vec3_transform(vtx.position, vtx.position, &ident); } { - auto vtx = m_vertex_buffer->at(2); + auto vtx = _vertex_buffer->at(2); *vtx.color = 0xFFFFFFFF; vec4_set(vtx.uv[0], 0, 1, 0, 0); - vec3_set(vtx.position, -p_x - m_shear->x, p_y - m_shear->y, 0); + vec3_set(vtx.position, -p_x - _shear->x, p_y - _shear->y, 0); vec3_transform(vtx.position, vtx.position, &ident); } { - auto vtx = m_vertex_buffer->at(3); + auto vtx = _vertex_buffer->at(3); *vtx.color = 0xFFFFFFFF; vec4_set(vtx.uv[0], 1, 1, 0, 0); - vec3_set(vtx.position, p_x - m_shear->x, p_y + m_shear->y, 0); + vec3_set(vtx.position, p_x - _shear->x, p_y + _shear->y, 0); vec3_transform(vtx.position, vtx.position, &ident); } - m_vertex_buffer->update(true); - m_update_mesh = false; + _vertex_buffer->update(true); + _update_mesh = false; } - this->m_source_rendered = false; + this->_source_rendered = false; } void filter::transform::transform_instance::video_render(gs_effect_t* paramEffect) { - if (!m_active) { - obs_source_skip_video_filter(m_self); + if (!_active) { + obs_source_skip_video_filter(_self); return; } // Grab parent and target. - obs_source_t* parent = obs_filter_get_parent(m_self); - obs_source_t* target = obs_filter_get_target(m_self); + obs_source_t* parent = obs_filter_get_parent(_self); + obs_source_t* target = obs_filter_get_target(_self); if (!parent || !target) { - obs_source_skip_video_filter(m_self); + obs_source_skip_video_filter(_self); return; } @@ -531,20 +531,20 @@ void filter::transform::transform_instance::video_render(gs_effect_t* paramEffec uint32_t width = obs_source_get_base_width(target); uint32_t height = obs_source_get_base_height(target); if ((width == 0) || (height == 0)) { - obs_source_skip_video_filter(m_self); + obs_source_skip_video_filter(_self); return; } gs_effect_t* default_effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); // Only render if we didn't already render. - if (!this->m_source_rendered) { + if (!this->_source_rendered) { std::shared_ptr source_tex; uint32_t real_width = width; uint32_t real_height = height; // If MipMapping is enabled, resize Render Target to be a Power of Two. - if (m_mipmap_enabled) { + if (_mipmap_enabled) { real_width = uint32_t(pow(2, util::math::get_power_of_two_exponent_ceil(width))); real_height = uint32_t(pow(2, util::math::get_power_of_two_exponent_ceil(height))); if ((real_width >= 8192) || (real_height >= 8192)) { @@ -562,7 +562,7 @@ void filter::transform::transform_instance::video_render(gs_effect_t* paramEffec // Draw previous filters to texture. try { - auto op = m_source_rendertarget->render(real_width, real_height); + auto op = _source_rendertarget->render(real_width, real_height); gs_set_cull_mode(GS_NEITHER); gs_reset_blend_state(); @@ -579,20 +579,20 @@ void filter::transform::transform_instance::video_render(gs_effect_t* paramEffec gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0); /// Render original source - if (obs_source_process_filter_begin(m_self, GS_RGBA, OBS_NO_DIRECT_RENDERING)) { - obs_source_process_filter_end(m_self, paramEffect ? paramEffect : default_effect, width, height); + if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_NO_DIRECT_RENDERING)) { + obs_source_process_filter_end(_self, paramEffect ? paramEffect : default_effect, width, height); } else { - obs_source_skip_video_filter(m_self); + obs_source_skip_video_filter(_self); } } catch (...) { - obs_source_skip_video_filter(m_self); + obs_source_skip_video_filter(_self); return; } - m_source_rendertarget->get_texture(source_tex); + _source_rendertarget->get_texture(source_tex); - if (m_mipmap_enabled) { - if ((!m_source_texture) || (m_source_texture->get_width() != real_width) - || (m_source_texture->get_height() != real_height)) { + if (_mipmap_enabled) { + if ((!_source_texture) || (_source_texture->get_width() != real_width) + || (_source_texture->get_height() != real_height)) { size_t mip_levels = 0; if (util::math::is_power_of_two(real_width) && util::math::is_power_of_two(real_height)) { size_t w_level = util::math::get_power_of_two_exponent_ceil(real_width); @@ -604,22 +604,22 @@ void filter::transform::transform_instance::video_render(gs_effect_t* paramEffec } } - m_source_texture = + _source_texture = std::make_shared(real_width, real_height, GS_RGBA, uint32_t(1u + mip_levels), nullptr, gs::texture::flags::BuildMipMaps); } - m_mipmapper.rebuild(source_tex, m_source_texture, m_mipmap_generator, float_t(m_mipmap_strength)); + _mipmapper.rebuild(source_tex, _source_texture, _mipmap_generator, float_t(_mipmap_strength)); } // Draw shape to texture try { - auto op = m_shape_rendertarget->render(width, height); + auto op = _shape_rendertarget->render(width, height); - if (m_camera_orthographic) { + if (_camera_orthographic) { gs_ortho(-1.0, 1.0, -1.0, 1.0, -farZ, farZ); } else { - gs_perspective(m_camera_fov, float_t(width) / float_t(height), nearZ, farZ); + gs_perspective(_camera_fov, float_t(width) / float_t(height), nearZ, farZ); // Fix camera pointing at -Z instead of +Z. gs_matrix_scale3f(1.0, 1.0, -1.0); // Move backwards so we can actually see stuff. @@ -637,28 +637,28 @@ void filter::transform::transform_instance::video_render(gs_effect_t* paramEffec gs_enable_stencil_test(false); gs_enable_stencil_write(false); gs_enable_color(true, true, true, true); - gs_load_vertexbuffer(m_vertex_buffer->update(false)); + gs_load_vertexbuffer(_vertex_buffer->update(false)); gs_load_indexbuffer(nullptr); while (gs_effect_loop(default_effect, "Draw")) { gs_effect_set_texture(gs_effect_get_param_by_name(default_effect, "image"), - m_mipmap_enabled ? m_source_texture->get_object() : source_tex->get_object()); + _mipmap_enabled ? _source_texture->get_object() : source_tex->get_object()); gs_draw(GS_TRISTRIP, 0, 4); } gs_load_vertexbuffer(nullptr); } catch (...) { - obs_source_skip_video_filter(m_self); + obs_source_skip_video_filter(_self); return; } - m_shape_rendertarget->get_texture(m_shape_texture); + _shape_rendertarget->get_texture(_shape_texture); - this->m_source_rendered = true; + this->_source_rendered = true; } // Draw final shape gs_reset_blend_state(); gs_enable_depth_test(false); while (gs_effect_loop(default_effect, "Draw")) { - gs_effect_set_texture(gs_effect_get_param_by_name(default_effect, "image"), m_shape_texture->get_object()); - gs_draw_sprite(m_shape_texture->get_object(), 0, 0, 0); + gs_effect_set_texture(gs_effect_get_param_by_name(default_effect, "image"), _shape_texture->get_object()); + gs_draw_sprite(_shape_texture->get_object(), 0, 0, 0); } } diff --git a/source/filters/filter-transform.hpp b/source/filters/filter-transform.hpp index b3381a7c..0fc70efe 100644 --- a/source/filters/filter-transform.hpp +++ b/source/filters/filter-transform.hpp @@ -29,7 +29,7 @@ namespace filter { namespace transform { class transform_factory { - obs_source_info sourceInfo; + obs_source_info _source_info; public: // Singleton static void initialize(); @@ -59,37 +59,37 @@ namespace filter { }; class transform_instance { - bool m_active; - obs_source_t* m_self; + bool _active; + obs_source_t* _self; // Input - std::shared_ptr m_source_rendertarget; - std::shared_ptr m_source_texture; - bool m_source_rendered; - std::pair m_source_size; + std::shared_ptr _source_rendertarget; + std::shared_ptr _source_texture; + bool _source_rendered; + std::pair _source_size; // Mipmapping - bool m_mipmap_enabled; - double_t m_mipmap_strength; - gs::mipmapper::generator m_mipmap_generator; - gs::mipmapper m_mipmapper; + bool _mipmap_enabled; + double_t _mipmap_strength; + gs::mipmapper::generator _mipmap_generator; + gs::mipmapper _mipmapper; // Rendering - std::shared_ptr m_shape_rendertarget; - std::shared_ptr m_shape_texture; + std::shared_ptr _shape_rendertarget; + std::shared_ptr _shape_texture; // Mesh - bool m_update_mesh; - std::shared_ptr m_vertex_buffer; - uint32_t m_rotation_order; - std::unique_ptr m_position; - std::unique_ptr m_rotation; - std::unique_ptr m_scale; - std::unique_ptr m_shear; + bool _update_mesh; + std::shared_ptr _vertex_buffer; + uint32_t _rotation_order; + std::unique_ptr _position; + std::unique_ptr _rotation; + std::unique_ptr _scale; + std::unique_ptr _shear; // Camera - bool m_camera_orthographic; - float_t m_camera_fov; + bool _camera_orthographic; + float_t _camera_fov; public: ~transform_instance(); diff --git a/source/gfx/blur/gfx-blur-base.cpp b/source/gfx/blur/gfx-blur-base.cpp index 0b1dbb52..48720a75 100644 --- a/source/gfx/blur/gfx-blur-base.cpp +++ b/source/gfx/blur/gfx-blur-base.cpp @@ -17,48 +17,48 @@ #include "gfx-blur-base.hpp" -void gfx::blur::ibase::set_step_scale_x(double_t v) +void gfx::blur::base::set_step_scale_x(double_t v) { this->set_step_scale(v, this->get_step_scale_y()); } -void gfx::blur::ibase::set_step_scale_y(double_t v) +void gfx::blur::base::set_step_scale_y(double_t v) { this->set_step_scale(this->get_step_scale_x(), v); } -double_t gfx::blur::ibase::get_step_scale_x() +double_t gfx::blur::base::get_step_scale_x() { double_t x, y; this->get_step_scale(x, y); return x; } -double_t gfx::blur::ibase::get_step_scale_y() +double_t gfx::blur::base::get_step_scale_y() { double_t x, y; this->get_step_scale(x, y); return y; } -void gfx::blur::ibase_center::set_center_x(double_t v) +void gfx::blur::base_center::set_center_x(double_t v) { this->set_center(v, this->get_center_y()); } -void gfx::blur::ibase_center::set_center_y(double_t v) +void gfx::blur::base_center::set_center_y(double_t v) { this->set_center(this->get_center_x(), v); } -double_t gfx::blur::ibase_center::get_center_x() +double_t gfx::blur::base_center::get_center_x() { double_t x, y; this->get_center(x, y); return x; } -double_t gfx::blur::ibase_center::get_center_y() +double_t 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 4f107129..30dcdaf6 100644 --- a/source/gfx/blur/gfx-blur-base.hpp +++ b/source/gfx/blur/gfx-blur-base.hpp @@ -31,9 +31,9 @@ namespace gfx { Zoom, }; - class ibase { + class base { public: - virtual ~ibase() {} + virtual ~base() {} virtual void set_input(std::shared_ptr<::gs::texture> texture) = 0; @@ -60,18 +60,18 @@ namespace gfx { virtual std::shared_ptr<::gs::texture> get() = 0; }; - class ibase_angle { + class base_angle { public: - virtual ~ibase_angle() {} + virtual ~base_angle() {} virtual double_t get_angle() = 0; virtual void set_angle(double_t angle) = 0; }; - class ibase_center { + class base_center { public: - virtual ~ibase_center() {} + virtual ~base_center() {} virtual void set_center(double_t x, double_t y) = 0; @@ -92,7 +92,7 @@ namespace gfx { virtual bool is_type_supported(::gfx::blur::type type) = 0; - virtual std::shared_ptr<::gfx::blur::ibase> create(::gfx::blur::type type) = 0; + virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) = 0; virtual double_t get_min_size(::gfx::blur::type type) = 0; diff --git a/source/gfx/blur/gfx-blur-box-linear.cpp b/source/gfx/blur/gfx-blur-box-linear.cpp index d6eff840..99374644 100644 --- a/source/gfx/blur/gfx-blur-box-linear.cpp +++ b/source/gfx/blur/gfx-blur-box-linear.cpp @@ -38,23 +38,23 @@ gfx::blur::box_linear_data::box_linear_data() { auto gctx = gs::context(); try { - char* file = obs_module_file("effects/blur/box-linear.effect"); - m_effect = std::make_shared<::gs::effect>(file); + char* file = obs_module_file("effects/blur/box-linear._effect"); + _effect = std::make_shared<::gs::effect>(file); bfree(file); } catch (...) { - P_LOG_ERROR(" Failed to load effect."); + P_LOG_ERROR(" Failed to load _effect."); } } gfx::blur::box_linear_data::~box_linear_data() { auto gctx = gs::context(); - m_effect.reset(); + _effect.reset(); } std::shared_ptr<::gs::effect> gfx::blur::box_linear_data::get_effect() { - return m_effect; + return _effect; } gfx::blur::box_linear_factory::box_linear_factory() {} @@ -73,7 +73,7 @@ bool gfx::blur::box_linear_factory::is_type_supported(::gfx::blur::type type) } } -std::shared_ptr<::gfx::blur::ibase> gfx::blur::box_linear_factory::create(::gfx::blur::type type) +std::shared_ptr<::gfx::blur::base> gfx::blur::box_linear_factory::create(::gfx::blur::type type) { switch (type) { case ::gfx::blur::type::Area: @@ -171,11 +171,11 @@ double_t gfx::blur::box_linear_factory::get_max_step_scale_y(::gfx::blur::type) std::shared_ptr<::gfx::blur::box_linear_data> gfx::blur::box_linear_factory::data() { - std::unique_lock ulock(m_data_lock); - std::shared_ptr<::gfx::blur::box_linear_data> data = m_data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::gfx::blur::box_linear_data> data = _data.lock(); if (!data) { data = std::make_shared<::gfx::blur::box_linear_data>(); - m_data = data; + _data = data; } return data; } @@ -187,17 +187,17 @@ std::shared_ptr<::gfx::blur::box_linear_data> gfx::blur::box_linear_factory::dat } gfx::blur::box_linear::box_linear() - : m_data(::gfx::blur::box_linear_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) + : _data(::gfx::blur::box_linear_factory::get().data()), _size(1.), _step_scale({1., 1.}) { - m_rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); - m_rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); + _rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); + _rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); } gfx::blur::box_linear::~box_linear() {} void gfx::blur::box_linear::set_input(std::shared_ptr<::gs::texture> texture) { - m_input_texture = texture; + _input_texture = texture; } ::gfx::blur::type gfx::blur::box_linear::get_type() @@ -207,46 +207,46 @@ void gfx::blur::box_linear::set_input(std::shared_ptr<::gs::texture> texture) double_t gfx::blur::box_linear::get_size() { - return m_size; + return _size; } void gfx::blur::box_linear::set_size(double_t width) { - m_size = width; - if (m_size < 1.0) { - m_size = 1.0; + _size = width; + if (_size < 1.0) { + _size = 1.0; } - if (m_size > MAX_BLUR_SIZE) { - m_size = MAX_BLUR_SIZE; + if (_size > MAX_BLUR_SIZE) { + _size = MAX_BLUR_SIZE; } } void gfx::blur::box_linear::set_step_scale(double_t x, double_t y) { - m_step_scale = {x, y}; + _step_scale = {x, y}; } void gfx::blur::box_linear::get_step_scale(double_t& x, double_t& y) { - x = m_step_scale.first; - y = m_step_scale.second; + x = _step_scale.first; + y = _step_scale.second; } double_t gfx::blur::box_linear::get_step_scale_x() { - return m_step_scale.first; + return _step_scale.first; } double_t gfx::blur::box_linear::get_step_scale_y() { - return m_step_scale.second; + return _step_scale.second; } std::shared_ptr<::gs::texture> gfx::blur::box_linear::render() { auto gctx = gs::context(); - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); gs_set_cull_mode(GS_NEITHER); gs_enable_color(true, true, true, true); @@ -262,17 +262,17 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); // Two Pass Blur - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); if (effect) { // Pass 1 - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); + 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("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f))); { - auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -280,11 +280,11 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render() } // Pass 2 - effect->get_parameter("pImage").set_texture(m_rendertarget2->get_texture()); + effect->get_parameter("pImage").set_texture(_rendertarget2->get_texture()); effect->get_parameter("pImageTexel").set_float2(0., float_t(1.f / height)); { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -294,15 +294,15 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear::render() gs_blend_state_pop(); - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } std::shared_ptr<::gs::texture> gfx::blur::box_linear::get() { - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } -gfx::blur::box_linear_directional::box_linear_directional() : m_angle(0) {} +gfx::blur::box_linear_directional::box_linear_directional() : _angle(0) {} ::gfx::blur::type gfx::blur::box_linear_directional::get_type() { @@ -311,19 +311,19 @@ gfx::blur::box_linear_directional::box_linear_directional() : m_angle(0) {} double_t gfx::blur::box_linear_directional::get_angle() { - return RAD_TO_DEG(m_angle); + return D_RAD_TO_DEG(_angle); } void gfx::blur::box_linear_directional::set_angle(double_t angle) { - m_angle = DEG_TO_RAD(angle); + _angle = D_DEG_TO_RAD(angle); } std::shared_ptr<::gs::texture> gfx::blur::box_linear_directional::render() { auto gctx = gs::context(); - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); gs_blend_state_push(); gs_reset_blend_state(); @@ -339,17 +339,17 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear_directional::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); // One Pass Blur - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); if (effect) { - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel") - .set_float2(float_t(1. / width * cos(m_angle)), float_t(1.f / height * sin(m_angle))); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); + .set_float2(float_t(1. / 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("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f))); { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -359,5 +359,5 @@ std::shared_ptr<::gs::texture> gfx::blur::box_linear_directional::render() gs_blend_state_pop(); - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } diff --git a/source/gfx/blur/gfx-blur-box-linear.hpp b/source/gfx/blur/gfx-blur-box-linear.hpp index 2658566b..4d95aad3 100644 --- a/source/gfx/blur/gfx-blur-box-linear.hpp +++ b/source/gfx/blur/gfx-blur-box-linear.hpp @@ -27,7 +27,7 @@ namespace gfx { namespace blur { class box_linear_data { - std::shared_ptr<::gs::effect> m_effect; + std::shared_ptr<::gs::effect> _effect; public: box_linear_data(); @@ -37,8 +37,8 @@ namespace gfx { }; class box_linear_factory : public ::gfx::blur::ifactory { - std::mutex m_data_lock; - std::weak_ptr<::gfx::blur::box_linear_data> m_data; + std::mutex _data_lock; + std::weak_ptr<::gfx::blur::box_linear_data> _data; public: box_linear_factory(); @@ -46,7 +46,7 @@ namespace gfx { virtual bool is_type_supported(::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::ibase> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; virtual double_t get_min_size(::gfx::blur::type type) override; @@ -80,17 +80,17 @@ namespace gfx { static ::gfx::blur::box_linear_factory& get(); }; - class box_linear : public ::gfx::blur::ibase { + class box_linear : public ::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::box_linear_data> m_data; + std::shared_ptr<::gfx::blur::box_linear_data> _data; - double_t m_size; - std::pair m_step_scale; - std::shared_ptr<::gs::texture> m_input_texture; - std::shared_ptr<::gs::rendertarget> m_rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::gs::texture> _input_texture; + std::shared_ptr<::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> m_rendertarget2; + std::shared_ptr<::gs::rendertarget> _rendertarget2; public: box_linear(); @@ -112,8 +112,8 @@ namespace gfx { virtual std::shared_ptr<::gs::texture> get() override; }; - class box_linear_directional : public ::gfx::blur::box_linear, public ::gfx::blur::ibase_angle { - double_t m_angle; + class box_linear_directional : public ::gfx::blur::box_linear, public ::gfx::blur::base_angle { + double_t _angle; public: box_linear_directional(); diff --git a/source/gfx/blur/gfx-blur-box.cpp b/source/gfx/blur/gfx-blur-box.cpp index efe73722..6be84b2b 100644 --- a/source/gfx/blur/gfx-blur-box.cpp +++ b/source/gfx/blur/gfx-blur-box.cpp @@ -38,23 +38,23 @@ gfx::blur::box_data::box_data() { auto gctx = gs::context(); try { - char* file = obs_module_file("effects/blur/box.effect"); - m_effect = std::make_shared<::gs::effect>(file); + char* file = obs_module_file("effects/blur/box._effect"); + _effect = std::make_shared<::gs::effect>(file); bfree(file); } catch (...) { - P_LOG_ERROR(" Failed to load effect."); + P_LOG_ERROR(" Failed to load _effect."); } } gfx::blur::box_data::~box_data() { auto gctx = gs::context(); - m_effect.reset(); + _effect.reset(); } std::shared_ptr<::gs::effect> gfx::blur::box_data::get_effect() { - return m_effect; + return _effect; } gfx::blur::box_factory::box_factory() {} @@ -77,7 +77,7 @@ bool gfx::blur::box_factory::is_type_supported(::gfx::blur::type type) } } -std::shared_ptr<::gfx::blur::ibase> gfx::blur::box_factory::create(::gfx::blur::type type) +std::shared_ptr<::gfx::blur::base> gfx::blur::box_factory::create(::gfx::blur::type type) { switch (type) { case ::gfx::blur::type::Area: @@ -179,11 +179,11 @@ double_t gfx::blur::box_factory::get_max_step_scale_y(::gfx::blur::type) std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data() { - std::unique_lock ulock(m_data_lock); - std::shared_ptr<::gfx::blur::box_data> data = m_data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::gfx::blur::box_data> data = _data.lock(); if (!data) { data = std::make_shared<::gfx::blur::box_data>(); - m_data = data; + _data = data; } return data; } @@ -194,18 +194,18 @@ std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data() return instance; } -gfx::blur::box::box() : m_data(::gfx::blur::box_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) +gfx::blur::box::box() : _data(::gfx::blur::box_factory::get().data()), _size(1.), _step_scale({1., 1.}) { auto gctx = gs::context(); - m_rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); - m_rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); + _rendertarget = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); + _rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE); } gfx::blur::box::~box() {} void gfx::blur::box::set_input(std::shared_ptr<::gs::texture> texture) { - m_input_texture = texture; + _input_texture = texture; } ::gfx::blur::type gfx::blur::box::get_type() @@ -215,46 +215,46 @@ void gfx::blur::box::set_input(std::shared_ptr<::gs::texture> texture) double_t gfx::blur::box::get_size() { - return m_size; + return _size; } void gfx::blur::box::set_size(double_t width) { - m_size = width; - if (m_size < 1.0) { - m_size = 1.0; + _size = width; + if (_size < 1.0) { + _size = 1.0; } - if (m_size > MAX_BLUR_SIZE) { - m_size = MAX_BLUR_SIZE; + if (_size > MAX_BLUR_SIZE) { + _size = MAX_BLUR_SIZE; } } void gfx::blur::box::set_step_scale(double_t x, double_t y) { - m_step_scale = {x, y}; + _step_scale = {x, y}; } void gfx::blur::box::get_step_scale(double_t& x, double_t& y) { - x = m_step_scale.first; - y = m_step_scale.second; + x = _step_scale.first; + y = _step_scale.second; } double_t gfx::blur::box::get_step_scale_x() { - return m_step_scale.first; + return _step_scale.first; } double_t gfx::blur::box::get_step_scale_y() { - return m_step_scale.second; + return _step_scale.second; } std::shared_ptr<::gs::texture> gfx::blur::box::render() { auto gctx = gs::context(); - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); gs_set_cull_mode(GS_NEITHER); gs_enable_color(true, true, true, true); @@ -270,17 +270,17 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); // Two Pass Blur - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); if (effect) { // Pass 1 - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); + 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("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f))); { - auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -288,11 +288,11 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render() } // Pass 2 - effect->get_parameter("pImage").set_texture(m_rendertarget2->get_texture()); + effect->get_parameter("pImage").set_texture(_rendertarget2->get_texture()); effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -302,15 +302,15 @@ std::shared_ptr<::gs::texture> gfx::blur::box::render() gs_blend_state_pop(); - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } std::shared_ptr<::gs::texture> gfx::blur::box::get() { - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } -gfx::blur::box_directional::box_directional() : m_angle(0) {} +gfx::blur::box_directional::box_directional() : _angle(0) {} ::gfx::blur::type gfx::blur::box_directional::get_type() { @@ -319,19 +319,19 @@ gfx::blur::box_directional::box_directional() : m_angle(0) {} double_t gfx::blur::box_directional::get_angle() { - return RAD_TO_DEG(m_angle); + return D_RAD_TO_DEG(_angle); } void gfx::blur::box_directional::set_angle(double_t angle) { - m_angle = DEG_TO_RAD(angle); + _angle = D_DEG_TO_RAD(angle); } std::shared_ptr<::gs::texture> gfx::blur::box_directional::render() { auto gctx = gs::context(); - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); gs_blend_state_push(); gs_reset_blend_state(); @@ -347,17 +347,17 @@ std::shared_ptr<::gs::texture> gfx::blur::box_directional::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); // One Pass Blur - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); if (effect) { - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel") - .set_float2(float_t(1. / width * cos(m_angle)), float_t(1.f / height * sin(m_angle))); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); + .set_float2(float_t(1. / 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("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f))); { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -367,7 +367,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_directional::render() gs_blend_state_pop(); - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } ::gfx::blur::type gfx::blur::box_rotational::get_type() @@ -377,31 +377,31 @@ std::shared_ptr<::gs::texture> gfx::blur::box_directional::render() void gfx::blur::box_rotational::set_center(double_t x, double_t y) { - m_center.first = x; - m_center.second = y; + _center.first = x; + _center.second = y; } void gfx::blur::box_rotational::get_center(double_t& x, double_t& y) { - x = m_center.first; - y = m_center.second; + x = _center.first; + y = _center.second; } double_t gfx::blur::box_rotational::get_angle() { - return RAD_TO_DEG(m_angle); + return D_RAD_TO_DEG(_angle); } void gfx::blur::box_rotational::set_angle(double_t angle) { - m_angle = DEG_TO_RAD(angle); + _angle = D_DEG_TO_RAD(angle); } std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render() { auto gctx = gs::context(); - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); gs_blend_state_push(); gs_reset_blend_state(); @@ -417,18 +417,18 @@ std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); // One Pass Blur - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); if (effect) { - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); - effect->get_parameter("pAngle").set_float(float_t(m_angle / m_size)); - effect->get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second)); + 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("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f))); + effect->get_parameter("pAngle").set_float(float_t(_angle / _size)); + effect->get_parameter("pCenter").set_float2(float_t(_center.first), float_t(_center.second)); { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Rotate")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -438,7 +438,7 @@ std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render() gs_blend_state_pop(); - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } ::gfx::blur::type gfx::blur::box_zoom::get_type() @@ -448,21 +448,21 @@ std::shared_ptr<::gs::texture> gfx::blur::box_rotational::render() void gfx::blur::box_zoom::set_center(double_t x, double_t y) { - m_center.first = x; - m_center.second = y; + _center.first = x; + _center.second = y; } void gfx::blur::box_zoom::get_center(double_t& x, double_t& y) { - x = m_center.first; - y = m_center.second; + x = _center.first; + y = _center.second; } std::shared_ptr<::gs::texture> gfx::blur::box_zoom::render() { auto gctx = gs::context(); - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); gs_blend_state_push(); gs_reset_blend_state(); @@ -478,17 +478,17 @@ std::shared_ptr<::gs::texture> gfx::blur::box_zoom::render() gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); // One Pass Blur - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); if (effect) { - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pSizeInverseMul").set_float(float_t(1.0f / (float_t(m_size) * 2.0f + 1.0f))); - effect->get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second)); + 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("pSizeInverseMul").set_float(float_t(1.0f / (float_t(_size) * 2.0f + 1.0f))); + effect->get_parameter("pCenter").set_float2(float_t(_center.first), float_t(_center.second)); { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Zoom")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -498,5 +498,5 @@ std::shared_ptr<::gs::texture> gfx::blur::box_zoom::render() gs_blend_state_pop(); - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } diff --git a/source/gfx/blur/gfx-blur-box.hpp b/source/gfx/blur/gfx-blur-box.hpp index a8994ec0..3e2577af 100644 --- a/source/gfx/blur/gfx-blur-box.hpp +++ b/source/gfx/blur/gfx-blur-box.hpp @@ -27,7 +27,7 @@ namespace gfx { namespace blur { class box_data { - std::shared_ptr<::gs::effect> m_effect; + std::shared_ptr<::gs::effect> _effect; public: box_data(); @@ -37,8 +37,8 @@ namespace gfx { }; class box_factory : public ::gfx::blur::ifactory { - std::mutex m_data_lock; - std::weak_ptr<::gfx::blur::box_data> m_data; + std::mutex _data_lock; + std::weak_ptr<::gfx::blur::box_data> _data; public: box_factory(); @@ -46,7 +46,7 @@ namespace gfx { virtual bool is_type_supported(::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::ibase> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; virtual double_t get_min_size(::gfx::blur::type type) override; @@ -80,17 +80,17 @@ namespace gfx { static ::gfx::blur::box_factory& get(); }; - class box : public ::gfx::blur::ibase { + class box : public ::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::box_data> m_data; + std::shared_ptr<::gfx::blur::box_data> _data; - double_t m_size; - std::pair m_step_scale; - std::shared_ptr<::gs::texture> m_input_texture; - std::shared_ptr<::gs::rendertarget> m_rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::gs::texture> _input_texture; + std::shared_ptr<::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> m_rendertarget2; + std::shared_ptr<::gs::rendertarget> _rendertarget2; public: box(); @@ -112,8 +112,8 @@ namespace gfx { virtual std::shared_ptr<::gs::texture> get() override; }; - class box_directional : public ::gfx::blur::box, public ::gfx::blur::ibase_angle { - double_t m_angle; + class box_directional : public ::gfx::blur::box, public ::gfx::blur::base_angle { + double_t _angle; public: box_directional(); @@ -127,10 +127,10 @@ namespace gfx { }; class box_rotational : public ::gfx::blur::box, - public ::gfx::blur::ibase_angle, - public ::gfx::blur::ibase_center { - std::pair m_center; - double_t m_angle; + public ::gfx::blur::base_angle, + public ::gfx::blur::base_center { + std::pair _center; + double_t _angle; public: virtual ::gfx::blur::type get_type() override; @@ -144,8 +144,8 @@ namespace gfx { virtual std::shared_ptr<::gs::texture> render() override; }; - class box_zoom : public ::gfx::blur::box, public ::gfx::blur::ibase_center { - std::pair m_center; + class box_zoom : public ::gfx::blur::box, public ::gfx::blur::base_center { + std::pair _center; public: virtual ::gfx::blur::type get_type() override; diff --git a/source/gfx/blur/gfx-blur-dual-filtering.cpp b/source/gfx/blur/gfx-blur-dual-filtering.cpp index 30782f1d..6b150e52 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.cpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.cpp @@ -54,23 +54,23 @@ gfx::blur::dual_filtering_data::dual_filtering_data() { auto gctx = gs::context(); try { - char* file = obs_module_file("effects/blur/dual-filtering.effect"); - m_effect = std::make_shared<::gs::effect>(file); + char* file = obs_module_file("effects/blur/dual-filtering._effect"); + _effect = std::make_shared<::gs::effect>(file); bfree(file); } catch (...) { - P_LOG_ERROR(" Failed to load effect."); + P_LOG_ERROR(" Failed to load _effect."); } } gfx::blur::dual_filtering_data::~dual_filtering_data() { auto gctx = gs::context(); - m_effect.reset(); + _effect.reset(); } std::shared_ptr<::gs::effect> gfx::blur::dual_filtering_data::get_effect() { - return m_effect; + return _effect; } gfx::blur::dual_filtering_factory::dual_filtering_factory() {} @@ -87,7 +87,7 @@ bool gfx::blur::dual_filtering_factory::is_type_supported(::gfx::blur::type type } } -std::shared_ptr<::gfx::blur::ibase> gfx::blur::dual_filtering_factory::create(::gfx::blur::type type) +std::shared_ptr<::gfx::blur::base> gfx::blur::dual_filtering_factory::create(::gfx::blur::type type) { switch (type) { case ::gfx::blur::type::Area: @@ -164,11 +164,11 @@ double_t gfx::blur::dual_filtering_factory::get_max_step_scale_y(::gfx::blur::ty std::shared_ptr<::gfx::blur::dual_filtering_data> gfx::blur::dual_filtering_factory::data() { - std::unique_lock ulock(m_data_lock); - std::shared_ptr<::gfx::blur::dual_filtering_data> data = m_data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::gfx::blur::dual_filtering_data> data = _data.lock(); if (!data) { data = std::make_shared<::gfx::blur::dual_filtering_data>(); - m_data = data; + _data = data; } return data; } @@ -180,12 +180,12 @@ std::shared_ptr<::gfx::blur::dual_filtering_data> gfx::blur::dual_filtering_fact } gfx::blur::dual_filtering::dual_filtering() - : m_data(::gfx::blur::dual_filtering_factory::get().data()), m_size(0), m_size_iterations(0) + : _data(::gfx::blur::dual_filtering_factory::get().data()), _size(0), _size_iterations(0) { auto gctx = gs::context(); - m_rendertargets.resize(MAX_LEVELS + 1); + _rendertargets.resize(MAX_LEVELS + 1); for (size_t n = 0; n <= MAX_LEVELS; n++) { - m_rendertargets[n] = std::make_shared(GS_RGBA32F, GS_ZS_NONE); + _rendertargets[n] = std::make_shared(GS_RGBA32F, GS_ZS_NONE); } } @@ -193,7 +193,7 @@ gfx::blur::dual_filtering::~dual_filtering() {} void gfx::blur::dual_filtering::set_input(std::shared_ptr<::gs::texture> texture) { - m_input_texture = texture; + _input_texture = texture; } ::gfx::blur::type gfx::blur::dual_filtering::get_type() @@ -203,15 +203,15 @@ void gfx::blur::dual_filtering::set_input(std::shared_ptr<::gs::texture> texture double_t gfx::blur::dual_filtering::get_size() { - return m_size; + return _size; } void gfx::blur::dual_filtering::set_size(double_t width) { - m_size = width; - m_size_iterations = size_t(round(width)); - if (m_size_iterations >= MAX_LEVELS) { - m_size_iterations = MAX_LEVELS; + _size = width; + _size_iterations = size_t(round(width)); + if (_size_iterations >= MAX_LEVELS) { + _size_iterations = MAX_LEVELS; } } @@ -222,12 +222,12 @@ void gfx::blur::dual_filtering::get_step_scale(double_t&, double_t&) {} std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() { auto gctx = gs::context(); - auto effect = m_data->get_effect(); + auto effect = _data->get_effect(); if (!effect) { - return m_input_texture; + return _input_texture; } - size_t actual_iterations = m_size_iterations; + size_t actual_iterations = _size_iterations; gs_blend_state_push(); gs_reset_blend_state(); @@ -249,9 +249,9 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() // Select Texture std::shared_ptr tex_cur; if (n > 1) { - tex_cur = m_rendertargets[n - 1]->get_texture(); + tex_cur = _rendertargets[n - 1]->get_texture(); } else { - tex_cur = m_input_texture; + tex_cur = _input_texture; } // Reduce Size @@ -269,7 +269,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() effect->get_parameter("pImageHalfTexel").set_float2(0.5f / width, 0.5f / height); { - auto op = m_rendertargets[n]->render(width, height); + auto op = _rendertargets[n]->render(width, height); gs_ortho(0., 1., 0., 1., 0., 1.); while (gs_effect_loop(effect->get_object(), "Down")) { gs_draw_sprite(tex_cur->get_object(), 0, 1, 1); @@ -280,7 +280,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() // Upsample for (size_t n = actual_iterations; n > 0; n--) { // Select Texture - std::shared_ptr tex_cur = m_rendertargets[n]->get_texture(); + std::shared_ptr tex_cur = _rendertargets[n]->get_texture(); // Get Size uint32_t width = tex_cur->get_width(); @@ -297,7 +297,7 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() height *= 2; { - auto op = m_rendertargets[n - 1]->render(width, height); + auto op = _rendertargets[n - 1]->render(width, height); gs_ortho(0., 1., 0., 1., 0., 1.); while (gs_effect_loop(effect->get_object(), "Up")) { gs_draw_sprite(tex_cur->get_object(), 0, 1, 1); @@ -307,10 +307,10 @@ std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::render() gs_blend_state_pop(); - return m_rendertargets[0]->get_texture(); + return _rendertargets[0]->get_texture(); } std::shared_ptr<::gs::texture> gfx::blur::dual_filtering::get() { - return m_rendertargets[0]->get_texture(); + return _rendertargets[0]->get_texture(); } diff --git a/source/gfx/blur/gfx-blur-dual-filtering.hpp b/source/gfx/blur/gfx-blur-dual-filtering.hpp index 1f8dfd71..a00102b1 100644 --- a/source/gfx/blur/gfx-blur-dual-filtering.hpp +++ b/source/gfx/blur/gfx-blur-dual-filtering.hpp @@ -28,7 +28,7 @@ namespace gfx { namespace blur { class dual_filtering_data { - std::shared_ptr<::gs::effect> m_effect; + std::shared_ptr<::gs::effect> _effect; public: dual_filtering_data(); @@ -38,8 +38,8 @@ namespace gfx { }; class dual_filtering_factory : public ::gfx::blur::ifactory { - std::mutex m_data_lock; - std::weak_ptr<::gfx::blur::dual_filtering_data> m_data; + std::mutex _data_lock; + std::weak_ptr<::gfx::blur::dual_filtering_data> _data; public: dual_filtering_factory(); @@ -47,7 +47,7 @@ namespace gfx { virtual bool is_type_supported(::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::ibase> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; virtual double_t get_min_size(::gfx::blur::type type) override; @@ -81,15 +81,15 @@ namespace gfx { static ::gfx::blur::dual_filtering_factory& get(); }; - class dual_filtering : public ::gfx::blur::ibase { - std::shared_ptr<::gfx::blur::dual_filtering_data> m_data; + class dual_filtering : public ::gfx::blur::base { + std::shared_ptr<::gfx::blur::dual_filtering_data> _data; - double_t m_size; - size_t m_size_iterations; + double_t _size; + size_t _size_iterations; - std::shared_ptr m_input_texture; + std::shared_ptr _input_texture; - std::vector> m_rendertargets; + std::vector> _rendertargets; public: dual_filtering(); diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.cpp b/source/gfx/blur/gfx-blur-gaussian-linear.cpp index 26351ccc..8a352fdc 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.cpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.cpp @@ -45,8 +45,8 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data() auto gctx = gs::context(); { - char* file = obs_module_file("effects/blur/gaussian-linear.effect"); - m_effect = std::make_shared(file); + char* file = obs_module_file("effects/blur/gaussian-linear._effect"); + _effect = std::make_shared(file); bfree(file); } @@ -77,18 +77,18 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data() kernel_data.at(p) = float_t(kernel_math[p] * inverse_sum); } - m_kernels.push_back(std::move(kernel_data)); + _kernels.push_back(std::move(kernel_data)); } } gfx::blur::gaussian_linear_data::~gaussian_linear_data() { - m_effect.reset(); + _effect.reset(); } std::shared_ptr<::gs::effect> gfx::blur::gaussian_linear_data::get_effect() { - return m_effect; + return _effect; } std::vector const& gfx::blur::gaussian_linear_data::get_kernel(size_t width) @@ -98,7 +98,7 @@ std::vector const& gfx::blur::gaussian_linear_data::get_kernel(size_t w if (width > MAX_BLUR_SIZE) width = MAX_BLUR_SIZE; width -= 1; - return m_kernels[width]; + return _kernels[width]; } gfx::blur::gaussian_linear_factory::gaussian_linear_factory() {} @@ -117,7 +117,7 @@ bool gfx::blur::gaussian_linear_factory::is_type_supported(::gfx::blur::type v) } } -std::shared_ptr<::gfx::blur::ibase> gfx::blur::gaussian_linear_factory::create(::gfx::blur::type v) +std::shared_ptr<::gfx::blur::base> gfx::blur::gaussian_linear_factory::create(::gfx::blur::type v) { switch (v) { case ::gfx::blur::type::Area: @@ -216,11 +216,11 @@ double_t gfx::blur::gaussian_linear_factory::get_max_step_scale_y(::gfx::blur::t std::shared_ptr<::gfx::blur::gaussian_linear_data> gfx::blur::gaussian_linear_factory::data() { - std::unique_lock ulock(m_data_lock); - std::shared_ptr<::gfx::blur::gaussian_linear_data> data = m_data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::gfx::blur::gaussian_linear_data> data = _data.lock(); if (!data) { data = std::make_shared<::gfx::blur::gaussian_linear_data>(); - m_data = data; + _data = data; } return data; } @@ -232,19 +232,19 @@ std::shared_ptr<::gfx::blur::gaussian_linear_data> gfx::blur::gaussian_linear_fa } gfx::blur::gaussian_linear::gaussian_linear() - : m_data(::gfx::blur::gaussian_linear_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) + : _data(::gfx::blur::gaussian_linear_factory::get().data()), _size(1.), _step_scale({1., 1.}) { auto gctx = gs::context(); - m_rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); - m_rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); } gfx::blur::gaussian_linear::~gaussian_linear() {} void gfx::blur::gaussian_linear::set_input(std::shared_ptr<::gs::texture> texture) { - m_input_texture = texture; + _input_texture = texture; } ::gfx::blur::type gfx::blur::gaussian_linear::get_type() @@ -254,7 +254,7 @@ void gfx::blur::gaussian_linear::set_input(std::shared_ptr<::gs::texture> textur double_t gfx::blur::gaussian_linear::get_size() { - return m_size; + return _size; } void gfx::blur::gaussian_linear::set_size(double_t width) @@ -263,44 +263,44 @@ void gfx::blur::gaussian_linear::set_size(double_t width) width = 1.; if (width > MAX_BLUR_SIZE) width = MAX_BLUR_SIZE; - m_size = width; + _size = width; } void gfx::blur::gaussian_linear::set_step_scale(double_t x, double_t y) { - m_step_scale.first = x; - m_step_scale.second = y; + _step_scale.first = x; + _step_scale.second = y; } void gfx::blur::gaussian_linear::get_step_scale(double_t& x, double_t& y) { - x = m_step_scale.first; - y = m_step_scale.second; + x = _step_scale.first; + y = _step_scale.second; } double_t gfx::blur::gaussian_linear::get_step_scale_x() { - return m_step_scale.first; + return _step_scale.first; } double_t gfx::blur::gaussian_linear::get_step_scale_y() { - return m_step_scale.second; + return _step_scale.second; } std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() { auto gctx = gs::context(); - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); - auto kernel = m_data->get_kernel(size_t(m_size)); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { - return m_input_texture; + if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { + return _input_texture; } - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); // Setup gs_set_cull_mode(GS_NEITHER); @@ -316,40 +316,40 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS); gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); - effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); + 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_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass - if (m_step_scale.first > std::numeric_limits::epsilon()) { + if (_step_scale.first > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); { - auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); } } - std::swap(m_rendertarget, m_rendertarget2); - effect->get_parameter("pImage").set_texture(m_rendertarget->get_texture()); + std::swap(_rendertarget, _rendertarget2); + effect->get_parameter("pImage").set_texture(_rendertarget->get_texture()); } // Second Pass - if (m_step_scale.second > std::numeric_limits::epsilon()) { + if (_step_scale.second > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { - auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); } } - std::swap(m_rendertarget, m_rendertarget2); + std::swap(_rendertarget, _rendertarget2); } gs_blend_state_pop(); @@ -359,10 +359,10 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::get() { - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } -gfx::blur::gaussian_linear_directional::gaussian_linear_directional() : m_angle(0.) {} +gfx::blur::gaussian_linear_directional::gaussian_linear_directional() : _angle(0.) {} gfx::blur::gaussian_linear_directional::~gaussian_linear_directional() {} @@ -373,27 +373,27 @@ gfx::blur::gaussian_linear_directional::~gaussian_linear_directional() {} double_t gfx::blur::gaussian_linear_directional::get_angle() { - return RAD_TO_DEG(m_angle); + return D_RAD_TO_DEG(_angle); } void gfx::blur::gaussian_linear_directional::set_angle(double_t angle) { - m_angle = DEG_TO_RAD(angle); + _angle = D_DEG_TO_RAD(angle); } std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear_directional::render() { auto gctx = gs::context(); - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); - auto kernel = m_data->get_kernel(size_t(m_size)); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { - return m_input_texture; + if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { + return _input_texture; } - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); // Setup gs_set_cull_mode(GS_NEITHER); @@ -409,16 +409,16 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear_directional::render() gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS); gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel") - .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(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); + .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_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.hpp b/source/gfx/blur/gfx-blur-gaussian-linear.hpp index 74726cda..0ddee301 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.hpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.hpp @@ -26,8 +26,8 @@ namespace gfx { namespace blur { class gaussian_linear_data { - std::shared_ptr<::gs::effect> m_effect; - std::vector> m_kernels; + std::shared_ptr<::gs::effect> _effect; + std::vector> _kernels; public: gaussian_linear_data(); @@ -39,8 +39,8 @@ namespace gfx { }; class gaussian_linear_factory : public ::gfx::blur::ifactory { - std::mutex m_data_lock; - std::weak_ptr<::gfx::blur::gaussian_linear_data> m_data; + std::mutex _data_lock; + std::weak_ptr<::gfx::blur::gaussian_linear_data> _data; public: gaussian_linear_factory(); @@ -48,7 +48,7 @@ namespace gfx { virtual bool is_type_supported(::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::ibase> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; virtual double_t get_min_size(::gfx::blur::type type) override; @@ -82,17 +82,17 @@ namespace gfx { static ::gfx::blur::gaussian_linear_factory& get(); }; - class gaussian_linear : public ::gfx::blur::ibase { + class gaussian_linear : public ::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::gaussian_linear_data> m_data; + std::shared_ptr<::gfx::blur::gaussian_linear_data> _data; - double_t m_size; - std::pair m_step_scale; - std::shared_ptr<::gs::texture> m_input_texture; - std::shared_ptr<::gs::rendertarget> m_rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::gs::texture> _input_texture; + std::shared_ptr<::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> m_rendertarget2; + std::shared_ptr<::gs::rendertarget> _rendertarget2; public: gaussian_linear(); @@ -119,8 +119,8 @@ namespace gfx { virtual std::shared_ptr<::gs::texture> get() override; }; - class gaussian_linear_directional : public ::gfx::blur::gaussian_linear, public ::gfx::blur::ibase_angle { - double_t m_angle; + class gaussian_linear_directional : public ::gfx::blur::gaussian_linear, public ::gfx::blur::base_angle { + double_t _angle; public: gaussian_linear_directional(); diff --git a/source/gfx/blur/gfx-blur-gaussian.cpp b/source/gfx/blur/gfx-blur-gaussian.cpp index e842a5a5..12c7167e 100644 --- a/source/gfx/blur/gfx-blur-gaussian.cpp +++ b/source/gfx/blur/gfx-blur-gaussian.cpp @@ -45,8 +45,8 @@ gfx::blur::gaussian_data::gaussian_data() { auto gctx = gs::context(); { - char* file = obs_module_file("effects/blur/gaussian.effect"); - m_effect = std::make_shared(file); + char* file = obs_module_file("effects/blur/gaussian._effect"); + _effect = std::make_shared(file); bfree(file); } @@ -77,19 +77,19 @@ gfx::blur::gaussian_data::gaussian_data() kernel_data.at(p) = float_t(kernel_math[p] * inverse_sum); } - m_kernels.push_back(std::move(kernel_data)); + _kernels.push_back(std::move(kernel_data)); } } gfx::blur::gaussian_data::~gaussian_data() { auto gctx = gs::context(); - m_effect.reset(); + _effect.reset(); } std::shared_ptr<::gs::effect> gfx::blur::gaussian_data::get_effect() { - return m_effect; + return _effect; } std::vector const& gfx::blur::gaussian_data::get_kernel(size_t width) @@ -99,7 +99,7 @@ std::vector const& gfx::blur::gaussian_data::get_kernel(size_t width) if (width > MAX_BLUR_SIZE) width = MAX_BLUR_SIZE; width -= 1; - return m_kernels[width]; + return _kernels[width]; } gfx::blur::gaussian_factory::gaussian_factory() {} @@ -122,7 +122,7 @@ bool gfx::blur::gaussian_factory::is_type_supported(::gfx::blur::type v) } } -std::shared_ptr<::gfx::blur::ibase> gfx::blur::gaussian_factory::create(::gfx::blur::type v) +std::shared_ptr<::gfx::blur::base> gfx::blur::gaussian_factory::create(::gfx::blur::type v) { switch (v) { case ::gfx::blur::type::Area: @@ -224,11 +224,11 @@ double_t gfx::blur::gaussian_factory::get_max_step_scale_y(::gfx::blur::type) std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data() { - std::unique_lock ulock(m_data_lock); - std::shared_ptr<::gfx::blur::gaussian_data> data = m_data.lock(); + std::unique_lock ulock(_data_lock); + std::shared_ptr<::gfx::blur::gaussian_data> data = _data.lock(); if (!data) { data = std::make_shared<::gfx::blur::gaussian_data>(); - m_data = data; + _data = data; } return data; } @@ -240,18 +240,18 @@ std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data() } gfx::blur::gaussian::gaussian() - : m_data(::gfx::blur::gaussian_factory::get().data()), m_size(1.), m_step_scale({1., 1.}) + : _data(::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.}) { auto gctx = gs::context(); - m_rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); - m_rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rendertarget = std::make_shared(GS_RGBA, GS_ZS_NONE); + _rendertarget2 = std::make_shared(GS_RGBA, GS_ZS_NONE); } gfx::blur::gaussian::~gaussian() {} void gfx::blur::gaussian::set_input(std::shared_ptr<::gs::texture> texture) { - m_input_texture = texture; + _input_texture = texture; } ::gfx::blur::type gfx::blur::gaussian::get_type() @@ -261,7 +261,7 @@ void gfx::blur::gaussian::set_input(std::shared_ptr<::gs::texture> texture) double_t gfx::blur::gaussian::get_size() { - return m_size; + return _size; } void gfx::blur::gaussian::set_size(double_t width) @@ -270,44 +270,44 @@ void gfx::blur::gaussian::set_size(double_t width) width = 1.; if (width > MAX_BLUR_SIZE) width = MAX_BLUR_SIZE; - m_size = width; + _size = width; } void gfx::blur::gaussian::set_step_scale(double_t x, double_t y) { - m_step_scale.first = x; - m_step_scale.second = y; + _step_scale.first = x; + _step_scale.second = y; } void gfx::blur::gaussian::get_step_scale(double_t& x, double_t& y) { - x = m_step_scale.first; - y = m_step_scale.second; + x = _step_scale.first; + y = _step_scale.second; } double_t gfx::blur::gaussian::get_step_scale_x() { - return m_step_scale.first; + return _step_scale.first; } double_t gfx::blur::gaussian::get_step_scale_y() { - return m_step_scale.second; + return _step_scale.second; } std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() { auto gctx = gs::context(); - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); - auto kernel = m_data->get_kernel(size_t(m_size)); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { - return m_input_texture; + if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { + return _input_texture; } - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); // Setup gs_set_cull_mode(GS_NEITHER); @@ -323,40 +323,40 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS); gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); - effect->get_parameter("pImage").set_texture(m_input_texture); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); + 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_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass - if (m_step_scale.first > std::numeric_limits::epsilon()) { + if (_step_scale.first > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); { - auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); } } - std::swap(m_rendertarget, m_rendertarget2); - effect->get_parameter("pImage").set_texture(m_rendertarget->get_texture()); + std::swap(_rendertarget, _rendertarget2); + effect->get_parameter("pImage").set_texture(_rendertarget->get_texture()); } // Second Pass - if (m_step_scale.second > std::numeric_limits::epsilon()) { + if (_step_scale.second > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { - auto op = m_rendertarget2->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget2->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); } } - std::swap(m_rendertarget, m_rendertarget2); + std::swap(_rendertarget, _rendertarget2); } gs_blend_state_pop(); @@ -366,7 +366,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() std::shared_ptr<::gs::texture> gfx::blur::gaussian::get() { - return m_rendertarget->get_texture(); + return _rendertarget->get_texture(); } gfx::blur::gaussian_directional::gaussian_directional() : m_angle(0.) {} @@ -380,27 +380,27 @@ gfx::blur::gaussian_directional::~gaussian_directional() {} double_t gfx::blur::gaussian_directional::get_angle() { - return RAD_TO_DEG(m_angle); + return D_RAD_TO_DEG(m_angle); } void gfx::blur::gaussian_directional::set_angle(double_t angle) { - m_angle = DEG_TO_RAD(angle); + m_angle = D_DEG_TO_RAD(angle); } std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render() { auto gctx = gs::context(); - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); - auto kernel = m_data->get_kernel(size_t(m_size)); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { - return m_input_texture; + if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { + return _input_texture; } - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); // Setup obs_enter_graphics(); @@ -417,16 +417,16 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render() gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS); gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel") .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(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); + 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_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Draw")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -447,15 +447,15 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_rotational::render() { auto gctx = gs::context(); - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); - auto kernel = m_data->get_kernel(size_t(m_size)); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { - return m_input_texture; + if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { + return _input_texture; } - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); // Setup gs_set_cull_mode(GS_NEITHER); @@ -471,17 +471,17 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_rotational::render() gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS); gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); - effect->get_parameter("pAngle").set_float(float_t(m_angle / m_size)); + 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("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_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Rotate")) { gs_draw_sprite(nullptr, 0, 1, 1); @@ -507,12 +507,12 @@ void gfx::blur::gaussian_rotational::get_center(double_t& x, double_t& y) double_t gfx::blur::gaussian_rotational::get_angle() { - return double_t(RAD_TO_DEG(m_angle)); + return double_t(D_RAD_TO_DEG(m_angle)); } void gfx::blur::gaussian_rotational::set_angle(double_t angle) { - m_angle = DEG_TO_RAD(angle); + m_angle = D_DEG_TO_RAD(angle); } ::gfx::blur::type gfx::blur::gaussian_zoom::get_type() @@ -524,15 +524,15 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_zoom::render() { auto gctx = gs::context(); - std::shared_ptr<::gs::effect> effect = m_data->get_effect(); - auto kernel = m_data->get_kernel(size_t(m_size)); + std::shared_ptr<::gs::effect> effect = _data->get_effect(); + auto kernel = _data->get_kernel(size_t(_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { - return m_input_texture; + if (!effect || ((_step_scale.first + _step_scale.second) < std::numeric_limits::epsilon())) { + return _input_texture; } - float_t width = float_t(m_input_texture->get_width()); - float_t height = float_t(m_input_texture->get_height()); + float_t width = float_t(_input_texture->get_width()); + float_t height = float_t(_input_texture->get_height()); // Setup gs_set_cull_mode(GS_NEITHER); @@ -548,16 +548,16 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_zoom::render() gs_stencil_function(GS_STENCIL_BOTH, GS_ALWAYS); gs_stencil_op(GS_STENCIL_BOTH, GS_ZERO, GS_ZERO, GS_ZERO); - effect->get_parameter("pImage").set_texture(m_input_texture); + effect->get_parameter("pImage").set_texture(_input_texture); effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), float_t(1.f / height)); - effect->get_parameter("pStepScale").set_float2(float_t(m_step_scale.first), float_t(m_step_scale.second)); - effect->get_parameter("pSize").set_float(float_t(m_size)); + 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_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass { - auto op = m_rendertarget->render(uint32_t(width), uint32_t(height)); + auto op = _rendertarget->render(uint32_t(width), uint32_t(height)); gs_ortho(0, 1., 0, 1., 0, 1.); while (gs_effect_loop(effect->get_object(), "Zoom")) { gs_draw_sprite(nullptr, 0, 1, 1); diff --git a/source/gfx/blur/gfx-blur-gaussian.hpp b/source/gfx/blur/gfx-blur-gaussian.hpp index ccbb94a3..92213246 100644 --- a/source/gfx/blur/gfx-blur-gaussian.hpp +++ b/source/gfx/blur/gfx-blur-gaussian.hpp @@ -26,8 +26,8 @@ namespace gfx { namespace blur { class gaussian_data { - std::shared_ptr<::gs::effect> m_effect; - std::vector> m_kernels; + std::shared_ptr<::gs::effect> _effect; + std::vector> _kernels; public: gaussian_data(); @@ -39,8 +39,8 @@ namespace gfx { }; class gaussian_factory : public ::gfx::blur::ifactory { - std::mutex m_data_lock; - std::weak_ptr<::gfx::blur::gaussian_data> m_data; + std::mutex _data_lock; + std::weak_ptr<::gfx::blur::gaussian_data> _data; public: gaussian_factory(); @@ -48,7 +48,7 @@ namespace gfx { virtual bool is_type_supported(::gfx::blur::type type) override; - virtual std::shared_ptr<::gfx::blur::ibase> create(::gfx::blur::type type) override; + virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override; virtual double_t get_min_size(::gfx::blur::type type) override; @@ -82,17 +82,17 @@ namespace gfx { static ::gfx::blur::gaussian_factory& get(); }; - class gaussian : public ::gfx::blur::ibase { + class gaussian : public ::gfx::blur::base { protected: - std::shared_ptr<::gfx::blur::gaussian_data> m_data; + std::shared_ptr<::gfx::blur::gaussian_data> _data; - double_t m_size; - std::pair m_step_scale; - std::shared_ptr<::gs::texture> m_input_texture; - std::shared_ptr<::gs::rendertarget> m_rendertarget; + double_t _size; + std::pair _step_scale; + std::shared_ptr<::gs::texture> _input_texture; + std::shared_ptr<::gs::rendertarget> _rendertarget; private: - std::shared_ptr<::gs::rendertarget> m_rendertarget2; + std::shared_ptr<::gs::rendertarget> _rendertarget2; public: gaussian(); @@ -119,7 +119,7 @@ namespace gfx { virtual std::shared_ptr<::gs::texture> get() override; }; - class gaussian_directional : public ::gfx::blur::gaussian, public ::gfx::blur::ibase_angle { + class gaussian_directional : public ::gfx::blur::gaussian, public ::gfx::blur::base_angle { double_t m_angle; public: @@ -135,8 +135,8 @@ namespace gfx { }; class gaussian_rotational : public ::gfx::blur::gaussian, - public ::gfx::blur::ibase_angle, - public ::gfx::blur::ibase_center { + public ::gfx::blur::base_angle, + public ::gfx::blur::base_center { std::pair m_center; double_t m_angle; @@ -152,7 +152,7 @@ namespace gfx { virtual std::shared_ptr<::gs::texture> render() override; }; - class gaussian_zoom : public ::gfx::blur::gaussian, public ::gfx::blur::ibase_center { + class gaussian_zoom : public ::gfx::blur::gaussian, public ::gfx::blur::base_center { std::pair m_center; public: diff --git a/source/gfx/gfx-effect-source.cpp b/source/gfx/gfx-effect-source.cpp index b53dbbdf..6104a35d 100644 --- a/source/gfx/gfx-effect-source.cpp +++ b/source/gfx/gfx-effect-source.cpp @@ -133,22 +133,22 @@ void gfx::effect_source::get_properties(obs_properties_t* properties) { obs_property_t* p = nullptr; - p = obs_properties_add_list(properties, D_TYPE, P_TRANSLATE(T_TYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(T_TYPE))); - obs_property_list_add_int(p, P_TRANSLATE(T_TYPE_TEXT), (long long)InputTypes::Text); - obs_property_list_add_int(p, P_TRANSLATE(T_TYPE_FILE), (long long)InputTypes::File); + p = obs_properties_add_list(properties, D_TYPE, D_TRANSLATE(T_TYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(T_TYPE))); + obs_property_list_add_int(p, D_TRANSLATE(T_TYPE_TEXT), (long long)InputTypes::Text); + obs_property_list_add_int(p, D_TRANSLATE(T_TYPE_FILE), (long long)InputTypes::File); obs_property_set_modified_callback2(p, property_type_modified, this); - p = obs_properties_add_text(properties, D_INPUT_TEXT, P_TRANSLATE(T_INPUT_TEXT), OBS_TEXT_MULTILINE); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(T_INPUT_TEXT))); + p = obs_properties_add_text(properties, D_INPUT_TEXT, D_TRANSLATE(T_INPUT_TEXT), OBS_TEXT_MULTILINE); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(T_INPUT_TEXT))); obs_property_set_modified_callback2(p, property_input_modified, this); { char* tmp_path = obs_module_file(m_defaultShaderPath.c_str()); p = obs_properties_add_path( - properties, D_INPUT_FILE, P_TRANSLATE(T_INPUT_FILE), OBS_PATH_FILE, - "Any (*.effect *.shader *.hlsl);;Effect (*.effect);;Shader (*.shader);;DirectX (*.hlsl)", tmp_path); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(T_INPUT_FILE))); + properties, D_INPUT_FILE, D_TRANSLATE(T_INPUT_FILE), OBS_PATH_FILE, + "Any (*._effect *.shader *.hlsl);;Effect (*._effect);;Shader (*.shader);;DirectX (*.hlsl)", tmp_path); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(T_INPUT_FILE))); obs_property_set_modified_callback2(p, property_input_modified, this); bfree(tmp_path); } @@ -178,10 +178,10 @@ void gfx::effect_source::get_properties(obs_properties_t* properties) // Switch between File and Source Input p = obs_properties_add_list(properties, prm.second->ui.names[0], prm.second->ui.descs[0], obs_combo_type::OBS_COMBO_TYPE_LIST, obs_combo_format::OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(T_TEXTURE_TYPE))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(T_TEXTURE_TYPE))); obs_property_set_modified_callback2(p, property_texture_type_modified, prm.second.get()); - obs_property_list_add_int(p, P_TRANSLATE(T_TEXTURE_TYPE_FILE), 0); - obs_property_list_add_int(p, P_TRANSLATE(T_TEXTURE_TYPE_SOURCE), 1); + obs_property_list_add_int(p, D_TRANSLATE(T_TEXTURE_TYPE_FILE), 0); + obs_property_list_add_int(p, D_TRANSLATE(T_TEXTURE_TYPE_SOURCE), 1); // Texture Path char* defaultPath = obs_module_file(""); diff --git a/source/gfx/gfx-source-texture.cpp b/source/gfx/gfx-source-texture.cpp index 88b69fc0..2cf776b8 100644 --- a/source/gfx/gfx-source-texture.cpp +++ b/source/gfx/gfx-source-texture.cpp @@ -19,21 +19,21 @@ gfx::source_texture::~source_texture() { - if (child && parent) { - obs_source_remove_active_child(parent->get(), child->get()); + if (_child && _parent) { + obs_source_remove_active_child(_parent->get(), _child->get()); } - parent.reset(); - child.reset(); + _parent.reset(); + _child.reset(); } gfx::source_texture::source_texture(obs_source_t* _parent) { if (!_parent) { - throw std::invalid_argument("parent must not be null"); + throw std::invalid_argument("_parent must not be null"); } - parent = std::make_shared(_parent, false, false); - render_target = std::make_shared(GS_RGBA, GS_ZS_NONE); + _parent = std::make_shared(_parent, false, false); + _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) @@ -42,9 +42,9 @@ gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent throw std::invalid_argument("source must not be null"); } if (!obs_source_add_active_child(_parent, _source)) { - throw std::runtime_error("parent is contained in child"); + throw std::runtime_error("_parent is contained in _child"); } - child = std::make_shared(_source, true, true); + _child = std::make_shared(_source, true, true); } gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : source_texture(_parent) @@ -52,9 +52,9 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : if (!_name) { throw std::invalid_argument("name must not be null"); } - child = std::make_shared(_name, true, true); - if (!obs_source_add_active_child(_parent, child->get())) { - throw std::runtime_error("parent is contained in child"); + _child = std::make_shared(_name, true, true); + if (!obs_source_add_active_child(_parent, _child->get())) { + throw std::runtime_error("_parent is contained in _child"); } } @@ -64,17 +64,17 @@ gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent) : gfx::source_texture::source_texture(std::shared_ptr pchild, std::shared_ptr pparent) { if (!pchild) { - throw std::invalid_argument("child must not be null"); + throw std::invalid_argument("_child must not be null"); } if (!pparent) { - throw std::invalid_argument("parent must not be null"); + throw std::invalid_argument("_parent must not be null"); } if (!obs_source_add_active_child(pparent->get(), pchild->get())) { - throw std::runtime_error("parent is contained in child"); + throw std::runtime_error("_parent is contained in _child"); } - this->child = pchild; - this->parent = pparent; - this->render_target = std::make_shared(GS_RGBA, GS_ZS_NONE); + this->_child = pchild; + this->_parent = pparent; + this->_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } gfx::source_texture::source_texture(std::shared_ptr _child, obs_source_t* _parent) @@ -83,24 +83,24 @@ gfx::source_texture::source_texture(std::shared_ptr _child, obs_sou obs_source_t* gfx::source_texture::get_object() { - if (child) { - return child->get(); + if (_child) { + return _child->get(); } return nullptr; } obs_source_t* gfx::source_texture::get_parent() { - return parent->get(); + return _parent->get(); } void gfx::source_texture::clear() { - if (child && parent) { - obs_source_remove_active_child(parent->get(), child->get()); + if (_child && _parent) { + obs_source_remove_active_child(_parent->get(), _child->get()); } - child->clear(); - child.reset(); + _child->clear(); + _child.reset(); } std::shared_ptr gfx::source_texture::render(size_t width, size_t height) @@ -111,22 +111,22 @@ std::shared_ptr gfx::source_texture::render(size_t width, size_t he if ((height == 0) || (height >= 16384)) { throw std::runtime_error("Height too large or too small."); } - if (child->destroyed() || parent->destroyed()) { + if (_child->destroyed() || _parent->destroyed()) { return nullptr; } { - auto op = render_target->render((uint32_t)width, (uint32_t)height); + auto op = _rt->render((uint32_t)width, (uint32_t)height); vec4 black; vec4_zero(&black); gs_ortho(0, (float_t)width, 0, (float_t)height, 0, 1); gs_clear(GS_CLEAR_COLOR, &black, 0, 0); - if (child) { - obs_source_video_render(child->get()); + if (_child) { + obs_source_video_render(_child->get()); } } std::shared_ptr tex; - render_target->get_texture(tex); + _rt->get_texture(tex); return tex; } diff --git a/source/gfx/gfx-source-texture.hpp b/source/gfx/gfx-source-texture.hpp index 912d7b50..2589b169 100644 --- a/source/gfx/gfx-source-texture.hpp +++ b/source/gfx/gfx-source-texture.hpp @@ -34,10 +34,10 @@ namespace gfx { class source_texture { - std::shared_ptr parent; - std::shared_ptr child; + std::shared_ptr _parent; + std::shared_ptr _child; - std::shared_ptr render_target; + std::shared_ptr _rt; source_texture(obs_source_t* parent); diff --git a/source/obs/gs/gs-effect.cpp b/source/obs/gs/gs-effect.cpp index d7cdf519..d2d32f39 100644 --- a/source/obs/gs/gs-effect.cpp +++ b/source/obs/gs/gs-effect.cpp @@ -36,7 +36,7 @@ //#define OBS_LOAD_EFFECT_FILE -gs::effect::effect() : m_effect(nullptr) {} +gs::effect::effect() : _effect(nullptr) {} gs::effect::effect(std::string file) : effect() { @@ -72,8 +72,8 @@ gs::effect::effect(std::string file) : effect() char* errorMessage = nullptr; auto gctx = gs::context(); - m_effect = gs_effect_create(shader_buf.data(), file.c_str(), &errorMessage); - if (!m_effect || errorMessage) { + _effect = gs_effect_create(shader_buf.data(), file.c_str(), &errorMessage); + if (!_effect || errorMessage) { std::string error = "Generic Error"; if (errorMessage) { error = std::string(errorMessage); @@ -88,8 +88,8 @@ gs::effect::effect(std::string code, std::string name) : effect() { char* errorMessage = nullptr; auto gctx = gs::context(); - m_effect = gs_effect_create(code.c_str(), name.c_str(), &errorMessage); - if (!m_effect || errorMessage) { + _effect = gs_effect_create(code.c_str(), name.c_str(), &errorMessage); + if (!_effect || errorMessage) { std::string error = "Generic Error"; if (errorMessage) { error = std::string(errorMessage); @@ -102,22 +102,22 @@ gs::effect::effect(std::string code, std::string name) : effect() gs::effect::~effect() { auto gctx = gs::context(); - gs_effect_destroy(m_effect); + gs_effect_destroy(_effect); } gs_effect_t* gs::effect::get_object() { - return m_effect; + return _effect; } size_t gs::effect::count_parameters() { - return (size_t)gs_effect_get_num_params(m_effect); + return (size_t)gs_effect_get_num_params(_effect); } std::list gs::effect::get_parameters() { - size_t num = gs_effect_get_num_params(m_effect); + size_t num = gs_effect_get_num_params(_effect); std::list ps; for (size_t idx = 0; idx < num; idx++) { ps.emplace_back(get_parameter(idx)); @@ -127,7 +127,7 @@ std::list gs::effect::get_parameters() gs::effect_parameter gs::effect::get_parameter(size_t idx) { - gs_eparam_t* param = gs_effect_get_param_by_idx(m_effect, idx); + gs_eparam_t* param = gs_effect_get_param_by_idx(_effect, idx); if (!param) throw std::invalid_argument("parameter with index not found"); return effect_parameter(param); @@ -135,13 +135,13 @@ gs::effect_parameter gs::effect::get_parameter(size_t idx) bool gs::effect::has_parameter(std::string name) { - gs_eparam_t* param = gs_effect_get_param_by_name(m_effect, name.c_str()); + gs_eparam_t* param = gs_effect_get_param_by_name(_effect, name.c_str()); return (param != nullptr); } bool gs::effect::has_parameter(std::string name, effect_parameter::type type) { - gs_eparam_t* param = gs_effect_get_param_by_name(m_effect, name.c_str()); + gs_eparam_t* param = gs_effect_get_param_by_name(_effect, name.c_str()); if (param == nullptr) return false; gs::effect_parameter eprm(param); @@ -150,28 +150,28 @@ bool gs::effect::has_parameter(std::string name, effect_parameter::type type) gs::effect_parameter gs::effect::get_parameter(std::string name) { - gs_eparam_t* param = gs_effect_get_param_by_name(m_effect, name.c_str()); + gs_eparam_t* param = gs_effect_get_param_by_name(_effect, name.c_str()); if (!param) throw std::invalid_argument("parameter with name not found"); return effect_parameter(param); } -gs::effect_parameter::effect_parameter(gs_eparam_t* param) : m_param(param) +gs::effect_parameter::effect_parameter(gs_eparam_t* param) : _param(param) { if (!param) throw std::invalid_argument("param is null"); - gs_effect_get_param_info(m_param, &m_paramInfo); + gs_effect_get_param_info(_param, &_param_info); } std::string gs::effect_parameter::get_name() { - return m_paramInfo.name; + return _param_info.name; } gs::effect_parameter::type gs::effect_parameter::get_type() { - switch (m_paramInfo.type) { + switch (_param_info.type) { case GS_SHADER_PARAM_BOOL: return type::Boolean; case GS_SHADER_PARAM_FLOAT: @@ -206,28 +206,28 @@ void gs::effect_parameter::set_bool(bool v) { if (get_type() != type::Boolean) throw std::bad_cast(); - gs_effect_set_bool(m_param, v); + gs_effect_set_bool(_param, v); } void gs::effect_parameter::set_bool_array(bool v[], size_t sz) { if (get_type() != type::Boolean) throw std::bad_cast(); - gs_effect_set_val(m_param, v, sz); + gs_effect_set_val(_param, v, sz); } void gs::effect_parameter::set_float(float_t x) { if (get_type() != type::Float) throw std::bad_cast(); - gs_effect_set_float(m_param, x); + gs_effect_set_float(_param, x); } void gs::effect_parameter::set_float2(vec2& v) { if (get_type() != type::Float2) throw std::bad_cast(); - gs_effect_set_vec2(m_param, &v); + gs_effect_set_vec2(_param, &v); } void gs::effect_parameter::set_float2(float_t x, float_t y) @@ -235,14 +235,14 @@ void gs::effect_parameter::set_float2(float_t x, float_t y) if (get_type() != type::Float2) throw std::bad_cast(); vec2 v = {{x, y}}; - gs_effect_set_vec2(m_param, &v); + gs_effect_set_vec2(_param, &v); } void gs::effect_parameter::set_float3(vec3& v) { if (get_type() != type::Float3) throw std::bad_cast(); - gs_effect_set_vec3(m_param, &v); + gs_effect_set_vec3(_param, &v); } void gs::effect_parameter::set_float3(float_t x, float_t y, float_t z) @@ -250,14 +250,14 @@ void gs::effect_parameter::set_float3(float_t x, float_t y, float_t z) if (get_type() != type::Float3) throw std::bad_cast(); vec3 v = {{x, y, z, 0}}; - gs_effect_set_vec3(m_param, &v); + gs_effect_set_vec3(_param, &v); } void gs::effect_parameter::set_float4(vec4& v) { if (get_type() != type::Float4) throw std::bad_cast(); - gs_effect_set_vec4(m_param, &v); + gs_effect_set_vec4(_param, &v); } void gs::effect_parameter::set_float4(float_t x, float_t y, float_t z, float_t w) @@ -265,7 +265,7 @@ void gs::effect_parameter::set_float4(float_t x, float_t y, float_t z, float_t w if (get_type() != type::Float4) throw std::bad_cast(); vec4 v = {{x, y, z, w}}; - gs_effect_set_vec4(m_param, &v); + gs_effect_set_vec4(_param, &v); } void gs::effect_parameter::set_float_array(float_t v[], size_t sz) @@ -273,14 +273,14 @@ void gs::effect_parameter::set_float_array(float_t v[], size_t sz) if ((get_type() != type::Float) && (get_type() != type::Float2) && (get_type() != type::Float3) && (get_type() != type::Float4)) throw std::bad_cast(); - gs_effect_set_val(m_param, v, sizeof(float_t) * sz); + gs_effect_set_val(_param, v, sizeof(float_t) * sz); } void gs::effect_parameter::set_int(int32_t x) { if ((get_type() != type::Integer) && (get_type() != type::Unknown)) throw std::bad_cast(); - gs_effect_set_int(m_param, x); + gs_effect_set_int(_param, x); } void gs::effect_parameter::set_int2(int32_t x, int32_t y) @@ -288,7 +288,7 @@ void gs::effect_parameter::set_int2(int32_t x, int32_t y) if ((get_type() != type::Integer2) && (get_type() != type::Unknown)) throw std::bad_cast(); int32_t v[2] = {x, y}; - gs_effect_set_val(m_param, v, sizeof(int) * 2); + gs_effect_set_val(_param, v, sizeof(int) * 2); } void gs::effect_parameter::set_int3(int32_t x, int32_t y, int32_t z) @@ -296,7 +296,7 @@ void gs::effect_parameter::set_int3(int32_t x, int32_t y, int32_t z) if ((get_type() != type::Integer3) && (get_type() != type::Unknown)) throw std::bad_cast(); int32_t v[3] = {x, y, z}; - gs_effect_set_val(m_param, v, sizeof(int) * 3); + gs_effect_set_val(_param, v, sizeof(int) * 3); } void gs::effect_parameter::set_int4(int32_t x, int32_t y, int32_t z, int32_t w) @@ -304,7 +304,7 @@ void gs::effect_parameter::set_int4(int32_t x, int32_t y, int32_t z, int32_t w) if ((get_type() != type::Integer4) && (get_type() != type::Unknown)) throw std::bad_cast(); int32_t v[4] = {x, y, z, w}; - gs_effect_set_val(m_param, v, sizeof(int) * 4); + gs_effect_set_val(_param, v, sizeof(int) * 4); } void gs::effect_parameter::set_int_array(int32_t v[], size_t sz) @@ -312,40 +312,40 @@ void gs::effect_parameter::set_int_array(int32_t v[], size_t sz) if ((get_type() != type::Integer) && (get_type() != type::Integer2) && (get_type() != type::Integer3) && (get_type() != type::Integer4) && (get_type() != type::Unknown)) throw std::bad_cast(); - gs_effect_set_val(m_param, v, sizeof(int) * sz); + gs_effect_set_val(_param, v, sizeof(int) * sz); } void gs::effect_parameter::set_matrix(matrix4& v) { if (get_type() != type::Matrix) throw std::bad_cast(); - gs_effect_set_matrix4(m_param, &v); + gs_effect_set_matrix4(_param, &v); } void gs::effect_parameter::set_texture(std::shared_ptr v) { if (get_type() != type::Texture) throw std::bad_cast(); - gs_effect_set_texture(m_param, v->get_object()); + gs_effect_set_texture(_param, v->get_object()); } void gs::effect_parameter::set_texture(gs_texture_t* v) { if (get_type() != type::Texture) throw std::bad_cast(); - gs_effect_set_texture(m_param, v); + gs_effect_set_texture(_param, v); } void gs::effect_parameter::set_sampler(std::shared_ptr v) { if (get_type() != type::Texture) throw std::bad_cast(); - gs_effect_set_next_sampler(m_param, v->get_object()); + gs_effect_set_next_sampler(_param, v->get_object()); } void gs::effect_parameter::set_sampler(gs_sampler_state* v) { if (get_type() != type::Texture) throw std::bad_cast(); - gs_effect_set_next_sampler(m_param, v); + gs_effect_set_next_sampler(_param, v); } diff --git a/source/obs/gs/gs-effect.hpp b/source/obs/gs/gs-effect.hpp index 0587d2ba..633b796a 100644 --- a/source/obs/gs/gs-effect.hpp +++ b/source/obs/gs/gs-effect.hpp @@ -41,6 +41,9 @@ namespace gs { class effect_parameter { + gs_eparam_t* _param; + gs_effect_param_info _param_info; + public: enum class type : uint8_t { Unknown, @@ -84,13 +87,12 @@ namespace gs { void set_texture(gs_texture_t* v); void set_sampler(std::shared_ptr v); void set_sampler(gs_sampler_state* v); - - private: - gs_eparam_t* m_param; - gs_effect_param_info m_paramInfo; }; class effect { + protected: + gs_effect_t* _effect; + public: effect(); effect(std::string file); @@ -106,7 +108,5 @@ namespace gs { bool has_parameter(std::string name); bool has_parameter(std::string name, effect_parameter::type type); - protected: - gs_effect_t* m_effect; }; } // namespace gs diff --git a/source/obs/gs/gs-indexbuffer.cpp b/source/obs/gs/gs-indexbuffer.cpp index e174da7d..56dc16e1 100644 --- a/source/obs/gs/gs-indexbuffer.cpp +++ b/source/obs/gs/gs-indexbuffer.cpp @@ -35,7 +35,7 @@ gs::index_buffer::index_buffer(uint32_t maximumVertices) { this->reserve(maximumVertices); auto gctx = gs::context(); - m_indexBuffer = gs_indexbuffer_create(gs_index_type::GS_UNSIGNED_LONG, this->data(), maximumVertices, GS_DYNAMIC); + _index_buffer = gs_indexbuffer_create(gs_index_type::GS_UNSIGNED_LONG, this->data(), maximumVertices, GS_DYNAMIC); } gs::index_buffer::index_buffer() : index_buffer(MAXIMUM_VERTICES) {} @@ -53,7 +53,7 @@ gs::index_buffer::index_buffer(std::vector& other) : index_buffer((uin gs::index_buffer::~index_buffer() { auto gctx = gs::context(); - gs_indexbuffer_destroy(m_indexBuffer); + gs_indexbuffer_destroy(_index_buffer); } gs_indexbuffer_t* gs::index_buffer::get() @@ -65,7 +65,7 @@ gs_indexbuffer_t* gs::index_buffer::get(bool refreshGPU) { if (refreshGPU) { auto gctx = gs::context(); - gs_indexbuffer_flush(m_indexBuffer); + gs_indexbuffer_flush(_index_buffer); } - return m_indexBuffer; + return _index_buffer; } diff --git a/source/obs/gs/gs-indexbuffer.hpp b/source/obs/gs/gs-indexbuffer.hpp index 770f13de..381f7535 100644 --- a/source/obs/gs/gs-indexbuffer.hpp +++ b/source/obs/gs/gs-indexbuffer.hpp @@ -45,6 +45,6 @@ namespace gs { gs_indexbuffer_t* get(bool refreshGPU); protected: - gs_indexbuffer_t* m_indexBuffer; + gs_indexbuffer_t* _index_buffer; }; } // namespace gs diff --git a/source/obs/gs/gs-mipmapper.cpp b/source/obs/gs/gs-mipmapper.cpp index aad8f253..a4b3952a 100644 --- a/source/obs/gs/gs-mipmapper.cpp +++ b/source/obs/gs/gs-mipmapper.cpp @@ -72,44 +72,44 @@ struct gs_d3d11_device { gs::mipmapper::~mipmapper() { - vertex_buffer.reset(); - render_target.reset(); - effect.reset(); + _vb.reset(); + _rt.reset(); + _effect.reset(); } gs::mipmapper::mipmapper() { - vertex_buffer = std::make_unique(uint32_t(6u), uint8_t(1u)); - auto v0 = vertex_buffer->at(0); + _vb = std::make_unique(uint32_t(6u), uint8_t(1u)); + auto v0 = _vb->at(0); v0.position->x = 0; v0.position->y = 0; v0.uv[0]->x = 0; v0.uv[0]->y = 0; - auto v1 = vertex_buffer->at(1); - auto v4 = vertex_buffer->at(4); + auto v1 = _vb->at(1); + auto v4 = _vb->at(4); v4.position->x = v1.position->x = 1.0; v4.position->y = v1.position->y = 0; v4.uv[0]->x = v1.uv[0]->x = 1.0; v4.uv[0]->y = v1.uv[0]->y = 0; - auto v2 = vertex_buffer->at(2); - auto v3 = vertex_buffer->at(3); + auto v2 = _vb->at(2); + auto v3 = _vb->at(3); v3.position->x = v2.position->x = 0; v3.position->y = v2.position->y = 1.0; v3.uv[0]->x = v2.uv[0]->x = 0; v3.uv[0]->y = v2.uv[0]->y = 1.0; - auto v5 = vertex_buffer->at(5); + auto v5 = _vb->at(5); v5.position->x = 1.0; v5.position->y = 1.0; v5.uv[0]->x = 1.0; v5.uv[0]->y = 1.0; - vertex_buffer->update(); + _vb->update(); - char* effect_file = obs_module_file("effects/mipgen.effect"); - effect = std::make_unique(effect_file); + char* effect_file = obs_module_file("effects/mipgen._effect"); + _effect = std::make_unique(effect_file); bfree(effect_file); } @@ -154,8 +154,8 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr //gs_copy_texture(target->get_object(), source->get_object()); // Test if we actually need to recreate the render target for a different format or at all. - if ((!render_target) || (source->get_color_format() != render_target->get_color_format())) { - render_target = std::make_unique(source->get_color_format(), GS_ZS_NONE); + if ((!_rt) || (source->get_color_format() != _rt->get_color_format())) { + _rt = std::make_unique(source->get_color_format(), GS_ZS_NONE); } // Render @@ -189,7 +189,7 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr break; } - gs_load_vertexbuffer(vertex_buffer->update()); + gs_load_vertexbuffer(_vb->update()); gs_load_indexbuffer(nullptr); if (source->get_type() == gs::texture::type::Normal) { @@ -236,7 +236,7 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr // Draw mipmap layer try { - auto op = render_target->render(uint32_t(texture_width), uint32_t(texture_height)); + auto op = _rt->render(uint32_t(texture_width), uint32_t(texture_height)); gs_set_cull_mode(GS_NEITHER); gs_reset_blend_state(); @@ -252,13 +252,13 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr vec4_zero(&black); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0); - effect->get_parameter("image").set_texture(target); - effect->get_parameter("level").set_int(int32_t(mip - 1)); - effect->get_parameter("imageTexel").set_float2(texel_width, texel_height); - effect->get_parameter("strength").set_float(strength); + _effect->get_parameter("image").set_texture(target); + _effect->get_parameter("level").set_int(int32_t(mip - 1)); + _effect->get_parameter("imageTexel").set_float2(texel_width, texel_height); + _effect->get_parameter("strength").set_float(strength); - while (gs_effect_loop(effect->get_object(), technique.c_str())) { - gs_draw(gs_draw_mode::GS_TRIS, 0, vertex_buffer->size()); + while (gs_effect_loop(_effect->get_object(), technique.c_str())) { + gs_draw(gs_draw_mode::GS_TRIS, 0, _vb->size()); } } catch (...) { P_LOG_ERROR("Failed to render mipmap layer."); @@ -268,7 +268,7 @@ void gs::mipmapper::rebuild(std::shared_ptr source, std::shared_ptr if (device_type == GS_DEVICE_DIRECT3D_11) { // Copy ID3D11Texture2D* rt = - reinterpret_cast(gs_texture_get_obj(render_target->get_object())); + reinterpret_cast(gs_texture_get_obj(_rt->get_object())); uint32_t level = uint32_t(D3D11CalcSubresource(UINT(mip), 0, UINT(mip_levels))); dev->context->CopySubresourceRegion(target_t2, level, 0, 0, 0, rt, 0, NULL); } diff --git a/source/obs/gs/gs-mipmapper.hpp b/source/obs/gs/gs-mipmapper.hpp index 2576d1fd..c74c56b2 100644 --- a/source/obs/gs/gs-mipmapper.hpp +++ b/source/obs/gs/gs-mipmapper.hpp @@ -35,9 +35,9 @@ namespace gs { class mipmapper { - std::unique_ptr vertex_buffer; - std::unique_ptr render_target; - std::unique_ptr effect; + std::unique_ptr _vb; + std::unique_ptr _rt; + std::unique_ptr _effect; public: enum class generator : uint8_t { diff --git a/source/obs/gs/gs-rendertarget.cpp b/source/obs/gs/gs-rendertarget.cpp index 1c90a84b..46f75838 100644 --- a/source/obs/gs/gs-rendertarget.cpp +++ b/source/obs/gs/gs-rendertarget.cpp @@ -35,16 +35,16 @@ gs::rendertarget::~rendertarget() { auto gctx = gs::context(); - gs_texrender_destroy(render_target); + gs_texrender_destroy(_render_target); } gs::rendertarget::rendertarget(gs_color_format colorFormat, gs_zstencil_format zsFormat) - : color_format(colorFormat), zstencil_format(zsFormat) + : _color_format(colorFormat), _zstencil_format(zsFormat) { - is_being_rendered = false; + _is_being_rendered = false; auto gctx = gs::context(); - render_target = gs_texrender_create(colorFormat, zsFormat); - if (!render_target) { + _render_target = gs_texrender_create(colorFormat, zsFormat); + if (!_render_target) { throw std::runtime_error("Failed to create render target."); } } @@ -57,7 +57,7 @@ gs::rendertarget_op gs::rendertarget::render(uint32_t width, uint32_t height) gs_texture_t* gs::rendertarget::get_object() { auto gctx = gs::context(); - gs_texture_t* tex = gs_texrender_get_texture(render_target); + gs_texture_t* tex = gs_texrender_get_texture(_render_target); return tex; } @@ -83,27 +83,27 @@ void gs::rendertarget::get_texture(std::unique_ptr& tex) gs_color_format gs::rendertarget::get_color_format() { - return color_format; + return _color_format; } gs_zstencil_format gs::rendertarget::get_zstencil_format() { - return zstencil_format; + return _zstencil_format; } gs::rendertarget_op::rendertarget_op(gs::rendertarget* rt, uint32_t width, uint32_t height) : parent(rt) { if (parent == nullptr) throw std::invalid_argument("rt"); - if (parent->is_being_rendered) + if (parent->_is_being_rendered) throw std::logic_error("Can't start rendering to the same render target twice."); auto gctx = gs::context(); - gs_texrender_reset(parent->render_target); - if (!gs_texrender_begin(parent->render_target, width, height)) { + gs_texrender_reset(parent->_render_target); + if (!gs_texrender_begin(parent->_render_target, width, height)) { throw std::runtime_error("Failed to begin rendering to render target."); } - parent->is_being_rendered = true; + parent->_is_being_rendered = true; } gs::rendertarget_op::rendertarget_op(gs::rendertarget_op&& r) @@ -118,6 +118,6 @@ gs::rendertarget_op::~rendertarget_op() return; auto gctx = gs::context(); - gs_texrender_end(parent->render_target); - parent->is_being_rendered = false; + gs_texrender_end(parent->_render_target); + parent->_is_being_rendered = false; } diff --git a/source/obs/gs/gs-rendertarget.hpp b/source/obs/gs/gs-rendertarget.hpp index 9b973afd..5c7dcecc 100644 --- a/source/obs/gs/gs-rendertarget.hpp +++ b/source/obs/gs/gs-rendertarget.hpp @@ -39,11 +39,11 @@ namespace gs { friend class rendertarget_op; protected: - gs_texrender_t* render_target; - bool is_being_rendered; + gs_texrender_t* _render_target; + bool _is_being_rendered; - gs_color_format color_format; - gs_zstencil_format zstencil_format; + gs_color_format _color_format; + gs_zstencil_format _zstencil_format; public: ~rendertarget(); diff --git a/source/obs/gs/gs-sampler.cpp b/source/obs/gs/gs-sampler.cpp index c3477bfc..3bfd3ee9 100644 --- a/source/obs/gs/gs-sampler.cpp +++ b/source/obs/gs/gs-sampler.cpp @@ -21,113 +21,113 @@ gs::sampler::sampler() { - m_dirty = true; - m_samplerInfo = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0}; - m_samplerState = nullptr; + _dirty = true; + _sampler_info = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0}; + _sampler_state = nullptr; } gs::sampler::~sampler() { - if (m_samplerState) - gs_samplerstate_destroy(m_samplerState); + if (_sampler_state) + gs_samplerstate_destroy(_sampler_state); } void gs::sampler::set_filter(gs_sample_filter v) { - m_dirty = true; - m_samplerInfo.filter = v; + _dirty = true; + _sampler_info.filter = v; } gs_sample_filter gs::sampler::get_filter() { - return m_samplerInfo.filter; + return _sampler_info.filter; } void gs::sampler::set_address_mode_u(gs_address_mode v) { - m_dirty = true; - m_samplerInfo.address_u = v; + _dirty = true; + _sampler_info.address_u = v; } gs_address_mode gs::sampler::get_address_mode_u() { - return m_samplerInfo.address_u; + return _sampler_info.address_u; } void gs::sampler::set_address_mode_v(gs_address_mode v) { - m_dirty = true; - m_samplerInfo.address_v = v; + _dirty = true; + _sampler_info.address_v = v; } gs_address_mode gs::sampler::get_address_mode_v() { - return m_samplerInfo.address_v; + return _sampler_info.address_v; } void gs::sampler::set_address_mode_w(gs_address_mode v) { - m_dirty = true; - m_samplerInfo.address_w = v; + _dirty = true; + _sampler_info.address_w = v; } gs_address_mode gs::sampler::get_address_mode_w() { - return m_samplerInfo.address_w; + return _sampler_info.address_w; } void gs::sampler::set_max_anisotropy(int v) { - m_dirty = true; - m_samplerInfo.max_anisotropy = v; + _dirty = true; + _sampler_info.max_anisotropy = v; } int gs::sampler::get_max_anisotropy() { - return m_samplerInfo.max_anisotropy; + return _sampler_info.max_anisotropy; } void gs::sampler::set_border_color(uint32_t v) { - m_dirty = true; - m_samplerInfo.border_color = v; + _dirty = true; + _sampler_info.border_color = v; } void gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { - m_dirty = true; - m_samplerInfo.border_color = a << 24 | r << 16 | g << 8 | b; + _dirty = true; + _sampler_info.border_color = a << 24 | r << 16 | g << 8 | b; } uint32_t gs::sampler::get_border_color() { - return m_samplerInfo.border_color; + return _sampler_info.border_color; } uint8_t gs::sampler::get_border_color(bool r, bool g, bool b, bool a) { if (a) - return (m_samplerInfo.border_color >> 24) & 0xFF; + return (_sampler_info.border_color >> 24) & 0xFF; if (r) - return (m_samplerInfo.border_color >> 16) & 0xFF; + return (_sampler_info.border_color >> 16) & 0xFF; if (g) - return (m_samplerInfo.border_color >> 8) & 0xFF; + return (_sampler_info.border_color >> 8) & 0xFF; if (b) - return m_samplerInfo.border_color & 0xFF; + return _sampler_info.border_color & 0xFF; return 0; } gs_sampler_state* gs::sampler::refresh() { - gs_samplerstate_destroy(m_samplerState); - m_samplerState = gs_samplerstate_create(&m_samplerInfo); - m_dirty = false; - return m_samplerState; + gs_samplerstate_destroy(_sampler_state); + _sampler_state = gs_samplerstate_create(&_sampler_info); + _dirty = false; + return _sampler_state; } gs_sampler_state* gs::sampler::get_object() { - if (m_dirty) + if (_dirty) return refresh(); - return m_samplerState; + return _sampler_state; } diff --git a/source/obs/gs/gs-sampler.hpp b/source/obs/gs/gs-sampler.hpp index 210baf36..621fbc0f 100644 --- a/source/obs/gs/gs-sampler.hpp +++ b/source/obs/gs/gs-sampler.hpp @@ -61,8 +61,8 @@ namespace gs { gs_sampler_state* get_object(); private: - bool m_dirty; - gs_sampler_info m_samplerInfo; - gs_sampler_state* m_samplerState; + bool _dirty; + gs_sampler_info _sampler_info; + gs_sampler_state* _sampler_state; }; } // namespace gs diff --git a/source/obs/gs/gs-texture.cpp b/source/obs/gs/gs-texture.cpp index 757242d6..70507167 100644 --- a/source/obs/gs/gs-texture.cpp +++ b/source/obs/gs/gs-texture.cpp @@ -52,15 +52,15 @@ gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, ui } auto gctx = gs::context(); - m_texture = gs_texture_create( + _texture = gs_texture_create( width, height, format, mip_levels, mip_data, (((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0) | (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0)); - if (!m_texture) + if (!_texture) throw std::runtime_error("Failed to create texture."); - m_textureType = type::Normal; + _type = type::Normal; } gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels, @@ -84,15 +84,15 @@ gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f } auto gctx = gs::context(); - m_texture = gs_voltexture_create( + _texture = gs_voltexture_create( width, height, depth, format, mip_levels, mip_data, (((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0) | (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0)); - if (!m_texture) + if (!_texture) throw std::runtime_error("Failed to create texture."); - m_textureType = type::Volume; + _type = type::Volume; } gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data, @@ -110,15 +110,15 @@ gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, } auto gctx = gs::context(); - m_texture = gs_cubetexture_create( + _texture = gs_cubetexture_create( size, format, mip_levels, mip_data, (((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0) | (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0)); - if (!m_texture) + if (!_texture) throw std::runtime_error("Failed to create texture."); - m_textureType = type::Cube; + _type = type::Cube; } gs::texture::texture(std::string file) @@ -128,75 +128,75 @@ gs::texture::texture(std::string file) throw std::ios_base::failure(file); auto gctx = gs::context(); - m_texture = gs_texture_create_from_file(file.c_str()); + _texture = gs_texture_create_from_file(file.c_str()); - if (!m_texture) + if (!_texture) throw std::runtime_error("Failed to load texture."); } gs::texture::~texture() { - if (m_isOwner && m_texture) { + if (_is_owner && _texture) { auto gctx = gs::context(); - switch (gs_get_texture_type(m_texture)) { + switch (gs_get_texture_type(_texture)) { case GS_TEXTURE_2D: - gs_texture_destroy(m_texture); + gs_texture_destroy(_texture); break; case GS_TEXTURE_3D: - gs_voltexture_destroy(m_texture); + gs_voltexture_destroy(_texture); break; case GS_TEXTURE_CUBE: - gs_cubetexture_destroy(m_texture); + gs_cubetexture_destroy(_texture); break; } } - m_texture = nullptr; + _texture = nullptr; } void gs::texture::load(int unit) { auto gctx = gs::context(); - gs_load_texture(m_texture, unit); + gs_load_texture(_texture, unit); } gs_texture_t* gs::texture::get_object() { - return m_texture; + return _texture; } uint32_t gs::texture::get_width() { - switch (m_textureType) { + switch (_type) { case type::Normal: - return gs_texture_get_width(m_texture); + return gs_texture_get_width(_texture); case type::Volume: - return gs_voltexture_get_width(m_texture); + return gs_voltexture_get_width(_texture); case type::Cube: - return gs_cubetexture_get_size(m_texture); + return gs_cubetexture_get_size(_texture); } return 0; } uint32_t gs::texture::get_height() { - switch (m_textureType) { + switch (_type) { case type::Normal: - return gs_texture_get_height(m_texture); + return gs_texture_get_height(_texture); case type::Volume: - return gs_voltexture_get_height(m_texture); + return gs_voltexture_get_height(_texture); case type::Cube: - return gs_cubetexture_get_size(m_texture); + return gs_cubetexture_get_size(_texture); } return 0; } uint32_t gs::texture::get_depth() { - switch (m_textureType) { + switch (_type) { case type::Normal: return 1; case type::Volume: - return gs_voltexture_get_depth(m_texture); + return gs_voltexture_get_depth(_texture); case type::Cube: return 6; } @@ -205,10 +205,10 @@ uint32_t gs::texture::get_depth() gs::texture::type gs::texture::get_type() { - return m_textureType; + return _type; } gs_color_format gs::texture::get_color_format() { - return gs_texture_get_color_format(m_texture); + return gs_texture_get_color_format(_texture); } diff --git a/source/obs/gs/gs-texture.hpp b/source/obs/gs/gs-texture.hpp index 92cff6ba..af0fcf80 100644 --- a/source/obs/gs/gs-texture.hpp +++ b/source/obs/gs/gs-texture.hpp @@ -44,9 +44,9 @@ namespace gs { }; protected: - gs_texture_t* m_texture; - bool m_isOwner = true; - type m_textureType = type::Normal; + gs_texture_t* _texture; + bool _is_owner = true; + type _type = type::Normal; public: ~texture(); @@ -105,7 +105,7 @@ namespace gs { /*! * \brief Create a texture from an existing gs_texture_t object. */ - texture(gs_texture_t* tex, bool takeOwnership = false) : m_texture(tex), m_isOwner(takeOwnership) {} + texture(gs_texture_t* tex, bool takeOwnership = false) : _texture(tex), _is_owner(takeOwnership) {} void load(int unit); @@ -123,4 +123,4 @@ namespace gs { }; } // namespace gs -ENABLE_BITMASK_OPERATORS(gs::texture::flags) +P_ENABLE_BITMASK_OPERATORS(gs::texture::flags) diff --git a/source/obs/gs/gs-vertex.cpp b/source/obs/gs/gs-vertex.cpp index c69cae46..c793310f 100644 --- a/source/obs/gs/gs-vertex.cpp +++ b/source/obs/gs/gs-vertex.cpp @@ -21,39 +21,39 @@ #include "util-memory.hpp" gs::vertex::vertex() - : position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), hasStore(true), store(nullptr) + : position(nullptr), normal(nullptr), tangent(nullptr), color(nullptr), _has_store(true), _store(nullptr) { - store = util::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4) * MAXIMUM_UVW_LAYERS); + _store = util::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4) * MAXIMUM_UVW_LAYERS); size_t offset = 0; - position = reinterpret_cast(reinterpret_cast(store) + offset); + position = reinterpret_cast(reinterpret_cast(_store) + offset); offset += sizeof(vec3); - normal = reinterpret_cast(reinterpret_cast(store) + offset); + normal = reinterpret_cast(reinterpret_cast(_store) + offset); offset += sizeof(vec3); - tangent = reinterpret_cast(reinterpret_cast(store) + offset); + tangent = reinterpret_cast(reinterpret_cast(_store) + offset); offset += sizeof(vec3); - color = reinterpret_cast(reinterpret_cast(store) + offset); + color = reinterpret_cast(reinterpret_cast(_store) + offset); offset += sizeof(uint32_t); for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { - uv[n] = reinterpret_cast(reinterpret_cast(store) + offset); + uv[n] = reinterpret_cast(reinterpret_cast(_store) + offset); offset += sizeof(vec4); } } gs::vertex::~vertex() { - if (hasStore) { - util::free_aligned(store); + if (_has_store) { + util::free_aligned(_store); } } gs::vertex::vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS]) - : position(p), normal(n), tangent(t), color(col), hasStore(false) + : position(p), normal(n), tangent(t), color(col), _has_store(false) { if (uvs != nullptr) { for (size_t idx = 0; idx < MAXIMUM_UVW_LAYERS; idx++) { diff --git a/source/obs/gs/gs-vertex.hpp b/source/obs/gs/gs-vertex.hpp index 17375914..32f16c52 100644 --- a/source/obs/gs/gs-vertex.hpp +++ b/source/obs/gs/gs-vertex.hpp @@ -45,7 +45,7 @@ namespace gs { ~vertex(); private: - bool hasStore; - void* store; + bool _has_store; + void* _store; }; } // namespace gs diff --git a/source/obs/gs/gs-vertexbuffer.cpp b/source/obs/gs/gs-vertexbuffer.cpp index 626c4c3d..da143a20 100644 --- a/source/obs/gs/gs-vertexbuffer.cpp +++ b/source/obs/gs/gs-vertexbuffer.cpp @@ -34,43 +34,43 @@ gs::vertex_buffer::~vertex_buffer() { - if (m_positions) { - util::free_aligned(m_positions); - m_positions = nullptr; + if (_positions) { + util::free_aligned(_positions); + _positions = nullptr; } - if (m_normals) { - util::free_aligned(m_normals); - m_normals = nullptr; + if (_normals) { + util::free_aligned(_normals); + _normals = nullptr; } - if (m_tangents) { - util::free_aligned(m_tangents); - m_tangents = nullptr; + if (_tangents) { + util::free_aligned(_tangents); + _tangents = nullptr; } - if (m_colors) { - util::free_aligned(m_colors); - m_colors = nullptr; + if (_colors) { + util::free_aligned(_colors); + _colors = nullptr; } - for (size_t n = 0; n < m_layers; n++) { - if (m_uvs[n]) { - util::free_aligned(m_uvs[n]); - m_uvs[n] = nullptr; + for (size_t n = 0; n < _layers; n++) { + if (_uvs[n]) { + util::free_aligned(_uvs[n]); + _uvs[n] = nullptr; } } - if (m_layerdata) { - util::free_aligned(m_layerdata); - m_layerdata = nullptr; + if (_layer_data) { + util::free_aligned(_layer_data); + _layer_data = nullptr; } - if (m_vertexbufferdata) { - memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); - if (!m_vertexbuffer) { - gs_vbdata_destroy(m_vertexbufferdata); - m_vertexbufferdata = nullptr; + if (_data) { + memset(_data, 0, sizeof(gs_vb_data)); + if (!_buffer) { + gs_vbdata_destroy(_data); + _data = nullptr; } } - if (m_vertexbuffer) { + if (_buffer) { auto gctx = gs::context(); - gs_vertexbuffer_destroy(m_vertexbuffer); - m_vertexbuffer = nullptr; + gs_vertexbuffer_destroy(_buffer); + _buffer = nullptr; } } @@ -79,8 +79,8 @@ gs::vertex_buffer::vertex_buffer() : vertex_buffer(MAXIMUM_VERTICES, MAXIMUM_UVW gs::vertex_buffer::vertex_buffer(uint32_t vertices) : vertex_buffer(vertices, MAXIMUM_UVW_LAYERS) {} gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers) - : m_size(vertices), m_capacity(vertices), m_layers(uvlayers), m_positions(nullptr), m_normals(nullptr), - m_tangents(nullptr), m_colors(nullptr), m_vertexbufferdata(nullptr), m_vertexbuffer(nullptr), m_layerdata(nullptr) + : _size(vertices), _capacity(vertices), _layers(uvlayers), _positions(nullptr), _normals(nullptr), + _tangents(nullptr), _colors(nullptr), _data(nullptr), _buffer(nullptr), _layer_data(nullptr) { if (vertices > MAXIMUM_VERTICES) { throw std::out_of_range("vertices out of range"); @@ -90,41 +90,41 @@ gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers) } // Allocate memory for data. - m_vertexbufferdata = gs_vbdata_create(); - m_vertexbufferdata->num = m_capacity; - m_vertexbufferdata->points = m_positions = (vec3*)util::malloc_aligned(16, sizeof(vec3) * m_capacity); - m_vertexbufferdata->normals = m_normals = (vec3*)util::malloc_aligned(16, sizeof(vec3) * m_capacity); - m_vertexbufferdata->tangents = m_tangents = (vec3*)util::malloc_aligned(16, sizeof(vec3) * m_capacity); - m_vertexbufferdata->colors = m_colors = (uint32_t*)util::malloc_aligned(16, sizeof(uint32_t) * m_capacity); + _data = gs_vbdata_create(); + _data->num = _capacity; + _data->points = _positions = (vec3*)util::malloc_aligned(16, sizeof(vec3) * _capacity); + _data->normals = _normals = (vec3*)util::malloc_aligned(16, sizeof(vec3) * _capacity); + _data->tangents = _tangents = (vec3*)util::malloc_aligned(16, sizeof(vec3) * _capacity); + _data->colors = _colors = (uint32_t*)util::malloc_aligned(16, sizeof(uint32_t) * _capacity); // cppcheck-suppress memsetClassFloat - memset(m_positions, 0, sizeof(vec3) * m_capacity); + memset(_positions, 0, sizeof(vec3) * _capacity); // cppcheck-suppress memsetClassFloat - memset(m_normals, 0, sizeof(vec3) * m_capacity); + memset(_normals, 0, sizeof(vec3) * _capacity); // cppcheck-suppress memsetClassFloat - memset(m_tangents, 0, sizeof(vec3) * m_capacity); - memset(m_colors, 0, sizeof(uint32_t) * m_capacity); + memset(_tangents, 0, sizeof(vec3) * _capacity); + memset(_colors, 0, sizeof(uint32_t) * _capacity); - m_vertexbufferdata->num_tex = m_layers; - if (m_layers > 0) { - m_vertexbufferdata->tvarray = m_layerdata = - (gs_tvertarray*)util::malloc_aligned(16, sizeof(gs_tvertarray) * m_layers); - for (size_t n = 0; n < m_layers; n++) { - m_layerdata[n].array = m_uvs[n] = (vec4*)util::malloc_aligned(16, sizeof(vec4) * m_capacity); - m_layerdata[n].width = 4; - memset(m_uvs[n], 0, sizeof(vec4) * m_capacity); + _data->num_tex = _layers; + if (_layers > 0) { + _data->tvarray = _layer_data = + (gs_tvertarray*)util::malloc_aligned(16, sizeof(gs_tvertarray) * _layers); + for (size_t n = 0; n < _layers; n++) { + _layer_data[n].array = _uvs[n] = (vec4*)util::malloc_aligned(16, sizeof(vec4) * _capacity); + _layer_data[n].width = 4; + memset(_uvs[n], 0, sizeof(vec4) * _capacity); } } else { - m_vertexbufferdata->tvarray = nullptr; + _data->tvarray = nullptr; } // Allocate GPU auto gctx = gs::context(); - m_vertexbuffer = gs_vertexbuffer_create(m_vertexbufferdata, GS_DYNAMIC); - memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); - m_vertexbufferdata->num = m_capacity; - m_vertexbufferdata->num_tex = m_layers; - if (!m_vertexbuffer) { + _buffer = gs_vertexbuffer_create(_data, GS_DYNAMIC); + memset(_data, 0, sizeof(gs_vb_data)); + _data->num = _capacity; + _data->num_tex = _layers; + if (!_buffer) { throw std::runtime_error("Failed to create vertex buffer."); } } @@ -141,24 +141,24 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb) this->set_uv_layers((uint32_t)vbd->num_tex); if (vbd->points != nullptr) - memcpy(m_positions, vbd->points, vbd->num * sizeof(vec3)); + memcpy(_positions, vbd->points, vbd->num * sizeof(vec3)); if (vbd->normals != nullptr) - memcpy(m_normals, vbd->normals, vbd->num * sizeof(vec3)); + memcpy(_normals, vbd->normals, vbd->num * sizeof(vec3)); if (vbd->tangents != nullptr) - memcpy(m_tangents, vbd->tangents, vbd->num * sizeof(vec3)); + memcpy(_tangents, vbd->tangents, vbd->num * sizeof(vec3)); if (vbd->colors != nullptr) - memcpy(m_colors, vbd->colors, vbd->num * sizeof(uint32_t)); + memcpy(_colors, vbd->colors, vbd->num * sizeof(uint32_t)); if (vbd->tvarray != nullptr) { for (size_t n = 0; n < vbd->num_tex; n++) { if (vbd->tvarray[n].array != nullptr && vbd->tvarray[n].width <= 4 && vbd->tvarray[n].width > 0) { if (vbd->tvarray[n].width == 4) { - memcpy(m_uvs[n], vbd->tvarray[n].array, vbd->num * sizeof(vec4)); + memcpy(_uvs[n], vbd->tvarray[n].array, vbd->num * sizeof(vec4)); } else { - for (size_t idx = 0; idx < m_capacity; idx++) { + for (size_t idx = 0; idx < _capacity; idx++) { float* mem = reinterpret_cast(vbd->tvarray[n].array) + (idx * vbd->tvarray[n].width); // cppcheck-suppress memsetClassFloat - memset(&m_uvs[n][idx], 0, sizeof(vec4)); - memcpy(&m_uvs[n][idx], mem, vbd->tvarray[n].width); + memset(&_uvs[n][idx], 0, sizeof(vec4)); + memcpy(&_uvs[n][idx], mem, vbd->tvarray[n].width); } } } @@ -167,120 +167,120 @@ gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb) } // cppcheck-suppress uninitMemberVar -gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(other.m_capacity) +gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(other._capacity) { // Copy Constructor - memcpy(m_positions, other.m_positions, m_capacity * sizeof(vec3)); - memcpy(m_normals, other.m_normals, m_capacity * sizeof(vec3)); - memcpy(m_tangents, other.m_tangents, m_capacity * sizeof(vec3)); - memcpy(m_colors, other.m_colors, m_capacity * sizeof(vec3)); + memcpy(_positions, other._positions, _capacity * sizeof(vec3)); + memcpy(_normals, other._normals, _capacity * sizeof(vec3)); + memcpy(_tangents, other._tangents, _capacity * sizeof(vec3)); + memcpy(_colors, other._colors, _capacity * sizeof(vec3)); for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { - memcpy(m_uvs[n], other.m_uvs[n], m_capacity * sizeof(vec3)); + memcpy(_uvs[n], other._uvs[n], _capacity * sizeof(vec3)); } } gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other) { // Move Constructor - m_capacity = other.m_capacity; - m_size = other.m_size; - m_layers = other.m_layers; - m_positions = other.m_positions; - m_normals = other.m_normals; - m_tangents = other.m_tangents; + _capacity = other._capacity; + _size = other._size; + _layers = other._layers; + _positions = other._positions; + _normals = other._normals; + _tangents = other._tangents; for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { - m_uvs[n] = other.m_uvs[n]; + _uvs[n] = other._uvs[n]; } - m_vertexbufferdata = other.m_vertexbufferdata; - m_vertexbuffer = other.m_vertexbuffer; - m_layerdata = other.m_layerdata; + _data = other._data; + _buffer = other._buffer; + _layer_data = other._layer_data; } void gs::vertex_buffer::operator=(vertex_buffer const&& other) { // Move Assignment /// First self-destruct (semi-destruct itself). - if (m_positions) { - util::free_aligned(m_positions); - m_positions = nullptr; + if (_positions) { + util::free_aligned(_positions); + _positions = nullptr; } - if (m_normals) { - util::free_aligned(m_normals); - m_normals = nullptr; + if (_normals) { + util::free_aligned(_normals); + _normals = nullptr; } - if (m_tangents) { - util::free_aligned(m_tangents); - m_tangents = nullptr; + if (_tangents) { + util::free_aligned(_tangents); + _tangents = nullptr; } - if (m_colors) { - util::free_aligned(m_colors); - m_colors = nullptr; + if (_colors) { + util::free_aligned(_colors); + _colors = nullptr; } for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { - if (m_uvs[n]) { - util::free_aligned(m_uvs[n]); - m_uvs[n] = nullptr; + if (_uvs[n]) { + util::free_aligned(_uvs[n]); + _uvs[n] = nullptr; } } - if (m_layerdata) { - util::free_aligned(m_layerdata); - m_layerdata = nullptr; + if (_layer_data) { + util::free_aligned(_layer_data); + _layer_data = nullptr; } - if (m_vertexbufferdata) { - memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); - if (!m_vertexbuffer) { - gs_vbdata_destroy(m_vertexbufferdata); - m_vertexbufferdata = nullptr; + if (_data) { + memset(_data, 0, sizeof(gs_vb_data)); + if (!_buffer) { + gs_vbdata_destroy(_data); + _data = nullptr; } } - if (m_vertexbuffer) { + if (_buffer) { auto gctx = gs::context(); - gs_vertexbuffer_destroy(m_vertexbuffer); - m_vertexbuffer = nullptr; + gs_vertexbuffer_destroy(_buffer); + _buffer = nullptr; } /// Then assign new values. - m_capacity = other.m_capacity; - m_size = other.m_size; - m_layers = other.m_layers; - m_positions = other.m_positions; - m_normals = other.m_normals; - m_tangents = other.m_tangents; + _capacity = other._capacity; + _size = other._size; + _layers = other._layers; + _positions = other._positions; + _normals = other._normals; + _tangents = other._tangents; for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { - m_uvs[n] = other.m_uvs[n]; + _uvs[n] = other._uvs[n]; } - m_vertexbufferdata = other.m_vertexbufferdata; - m_vertexbuffer = other.m_vertexbuffer; - m_layerdata = other.m_layerdata; + _data = other._data; + _buffer = other._buffer; + _layer_data = other._layer_data; } void gs::vertex_buffer::resize(uint32_t new_size) { - if (new_size > m_capacity) { + if (new_size > _capacity) { throw std::out_of_range("new_size out of range"); } - m_size = new_size; + _size = new_size; } uint32_t gs::vertex_buffer::size() { - return m_size; + return _size; } bool gs::vertex_buffer::empty() { - return m_size == 0; + return _size == 0; } const gs::vertex gs::vertex_buffer::at(uint32_t idx) { - if ((idx < 0) || (idx >= m_size)) { + if ((idx < 0) || (idx >= _size)) { throw std::out_of_range("idx out of range"); } - gs::vertex vtx(&m_positions[idx], &m_normals[idx], &m_tangents[idx], &m_colors[idx], nullptr); - for (size_t n = 0; n < m_layers; n++) { - vtx.uv[n] = &m_uvs[n][idx]; + gs::vertex vtx(&_positions[idx], &_normals[idx], &_tangents[idx], &_colors[idx], nullptr); + for (size_t n = 0; n < _layers; n++) { + vtx.uv[n] = &_uvs[n][idx]; } return vtx; } @@ -292,78 +292,78 @@ const gs::vertex gs::vertex_buffer::operator[](uint32_t const pos) void gs::vertex_buffer::set_uv_layers(uint32_t layers) { - m_layers = layers; + _layers = layers; } uint32_t gs::vertex_buffer::get_uv_layers() { - return m_layers; + return _layers; } vec3* gs::vertex_buffer::get_positions() { - return m_positions; + return _positions; } vec3* gs::vertex_buffer::get_normals() { - return m_normals; + return _normals; } vec3* gs::vertex_buffer::get_tangents() { - return m_tangents; + return _tangents; } uint32_t* gs::vertex_buffer::get_colors() { - return m_colors; + return _colors; } vec4* gs::vertex_buffer::get_uv_layer(size_t idx) { - if ((idx < 0) || (idx >= m_layers)) { + if ((idx < 0) || (idx >= _layers)) { throw std::out_of_range("idx out of range"); } - return m_uvs[idx]; + return _uvs[idx]; } gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU) { if (!refreshGPU) - return m_vertexbuffer; + return _buffer; - if (m_size > m_capacity) + if (_size > _capacity) throw std::out_of_range("size is larger than capacity"); // Update VertexBuffer data. auto gctx = gs::context(); - m_vertexbufferdata = gs_vertexbuffer_get_data(m_vertexbuffer); - memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); - m_vertexbufferdata->num = m_capacity; - m_vertexbufferdata->points = m_positions; - m_vertexbufferdata->normals = m_normals; - m_vertexbufferdata->tangents = m_tangents; - m_vertexbufferdata->colors = m_colors; - m_vertexbufferdata->num_tex = m_layers; - m_vertexbufferdata->tvarray = m_layerdata; - for (size_t n = 0; n < m_layers; n++) { - m_layerdata[n].array = m_uvs[n]; - m_layerdata[n].width = 4; + _data = gs_vertexbuffer_get_data(_buffer); + memset(_data, 0, sizeof(gs_vb_data)); + _data->num = _capacity; + _data->points = _positions; + _data->normals = _normals; + _data->tangents = _tangents; + _data->colors = _colors; + _data->num_tex = _layers; + _data->tvarray = _layer_data; + for (size_t n = 0; n < _layers; n++) { + _layer_data[n].array = _uvs[n]; + _layer_data[n].width = 4; } // Update GPU - gs_vertexbuffer_flush(m_vertexbuffer); + gs_vertexbuffer_flush(_buffer); // WORKAROUND: OBS Studio 20.x and below incorrectly deletes data that it doesn't own. - memset(m_vertexbufferdata, 0, sizeof(gs_vb_data)); - m_vertexbufferdata->num = m_capacity; - m_vertexbufferdata->num_tex = m_layers; - for (uint32_t n = 0; n < m_layers; n++) { - m_layerdata[n].width = 4; + memset(_data, 0, sizeof(gs_vb_data)); + _data->num = _capacity; + _data->num_tex = _layers; + for (uint32_t n = 0; n < _layers; n++) { + _layer_data[n].width = 4; } - return m_vertexbuffer; + return _buffer; } gs_vertbuffer_t* gs::vertex_buffer::update() diff --git a/source/obs/gs/gs-vertexbuffer.hpp b/source/obs/gs/gs-vertexbuffer.hpp index 9c0716d0..074eaf9f 100644 --- a/source/obs/gs/gs-vertexbuffer.hpp +++ b/source/obs/gs/gs-vertexbuffer.hpp @@ -36,6 +36,22 @@ namespace gs { class vertex_buffer { + uint32_t _size; + uint32_t _capacity; + uint32_t _layers; + + // Memory Storage + vec3* _positions; + vec3* _normals; + vec3* _tangents; + uint32_t* _colors; + vec4* _uvs[MAXIMUM_UVW_LAYERS]; + + // OBS GS Data + gs_vb_data* _data; + gs_vertbuffer_t* _buffer; + gs_tvertarray* _layer_data; + public: virtual ~vertex_buffer(); @@ -160,22 +176,5 @@ namespace gs { gs_vertbuffer_t* update(); gs_vertbuffer_t* update(bool refreshGPU); - - private: - uint32_t m_size; - uint32_t m_capacity; - uint32_t m_layers; - - // Memory Storage - vec3* m_positions; - vec3* m_normals; - vec3* m_tangents; - uint32_t* m_colors; - vec4* m_uvs[MAXIMUM_UVW_LAYERS]; - - // OBS GS Data - gs_vb_data* m_vertexbufferdata; - gs_vertbuffer_t* m_vertexbuffer; - gs_tvertarray* m_layerdata; }; } // namespace gs diff --git a/source/obs/obs-source-tracker.cpp b/source/obs/obs-source-tracker.cpp index a4407312..1347a34e 100644 --- a/source/obs/obs-source-tracker.cpp +++ b/source/obs/obs-source-tracker.cpp @@ -43,7 +43,7 @@ void obs::source_tracker::source_create_handler(void* ptr, calldata_t* data) return; } - self->source_map.insert({std::string(name), weak}); + self->_source_map.insert({std::string(name), weak}); } void obs::source_tracker::source_destroy_handler(void* ptr, calldata_t* data) @@ -63,13 +63,13 @@ void obs::source_tracker::source_destroy_handler(void* ptr, calldata_t* data) return; } - auto found = self->source_map.find(std::string(name)); - if (found == self->source_map.end()) { + auto found = self->_source_map.find(std::string(name)); + if (found == self->_source_map.end()) { return; } obs_weak_source_release(found->second); - self->source_map.erase(found); + self->_source_map.erase(found); } void obs::source_tracker::source_rename_handler(void* ptr, calldata_t* data) @@ -88,20 +88,20 @@ void obs::source_tracker::source_rename_handler(void* ptr, calldata_t* data) return; } - auto found = self->source_map.find(std::string(prev_name)); - if (found == self->source_map.end()) { + auto found = self->_source_map.find(std::string(prev_name)); + if (found == self->_source_map.end()) { // Untracked source, insert. obs_weak_source_t* weak = obs_source_get_weak_source(target); if (!weak) { return; } - self->source_map.insert({new_name, weak}); + self->_source_map.insert({new_name, weak}); return; } // Insert at new key, remove old pair. - self->source_map.insert({new_name, found->second}); - self->source_map.erase(found); + self->_source_map.insert({new_name, found->second}); + self->_source_map.erase(found); } void obs::source_tracker::initialize() @@ -136,17 +136,17 @@ obs::source_tracker::~source_tracker() signal_handler_disconnect(osi, "source_rename", &source_rename_handler, this); } - for (auto kv : this->source_map) { + for (auto kv : this->_source_map) { obs_weak_source_release(kv.second); } - this->source_map.clear(); + this->_source_map.clear(); } void obs::source_tracker::enumerate(enumerate_cb_t ecb, filter_cb_t fcb) { // Need func-local copy, otherwise we risk corruption if a new source is created or destroyed. - auto source_map_copy = this->source_map; - for (auto kv : this->source_map) { + auto source_map_copy = this->_source_map; + for (auto kv : this->_source_map) { obs_source_t* source = obs_weak_source_get_source(kv.second); if (!source) { continue; diff --git a/source/obs/obs-source-tracker.hpp b/source/obs/obs-source-tracker.hpp index f5fbf3ae..67881bbf 100644 --- a/source/obs/obs-source-tracker.hpp +++ b/source/obs/obs-source-tracker.hpp @@ -34,7 +34,7 @@ namespace obs { class source_tracker { - std::map source_map; + std::map _source_map; static void source_create_handler(void* ptr, calldata_t* data); static void source_destroy_handler(void* ptr, calldata_t* data); diff --git a/source/obs/obs-source.cpp b/source/obs/obs-source.cpp index 1f155507..dfc6e81e 100644 --- a/source/obs/obs-source.cpp +++ b/source/obs/obs-source.cpp @@ -28,8 +28,8 @@ void obs::source::handle_destroy(void* p, calldata_t* calldata) return; } - if (self->self == source) { - self->self = nullptr; + if (self->_self == source) { + self->_self = nullptr; } if (self->events.destroy) { @@ -397,10 +397,10 @@ obs::source::~source() auto_signal_d(transition_stop); #undef auto_signal_d - if (this->track_ownership && this->self) { - obs_source_release(this->self); + if (this->_track_ownership && this->_self) { + obs_source_release(this->_self); } - this->self = nullptr; + this->_self = nullptr; } obs::source::source() @@ -411,17 +411,17 @@ obs::source::source() #define auto_signal_c(SIGNAL) \ { \ this->events.SIGNAL.set_listen_callback([this] { \ - if (!this->self) \ + if (!this->_self) \ return; \ - auto sh = obs_source_get_signal_handler(this->self); \ + auto sh = obs_source_get_signal_handler(this->_self); \ if (sh) { \ signal_handler_connect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ } \ }); \ this->events.SIGNAL.set_silence_callback([this] { \ - if (!this->self) \ + if (!this->_self) \ return; \ - auto sh = obs_source_get_signal_handler(this->self); \ + auto sh = obs_source_get_signal_handler(this->_self); \ if (sh) { \ signal_handler_disconnect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ } \ @@ -441,51 +441,51 @@ obs::source::source() // things do. So instead we'll have to manually deal with it for now. { this->events.audio_data.set_listen_callback([this] { - if (!this->self) + if (!this->_self) return; - obs_source_add_audio_capture_callback(this->self, obs::source::handle_audio_data, this); + obs_source_add_audio_capture_callback(this->_self, obs::source::handle_audio_data, this); }); this->events.audio_data.set_silence_callback([this] { - if (!this->self) + if (!this->_self) return; - obs_source_remove_audio_capture_callback(this->self, obs::source::handle_audio_data, this); + obs_source_remove_audio_capture_callback(this->_self, obs::source::handle_audio_data, this); }); } } obs::source::source(std::string name, bool ptrack_ownership, bool add_reference) : ::obs::source::source() { - this->self = obs_get_source_by_name(name.c_str()); - if (!this->self) { + this->_self = obs_get_source_by_name(name.c_str()); + if (!this->_self) { throw std::runtime_error("source with name not found"); } - this->track_ownership = ptrack_ownership; + this->_track_ownership = ptrack_ownership; if (!add_reference) { - obs_source_release(this->self); + obs_source_release(this->_self); } } obs::source::source(obs_source_t* source, bool ptrack_ownership, bool add_reference) : ::obs::source::source() { - this->self = source; - if (!this->self) { + this->_self = source; + if (!this->_self) { throw std::invalid_argument("source must not be null"); } - this->track_ownership = ptrack_ownership; + this->_track_ownership = ptrack_ownership; if (add_reference) { - obs_source_addref(this->self); + obs_source_addref(this->_self); } } obs::source::source(source const& other) { - this->self = other.self; - this->track_ownership = other.track_ownership; + this->_self = other._self; + this->_track_ownership = other._track_ownership; - if (this->track_ownership) { - obs_source_addref(this->self); + if (this->_track_ownership) { + obs_source_addref(this->_self); } #ifdef auto_signal_c @@ -529,15 +529,15 @@ obs::source& obs::source::operator=(source const& other) } // Release previous source. - if (this->self && this->track_ownership) { - obs_source_release(this->self); + if (this->_self && this->_track_ownership) { + obs_source_release(this->_self); } - this->self = other.self; - this->track_ownership = other.track_ownership; + this->_self = other._self; + this->_track_ownership = other._track_ownership; - if (this->track_ownership) { - obs_source_addref(this->self); + if (this->_track_ownership) { + obs_source_addref(this->_self); } #ifdef auto_signal_c @@ -576,11 +576,11 @@ obs::source& obs::source::operator=(source const& other) return *this; } -obs::source::source(source&& other) : self(std::move(other.self)), track_ownership(std::move(other.track_ownership)) +obs::source::source(source&& other) : _self(std::move(other._self)), _track_ownership(std::move(other._track_ownership)) { // Clean out other source - other.self = nullptr; - other.track_ownership = false; + other._self = nullptr; + other._track_ownership = false; #ifdef auto_signal_c #undef auto_signal_c @@ -623,14 +623,14 @@ obs::source& obs::source::operator=(source&& other) } // Release previous source. - if (this->self && this->track_ownership) { - obs_source_release(this->self); + if (this->_self && this->_track_ownership) { + obs_source_release(this->_self); } - this->self = std::move(other.self); - this->track_ownership = std::move(other.track_ownership); - other.self = nullptr; - other.track_ownership = false; + this->_self = std::move(other._self); + this->_track_ownership = std::move(other._track_ownership); + other._self = nullptr; + other._track_ownership = false; #ifdef auto_signal_c #undef auto_signal_c @@ -670,47 +670,47 @@ obs::source& obs::source::operator=(source&& other) obs_source_type obs::source::type() { - if (!self) { + if (!_self) { return (obs_source_type)-1; } - return obs_source_get_type(self); + return obs_source_get_type(_self); } void* obs::source::type_data() { - if (!self) { + if (!_self) { return nullptr; } - return obs_source_get_type_data(self); + return obs_source_get_type_data(_self); } uint32_t obs::source::width() { - if (!self) { + if (!_self) { return 0; } - return obs_source_get_width(self); + return obs_source_get_width(_self); } uint32_t obs::source::height() { - if (!self) { + if (!_self) { return 0; } - return obs_source_get_height(self); + return obs_source_get_height(_self); } bool obs::source::destroyed() { - return self == nullptr; + return _self == nullptr; } void obs::source::clear() { - self = nullptr; + _self = nullptr; } obs_source_t* obs::source::get() { - return self; + return _self; } diff --git a/source/obs/obs-source.hpp b/source/obs/obs-source.hpp index db57a5de..755b26ef 100644 --- a/source/obs/obs-source.hpp +++ b/source/obs/obs-source.hpp @@ -37,8 +37,8 @@ namespace obs { class source { - obs_source_t* self; - bool track_ownership = false; + obs_source_t* _self; + bool _track_ownership = false; static void handle_destroy(void* p, calldata_t* calldata); static void handle_remove(void* p, calldata_t* calldata); diff --git a/source/plugin.cpp b/source/plugin.cpp index d746ecaa..dd5984c5 100644 --- a/source/plugin.cpp +++ b/source/plugin.cpp @@ -20,15 +20,15 @@ #include "plugin.hpp" #include "obs/obs-source-tracker.hpp" -std::list> initializerFunctions; -std::list> finalizerFunctions; +std::list> initializer_functions; +std::list> finalizer_functions; MODULE_EXPORT bool obs_module_load(void) { P_LOG_INFO("Loading Version %u.%u.%u (Build %u)", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH, PROJECT_VERSION_TWEAK); obs::source_tracker::initialize(); - for (auto func : initializerFunctions) { + for (auto func : initializer_functions) { func(); } return true; @@ -38,7 +38,7 @@ MODULE_EXPORT void obs_module_unload(void) { P_LOG_INFO("Unloading Version %u.%u.%u (Build %u)", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH, PROJECT_VERSION_TWEAK); - for (auto func : finalizerFunctions) { + for (auto func : finalizer_functions) { func(); } obs::source_tracker::finalize(); diff --git a/source/plugin.hpp b/source/plugin.hpp index f3e38a5f..bb96ff46 100644 --- a/source/plugin.hpp +++ b/source/plugin.hpp @@ -44,5 +44,5 @@ #define P_LOG_DEBUG(...) P_LOG(LOG_DEBUG, __VA_ARGS__) // Initializer & Finalizer -extern std::list> initializerFunctions; -extern std::list> finalizerFunctions; +extern std::list> initializer_functions; +extern std::list> finalizer_functions; diff --git a/source/sources/source-mirror.cpp b/source/sources/source-mirror.cpp index 2af82022..fad772de 100644 --- a/source/sources/source-mirror.cpp +++ b/source/sources/source-mirror.cpp @@ -38,33 +38,33 @@ #pragma warning(pop) #endif -#define S_SOURCE_MIRROR "Source.Mirror" -#define P_SOURCE "Source.Mirror.Source" -#define P_SOURCE_SIZE "Source.Mirror.Source.Size" -#define P_SOURCE_AUDIO "Source.Mirror.Source.Audio" -#define ST_AUDIO_LAYOUT S_SOURCE_MIRROR ".Audio.Layout" +#define ST "Source.Mirror" +#define ST_SOURCE "Source.Mirror.Source" +#define ST_SOURCE_SIZE "Source.Mirror.Source.Size" +#define ST_AUDIO "Source.Mirror.Source.Audio" +#define ST_AUDIO_LAYOUT ST ".Audio.Layout" #define ST_AUDIO_LAYOUT_(x) ST_AUDIO_LAYOUT "." D_VSTR(x) -#define P_SCALING "Source.Mirror.Scaling" -#define P_SCALING_METHOD "Source.Mirror.Scaling.Method" -#define P_SCALING_METHOD_POINT "Source.Mirror.Scaling.Method.Point" -#define P_SCALING_METHOD_BILINEAR "Source.Mirror.Scaling.Method.Bilinear" -#define P_SCALING_METHOD_BICUBIC "Source.Mirror.Scaling.Method.Bicubic" -#define P_SCALING_METHOD_LANCZOS "Source.Mirror.Scaling.Method.Lanczos" -#define P_SCALING_SIZE "Source.Mirror.Scaling.Size" -#define P_SCALING_TRANSFORMKEEPORIGINAL "Source.Mirror.Scaling.TransformKeepOriginal" -#define P_SCALING_BOUNDS "Source.Mirror.Scaling.Bounds" -#define P_SCALING_BOUNDS_STRETCH "Source.Mirror.Scaling.Bounds.Stretch" -#define P_SCALING_BOUNDS_FIT "Source.Mirror.Scaling.Bounds.Fit" -#define P_SCALING_BOUNDS_FILL "Source.Mirror.Scaling.Bounds.Fill" -#define P_SCALING_BOUNDS_FILLWIDTH "Source.Mirror.Scaling.Bounds.FillWidth" -#define P_SCALING_BOUNDS_FILLHEIGHT "Source.Mirror.Scaling.Bounds.FillHeight" -#define P_SCALING_ALIGNMENT "Source.Mirror.Scaling.Alignment" +#define ST_SCALING "Source.Mirror.Scaling" +#define ST_SCALING_METHOD "Source.Mirror.Scaling.Method" +#define ST_SCALING_METHOD_POINT "Source.Mirror.Scaling.Method.Point" +#define ST_SCALING_METHOD_BILINEAR "Source.Mirror.Scaling.Method.Bilinear" +#define ST_SCALING_METHOD_BICUBIC "Source.Mirror.Scaling.Method.Bicubic" +#define ST_SCALING_METHOD_LANCZOS "Source.Mirror.Scaling.Method.Lanczos" +#define ST_SCALING_SIZE "Source.Mirror.Scaling.Size" +#define ST_SCALING_TRANSFORMKEEPORIGINAL "Source.Mirror.Scaling.TransformKeepOriginal" +#define ST_SCALING_BOUNDS "Source.Mirror.Scaling.Bounds" +#define ST_SCALING_BOUNDS_STRETCH "Source.Mirror.Scaling.Bounds.Stretch" +#define ST_SCALING_BOUNDS_FIT "Source.Mirror.Scaling.Bounds.Fit" +#define ST_SCALING_BOUNDS_FILL "Source.Mirror.Scaling.Bounds.Fill" +#define ST_SCALING_BOUNDS_FILLWIDTH "Source.Mirror.Scaling.Bounds.FillWidth" +#define ST_SCALING_BOUNDS_FILLHEIGHT "Source.Mirror.Scaling.Bounds.FillHeight" +#define ST_SCALING_ALIGNMENT "Source.Mirror.Scaling.Alignment" // Initializer & Finalizer -INITIALIZER(SourceMirrorInit) +P_INITIALIZER(SourceMirrorInit) { - initializerFunctions.push_back([] { source::mirror::mirror_factory::initialize(); }); - finalizerFunctions.push_back([] { source::mirror::mirror_factory::finalize(); }); + initializer_functions.push_back([] { source::mirror::mirror_factory::initialize(); }); + finalizer_functions.push_back([] { source::mirror::mirror_factory::finalize(); }); } static std::shared_ptr factory_instance = nullptr; @@ -86,101 +86,101 @@ std::shared_ptr source::mirror::mirror_factory:: source::mirror::mirror_factory::mirror_factory() { - memset(&osi, 0, sizeof(obs_source_info)); - osi.id = "obs-stream-effects-source-mirror"; - osi.type = OBS_SOURCE_TYPE_INPUT; - osi.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_AUDIO | OBS_SOURCE_CUSTOM_DRAW; + memset(&_source_info, 0, sizeof(obs_source_info)); + _source_info.id = "obs-stream-effects-source-mirror"; + _source_info.type = OBS_SOURCE_TYPE_INPUT; + _source_info.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_AUDIO | OBS_SOURCE_CUSTOM_DRAW; - osi.get_name = get_name; - osi.get_defaults = get_defaults; - osi.get_properties = get_properties; - osi.get_width = get_width; - osi.get_height = get_height; - osi.create = create; - osi.destroy = destroy; - osi.update = update; - osi.activate = activate; - osi.deactivate = deactivate; - osi.video_tick = video_tick; - osi.video_render = video_render; - osi.enum_active_sources = enum_active_sources; - osi.load = load; - osi.save = save; + _source_info.get_name = get_name; + _source_info.get_defaults = get_defaults; + _source_info.get_properties = get_properties; + _source_info.get_width = get_width; + _source_info.get_height = get_height; + _source_info.create = create; + _source_info.destroy = destroy; + _source_info.update = update; + _source_info.activate = activate; + _source_info.deactivate = deactivate; + _source_info.video_tick = video_tick; + _source_info.video_render = video_render; + _source_info.enum_active_sources = enum_active_sources; + _source_info.load = load; + _source_info.save = save; - obs_register_source(&osi); + obs_register_source(&_source_info); } source::mirror::mirror_factory::~mirror_factory() {} const char* source::mirror::mirror_factory::get_name(void*) { - return P_TRANSLATE(S_SOURCE_MIRROR); + return D_TRANSLATE(ST); } void source::mirror::mirror_factory::get_defaults(obs_data_t* data) { - obs_data_set_default_string(data, P_SOURCE, ""); - obs_data_set_default_bool(data, P_SOURCE_AUDIO, false); + obs_data_set_default_string(data, ST_SOURCE, ""); + obs_data_set_default_bool(data, ST_AUDIO, false); obs_data_set_default_int(data, ST_AUDIO_LAYOUT, static_cast(SPEAKERS_UNKNOWN)); - obs_data_set_default_bool(data, P_SCALING, false); - obs_data_set_default_string(data, P_SCALING_SIZE, "100x100"); - obs_data_set_default_int(data, P_SCALING_METHOD, (int64_t)obs_scale_type::OBS_SCALE_BILINEAR); - obs_data_set_default_bool(data, P_SCALING_TRANSFORMKEEPORIGINAL, false); - obs_data_set_default_int(data, P_SCALING_BOUNDS, (int64_t)obs_bounds_type::OBS_BOUNDS_STRETCH); - obs_data_set_default_int(data, P_SCALING_ALIGNMENT, OBS_ALIGN_CENTER); + obs_data_set_default_bool(data, ST_SCALING, false); + obs_data_set_default_string(data, ST_SCALING_SIZE, "100x100"); + obs_data_set_default_int(data, ST_SCALING_METHOD, (int64_t)obs_scale_type::OBS_SCALE_BILINEAR); + obs_data_set_default_bool(data, ST_SCALING_TRANSFORMKEEPORIGINAL, false); + obs_data_set_default_int(data, ST_SCALING_BOUNDS, (int64_t)obs_bounds_type::OBS_BOUNDS_STRETCH); + obs_data_set_default_int(data, ST_SCALING_ALIGNMENT, OBS_ALIGN_CENTER); } bool source::mirror::mirror_factory::modified_properties(obs_properties_t* pr, obs_property_t* p, obs_data_t* data) { - if (obs_properties_get(pr, P_SOURCE) == p) { - obs_source_t* target = obs_get_source_by_name(obs_data_get_string(data, P_SOURCE)); + if (obs_properties_get(pr, ST_SOURCE) == p) { + obs_source_t* target = obs_get_source_by_name(obs_data_get_string(data, ST_SOURCE)); if (target) { std::vector buf(256); snprintf(buf.data(), buf.size(), "%" PRIu32 "x%" PRIu32, obs_source_get_width(target), obs_source_get_height(target)); - obs_data_set_string(data, P_SOURCE_SIZE, buf.data()); + obs_data_set_string(data, ST_SOURCE_SIZE, buf.data()); } else { - obs_data_set_string(data, P_SOURCE_SIZE, "0x0"); + obs_data_set_string(data, ST_SOURCE_SIZE, "0x0"); } obs_source_release(target); } - if (obs_properties_get(pr, P_SOURCE_AUDIO) == p) { - bool show = obs_data_get_bool(data, P_SOURCE_AUDIO); + if (obs_properties_get(pr, ST_AUDIO) == p) { + bool show = obs_data_get_bool(data, ST_AUDIO); obs_property_set_visible(obs_properties_get(pr, ST_AUDIO_LAYOUT), show); return true; } - if (obs_properties_get(pr, P_SCALING) == p) { - bool show = obs_data_get_bool(data, P_SCALING); - obs_property_set_visible(obs_properties_get(pr, P_SCALING_METHOD), show); - obs_property_set_visible(obs_properties_get(pr, P_SCALING_SIZE), show); - obs_property_set_visible(obs_properties_get(pr, P_SCALING_BOUNDS), show); - obs_property_set_visible(obs_properties_get(pr, P_SCALING_ALIGNMENT), show); + if (obs_properties_get(pr, ST_SCALING) == p) { + bool show = obs_data_get_bool(data, ST_SCALING); + obs_property_set_visible(obs_properties_get(pr, ST_SCALING_METHOD), show); + obs_property_set_visible(obs_properties_get(pr, ST_SCALING_SIZE), show); + obs_property_set_visible(obs_properties_get(pr, ST_SCALING_BOUNDS), show); + obs_property_set_visible(obs_properties_get(pr, ST_SCALING_ALIGNMENT), show); return true; } - if (obs_properties_get(pr, P_SCALING_BOUNDS) == p) { - obs_bounds_type scaling_type = static_cast(obs_data_get_int(data, P_SCALING_BOUNDS)); - obs_property_t* p2 = obs_properties_get(pr, P_SCALING_BOUNDS); + if (obs_properties_get(pr, ST_SCALING_BOUNDS) == p) { + obs_bounds_type scaling_type = static_cast(obs_data_get_int(data, ST_SCALING_BOUNDS)); + obs_property_t* p2 = obs_properties_get(pr, ST_SCALING_BOUNDS); switch (scaling_type) { case obs_bounds_type::OBS_BOUNDS_STRETCH: - obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_STRETCH))); + obs_property_set_long_description(p2, D_TRANSLATE(D_DESC(ST_SCALING_BOUNDS_STRETCH))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_INNER: - obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FIT))); + obs_property_set_long_description(p2, D_TRANSLATE(D_DESC(ST_SCALING_BOUNDS_FIT))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_OUTER: - obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILL))); + obs_property_set_long_description(p2, D_TRANSLATE(D_DESC(ST_SCALING_BOUNDS_FILL))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_TO_WIDTH: - obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILLWIDTH))); + obs_property_set_long_description(p2, D_TRANSLATE(D_DESC(ST_SCALING_BOUNDS_FILLWIDTH))); break; case obs_bounds_type::OBS_BOUNDS_SCALE_TO_HEIGHT: - obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS_FILLHEIGHT))); + obs_property_set_long_description(p2, D_TRANSLATE(D_DESC(ST_SCALING_BOUNDS_FILLHEIGHT))); break; default: - obs_property_set_long_description(p2, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS))); + obs_property_set_long_description(p2, D_TRANSLATE(D_DESC(ST_SCALING_BOUNDS))); break; } return true; @@ -194,8 +194,8 @@ obs_properties_t* source::mirror::mirror_factory::get_properties(void*) obs_properties_t* pr = obs_properties_create(); obs_property_t* p = nullptr; - p = obs_properties_add_list(pr, P_SOURCE, P_TRANSLATE(P_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SOURCE))); + p = obs_properties_add_list(pr, ST_SOURCE, D_TRANSLATE(ST_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SOURCE))); obs_property_set_modified_callback(p, modified_properties); obs_property_list_add_string(p, "", ""); obs::source_tracker::get()->enumerate( @@ -211,60 +211,60 @@ obs_properties_t* source::mirror::mirror_factory::get_properties(void*) }, obs::source_tracker::filter_scenes); - p = obs_properties_add_text(pr, P_SOURCE_SIZE, P_TRANSLATE(P_SOURCE_SIZE), OBS_TEXT_DEFAULT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SOURCE_SIZE))); + p = obs_properties_add_text(pr, ST_SOURCE_SIZE, D_TRANSLATE(ST_SOURCE_SIZE), OBS_TEXT_DEFAULT); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SOURCE_SIZE))); obs_property_set_enabled(p, false); - p = obs_properties_add_bool(pr, P_SOURCE_AUDIO, P_TRANSLATE(P_SOURCE_AUDIO)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SOURCE_AUDIO))); + p = obs_properties_add_bool(pr, ST_AUDIO, D_TRANSLATE(ST_AUDIO)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_AUDIO))); obs_property_set_modified_callback(p, modified_properties); - p = obs_properties_add_list(pr, ST_AUDIO_LAYOUT, P_TRANSLATE(ST_AUDIO_LAYOUT), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_AUDIO_LAYOUT, D_TRANSLATE(ST_AUDIO_LAYOUT), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Unknown)), static_cast(SPEAKERS_UNKNOWN)); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Mono)), static_cast(SPEAKERS_MONO)); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Stereo)), static_cast(SPEAKERS_STEREO)); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(StereoLFE)), static_cast(SPEAKERS_2POINT1)); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Quadraphonic)), static_cast(SPEAKERS_4POINT0)); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(QuadraphonicLFE)), + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(Unknown)), static_cast(SPEAKERS_UNKNOWN)); + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(Mono)), static_cast(SPEAKERS_MONO)); + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(Stereo)), static_cast(SPEAKERS_STEREO)); + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(StereoLFE)), static_cast(SPEAKERS_2POINT1)); + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(Quadraphonic)), static_cast(SPEAKERS_4POINT0)); + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(QuadraphonicLFE)), static_cast(SPEAKERS_4POINT1)); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Surround)), static_cast(SPEAKERS_5POINT1)); - obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(FullSurround)), static_cast(SPEAKERS_7POINT1)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_AUDIO_LAYOUT))); + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(Surround)), static_cast(SPEAKERS_5POINT1)); + obs_property_list_add_int(p, D_TRANSLATE(ST_AUDIO_LAYOUT_(FullSurround)), static_cast(SPEAKERS_7POINT1)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_AUDIO_LAYOUT))); - p = obs_properties_add_bool(pr, P_SCALING, P_TRANSLATE(P_SCALING)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING))); + p = obs_properties_add_bool(pr, ST_SCALING, D_TRANSLATE(ST_SCALING)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SCALING))); obs_property_set_modified_callback(p, modified_properties); - p = obs_properties_add_list(pr, P_SCALING_METHOD, P_TRANSLATE(P_SCALING_METHOD), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_SCALING_METHOD, D_TRANSLATE(ST_SCALING_METHOD), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_METHOD))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SCALING_METHOD))); obs_property_set_modified_callback(p, modified_properties); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_POINT), (int64_t)obs_scale_type::OBS_SCALE_POINT); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_BILINEAR), (int64_t)obs_scale_type::OBS_SCALE_BILINEAR); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_BICUBIC), (int64_t)obs_scale_type::OBS_SCALE_BICUBIC); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_LANCZOS), (int64_t)obs_scale_type::OBS_SCALE_LANCZOS); + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_METHOD_POINT), (int64_t)obs_scale_type::OBS_SCALE_POINT); + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_METHOD_BILINEAR), (int64_t)obs_scale_type::OBS_SCALE_BILINEAR); + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_METHOD_BICUBIC), (int64_t)obs_scale_type::OBS_SCALE_BICUBIC); + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_METHOD_LANCZOS), (int64_t)obs_scale_type::OBS_SCALE_LANCZOS); - p = obs_properties_add_text(pr, P_SCALING_SIZE, P_TRANSLATE(P_SCALING_SIZE), OBS_TEXT_DEFAULT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_SIZE))); + p = obs_properties_add_text(pr, ST_SCALING_SIZE, D_TRANSLATE(ST_SCALING_SIZE), OBS_TEXT_DEFAULT); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SCALING_SIZE))); - p = obs_properties_add_bool(pr, P_SCALING_TRANSFORMKEEPORIGINAL, P_TRANSLATE(P_SCALING_TRANSFORMKEEPORIGINAL)); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_TRANSFORMKEEPORIGINAL))); + p = obs_properties_add_bool(pr, ST_SCALING_TRANSFORMKEEPORIGINAL, D_TRANSLATE(ST_SCALING_TRANSFORMKEEPORIGINAL)); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SCALING_TRANSFORMKEEPORIGINAL))); - p = obs_properties_add_list(pr, P_SCALING_BOUNDS, P_TRANSLATE(P_SCALING_BOUNDS), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_SCALING_BOUNDS, D_TRANSLATE(ST_SCALING_BOUNDS), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SCALING_BOUNDS))); obs_property_set_modified_callback(p, modified_properties); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_STRETCH), (int64_t)obs_bounds_type::OBS_BOUNDS_STRETCH); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FIT), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_INNER); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FILL), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_OUTER); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FILLWIDTH), + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_BOUNDS_STRETCH), (int64_t)obs_bounds_type::OBS_BOUNDS_STRETCH); + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_BOUNDS_FIT), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_INNER); + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_BOUNDS_FILL), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_OUTER); + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_BOUNDS_FILLWIDTH), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_TO_WIDTH); - obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FILLHEIGHT), + obs_property_list_add_int(p, D_TRANSLATE(ST_SCALING_BOUNDS_FILLHEIGHT), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_TO_HEIGHT); - p = obs_properties_add_list(pr, P_SCALING_ALIGNMENT, P_TRANSLATE(P_SCALING_ALIGNMENT), OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(pr, ST_SCALING_ALIGNMENT, D_TRANSLATE(ST_SCALING_ALIGNMENT), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_ALIGNMENT))); + obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SCALING_ALIGNMENT))); obs_property_list_add_int(p, obs_module_recursive_text("\\@" S_ALIGNMENT_LEFT "\\@ \\@" S_ALIGNMENT_TOP "\\@"), OBS_ALIGN_LEFT | OBS_ALIGN_TOP); obs_property_list_add_int(p, obs_module_recursive_text("\\@" S_ALIGNMENT_TOP "\\@"), OBS_ALIGN_TOP); @@ -369,11 +369,11 @@ void source::mirror::mirror_factory::save(void* p, obs_data_t* d) void source::mirror::mirror_instance::release_input() { // Clear any references to the previous source. - if (this->m_source_item) { - obs_sceneitem_remove(this->m_source_item); - this->m_source_item = nullptr; + if (this->_source_item) { + obs_sceneitem_remove(this->_source_item); + this->_source_item = nullptr; } - this->m_source.reset(); + this->_source.reset(); } void source::mirror::mirror_instance::acquire_input(std::string source_name) @@ -383,14 +383,14 @@ void source::mirror::mirror_instance::acquire_input(std::string source_name) if (!ref_source) { // Early-Exit: Unable to find a source with this name, likely has been released. #ifdef _DEBUG - P_LOG_DEBUG(" Unable to find target source '%s'.", obs_source_get_name(this->m_self), + P_LOG_DEBUG(" Unable to find target source '%s'.", obs_source_get_name(this->_self), source_name.c_str()); #endif return; - } else if (ref_source == this->m_self) { + } else if (ref_source == this->_self) { // Early-Exit: Attempted self-mirror (recursion). #ifdef _DEBUG - P_LOG_DEBUG(" Attempted to mirror self.", obs_source_get_name(this->m_self)); + P_LOG_DEBUG(" Attempted to mirror _self.", obs_source_get_name(this->_self)); #endif obs_source_release(ref_source); return; @@ -399,41 +399,41 @@ void source::mirror::mirror_instance::acquire_input(std::string source_name) std::shared_ptr new_source = std::make_shared(ref_source, true, false); // It looks like everything is in order, so continue now. - this->m_source_item = obs_scene_add(obs_scene_from_source(this->m_scene->get()), new_source->get()); - if (!this->m_source_item) { + this->_source_item = obs_scene_add(obs_scene_from_source(this->_scene->get()), new_source->get()); + if (!this->_source_item) { // Late-Exit: OBS detected something bad, so no further action will be taken. #ifdef _DEBUG - P_LOG_DEBUG(" Attempted recursion with scene '%s'.", obs_source_get_name(this->m_self), + P_LOG_DEBUG(" Attempted recursion with scene '%s'.", obs_source_get_name(this->_self), source_name.c_str()); #endif return; } // If everything worked fine, we now set everything up. - this->m_source = new_source; - this->m_source->events.rename += std::bind(&source::mirror::mirror_instance::on_source_rename, this, + this->_source = new_source; + this->_source->events.rename += std::bind(&source::mirror::mirror_instance::on_source_rename, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); - if ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_AUDIO) != 0) { - this->m_source->events.audio_data += + if ((obs_source_get_output_flags(this->_source->get()) & OBS_SOURCE_AUDIO) != 0) { + this->_source->events.audio_data += std::bind(&source::mirror::mirror_instance::on_audio_data, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); } } source::mirror::mirror_instance::mirror_instance(obs_data_t*, obs_source_t* src) - : m_self(src), m_active(true), m_tick(0), m_scene_rendered(false), m_rescale_enabled(false), m_rescale_width(1), - m_rescale_height(1), m_rescale_keep_orig_size(false), m_rescale_type(obs_scale_type::OBS_SCALE_BICUBIC), - m_rescale_bounds(obs_bounds_type::OBS_BOUNDS_STRETCH), m_audio_enabled(false), m_audio_kill_thread(false), - m_audio_have_output(false), m_source_item(nullptr) + : _self(src), _active(true), _tick(0), _scene_rendered(false), _rescale_enabled(false), _rescale_width(1), + _rescale_height(1), _rescale_keep_orig_size(false), _rescale_type(obs_scale_type::OBS_SCALE_BICUBIC), + _rescale_bounds(obs_bounds_type::OBS_BOUNDS_STRETCH), _audio_enabled(false), _audio_kill_thread(false), + _audio_have_output(false), _source_item(nullptr) { // Initialize Video Rendering - this->m_scene = + this->_scene = std::make_shared(obs_scene_get_source(obs_scene_create_private("Source Mirror Internal Scene"))); - this->m_scene_texture_renderer = - std::make_shared(this->m_scene, std::make_shared(this->m_self, false, false)); + this->_scene_texture_renderer = + std::make_shared(this->_scene, std::make_shared(this->_self, false, false)); // Initialize Audio Rendering - this->m_audio_thread = std::thread(std::bind(&source::mirror::mirror_instance::audio_output_cb, this)); + this->_audio_thread = std::thread(std::bind(&source::mirror::mirror_instance::audio_output_cb, this)); } source::mirror::mirror_instance::~mirror_instance() @@ -441,27 +441,27 @@ source::mirror::mirror_instance::~mirror_instance() release_input(); // Finalize Audio Rendering - this->m_audio_kill_thread = true; - this->m_audio_notify.notify_all(); - if (this->m_audio_thread.joinable()) { - this->m_audio_thread.join(); + this->_audio_kill_thread = true; + this->_audio_notify.notify_all(); + if (this->_audio_thread.joinable()) { + this->_audio_thread.join(); } // Finalize Video Rendering - this->m_scene_texture_renderer.reset(); - this->m_scene.reset(); + this->_scene_texture_renderer.reset(); + this->_scene.reset(); } uint32_t source::mirror::mirror_instance::get_width() { - if (m_source) { - if ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_VIDEO) == 0) { + if (_source) { + if ((obs_source_get_output_flags(this->_source->get()) & OBS_SOURCE_VIDEO) == 0) { return 0; } - if (this->m_rescale_enabled && this->m_rescale_width > 0 && !this->m_rescale_keep_orig_size) { - return this->m_rescale_width; + if (this->_rescale_enabled && this->_rescale_width > 0 && !this->_rescale_keep_orig_size) { + return this->_rescale_width; } else { - return m_source->width(); + return _source->width(); } } return 0; @@ -469,14 +469,14 @@ uint32_t source::mirror::mirror_instance::get_width() uint32_t source::mirror::mirror_instance::get_height() { - if (m_source) { - if ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_VIDEO) == 0) { + if (_source) { + if ((obs_source_get_output_flags(this->_source->get()) & OBS_SOURCE_VIDEO) == 0) { return 0; } - if (this->m_rescale_enabled && this->m_rescale_height > 0 && !this->m_rescale_keep_orig_size) { - return this->m_rescale_height; + if (this->_rescale_enabled && this->_rescale_height > 0 && !this->_rescale_keep_orig_size) { + return this->_rescale_height; } else { - return m_source->height(); + return _source->height(); } } return 0; @@ -486,84 +486,84 @@ void source::mirror::mirror_instance::update(obs_data_t* data) { { // User changed the source we are tracking. release_input(); - this->m_source_name = obs_data_get_string(data, P_SOURCE); - if (this->m_source_name.length() > 0) { - acquire_input(this->m_source_name); + this->_source_name = obs_data_get_string(data, ST_SOURCE); + if (this->_source_name.length() > 0) { + acquire_input(this->_source_name); } } // Audio - this->m_audio_enabled = obs_data_get_bool(data, P_SOURCE_AUDIO); - this->m_audio_layout = static_cast(obs_data_get_int(data, ST_AUDIO_LAYOUT)); + this->_audio_enabled = obs_data_get_bool(data, ST_AUDIO); + this->_audio_layout = static_cast(obs_data_get_int(data, ST_AUDIO_LAYOUT)); // Rescaling - this->m_rescale_enabled = obs_data_get_bool(data, P_SCALING); - if (this->m_rescale_enabled) { // Parse rescaling settings. + this->_rescale_enabled = obs_data_get_bool(data, ST_SCALING); + if (this->_rescale_enabled) { // Parse rescaling settings. uint32_t width, height; // Read value. - const char* size = obs_data_get_string(data, P_SCALING_SIZE); + const char* size = obs_data_get_string(data, ST_SCALING_SIZE); const char* xpos = strchr(size, 'x'); if (xpos != nullptr) { // Width width = strtoul(size, nullptr, 10); if (errno == ERANGE || width == 0) { - this->m_rescale_enabled = false; - this->m_rescale_width = 1; + this->_rescale_enabled = false; + this->_rescale_width = 1; } else { - this->m_rescale_width = width; + this->_rescale_width = width; } height = strtoul(xpos + 1, nullptr, 10); if (errno == ERANGE || height == 0) { - this->m_rescale_enabled = false; - this->m_rescale_height = 1; + this->_rescale_enabled = false; + this->_rescale_height = 1; } else { - this->m_rescale_height = height; + this->_rescale_height = height; } } else { - this->m_rescale_enabled = false; - this->m_rescale_width = 1; - this->m_rescale_height = 1; + this->_rescale_enabled = false; + this->_rescale_width = 1; + this->_rescale_height = 1; } - this->m_rescale_keep_orig_size = obs_data_get_bool(data, P_SCALING_TRANSFORMKEEPORIGINAL); - this->m_rescale_type = static_cast(obs_data_get_int(data, P_SCALING_METHOD)); - this->m_rescale_bounds = static_cast(obs_data_get_int(data, P_SCALING_BOUNDS)); - this->m_rescale_alignment = static_cast(obs_data_get_int(data, P_SCALING_ALIGNMENT)); + this->_rescale_keep_orig_size = obs_data_get_bool(data, ST_SCALING_TRANSFORMKEEPORIGINAL); + this->_rescale_type = static_cast(obs_data_get_int(data, ST_SCALING_METHOD)); + this->_rescale_bounds = static_cast(obs_data_get_int(data, ST_SCALING_BOUNDS)); + this->_rescale_alignment = static_cast(obs_data_get_int(data, ST_SCALING_ALIGNMENT)); } } void source::mirror::mirror_instance::activate() { - this->m_active = true; + this->_active = true; // No source, delayed acquire. - if (!this->m_source_item && this->m_source_name.length() > 0) { - this->acquire_input(this->m_source_name.c_str()); + if (!this->_source_item && this->_source_name.length() > 0) { + this->acquire_input(this->_source_name.c_str()); } } void source::mirror::mirror_instance::deactivate() { - this->m_active = false; + this->_active = false; } void source::mirror::mirror_instance::video_tick(float time) { - this->m_tick += time; - if (this->m_tick > 0.1f) { - this->m_tick -= 0.1f; + this->_tick += time; + if (this->_tick > 0.1f) { + this->_tick -= 0.1f; // No source, delayed acquire. - if (!this->m_source_item && this->m_source_name.length() > 0) { - this->acquire_input(this->m_source_name.c_str()); + if (!this->_source_item && this->_source_name.length() > 0) { + this->acquire_input(this->_source_name.c_str()); } } // Update Scene Item Boundaries - if ((this->m_source_item && this->m_source) - && ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_VIDEO) != 0)) { + if ((this->_source_item && this->_source) + && ((obs_source_get_output_flags(this->_source->get()) & OBS_SOURCE_VIDEO) != 0)) { obs_transform_info info; info.pos.x = 0; info.pos.y = 0; @@ -573,40 +573,40 @@ void source::mirror::mirror_instance::video_tick(float time) info.alignment = OBS_ALIGN_LEFT | OBS_ALIGN_TOP; info.bounds.x = float_t(this->get_width()); info.bounds.y = float_t(this->get_height()); - info.bounds_alignment = m_rescale_alignment; + info.bounds_alignment = _rescale_alignment; info.bounds_type = obs_bounds_type::OBS_BOUNDS_STRETCH; - if (this->m_rescale_enabled) { - info.bounds_type = this->m_rescale_bounds; + if (this->_rescale_enabled) { + info.bounds_type = this->_rescale_bounds; } - obs_sceneitem_set_info(this->m_source_item, &info); - obs_sceneitem_force_update_transform(this->m_source_item); - obs_sceneitem_set_scale_filter(this->m_source_item, this->m_rescale_enabled ? this->m_rescale_type + obs_sceneitem_set_info(this->_source_item, &info); + obs_sceneitem_force_update_transform(this->_source_item); + obs_sceneitem_set_scale_filter(this->_source_item, this->_rescale_enabled ? this->_rescale_type : obs_scale_type::OBS_SCALE_POINT); } - m_scene_rendered = false; + _scene_rendered = false; } void source::mirror::mirror_instance::video_render(gs_effect_t* effect) { - if ((this->m_rescale_width == 0) || (this->m_rescale_height == 0) || !this->m_source_item - || !this->m_scene_texture_renderer || !this->m_source) { + if ((this->_rescale_width == 0) || (this->_rescale_height == 0) || !this->_source_item + || !this->_scene_texture_renderer || !this->_source) { return; } // Don't bother rendering sources that aren't video. - if ((obs_source_get_output_flags(this->m_source->get()) & OBS_SOURCE_VIDEO) == 0) { + if ((obs_source_get_output_flags(this->_source->get()) & OBS_SOURCE_VIDEO) == 0) { return; } // Only re-render the scene if there was a video_tick, saves GPU cycles. - if (!m_scene_rendered) { + if (!_scene_rendered) { // Override render size if rescaling is enabled. - uint32_t render_width = this->m_source->width(); - uint32_t render_height = this->m_source->height(); - if (m_rescale_enabled) { - render_width = m_rescale_width; - render_height = m_rescale_height; + uint32_t render_width = this->_source->width(); + uint32_t render_height = this->_source->height(); + if (_rescale_enabled) { + render_width = _rescale_width; + render_height = _rescale_height; } if (!render_width || !render_height) { @@ -615,56 +615,56 @@ void source::mirror::mirror_instance::video_render(gs_effect_t* effect) } try { - m_scene_texture = this->m_scene_texture_renderer->render(render_width, render_height); - m_scene_rendered = true; + _scene_texture = this->_scene_texture_renderer->render(render_width, render_height); + _scene_rendered = true; } catch (...) { // If we fail to render the source, just render nothing. return; } } - if (m_scene_texture) { + if (_scene_texture) { // Use default effect unless we are provided a different effect. if (!effect) { effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); } // Render the cached scene texture. - gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), m_scene_texture->get_object()); + gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), _scene_texture->get_object()); while (gs_effect_loop(effect, "Draw")) { - gs_draw_sprite(m_scene_texture->get_object(), 0, this->get_width(), this->get_height()); + gs_draw_sprite(_scene_texture->get_object(), 0, this->get_width(), this->get_height()); } } } void source::mirror::mirror_instance::audio_output_cb() { - std::unique_lock ulock(this->m_audio_lock_outputter); + std::unique_lock ulock(this->_audio_lock_outputter); - while (!this->m_audio_kill_thread) { - this->m_audio_notify.wait(ulock, [this]() { return this->m_audio_have_output || this->m_audio_kill_thread; }); + while (!this->_audio_kill_thread) { + this->_audio_notify.wait(ulock, [this]() { return this->_audio_have_output || this->_audio_kill_thread; }); - if (this->m_audio_have_output) { // Get used audio element + if (this->_audio_have_output) { // Get used audio element std::shared_ptr mad; { - std::lock_guard capture_lock(this->m_audio_lock_capturer); - if (m_audio_data_queue.size() > 0) { - mad = m_audio_data_queue.front(); - m_audio_data_queue.pop(); + std::lock_guard capture_lock(this->_audio_lock_capturer); + if (_audio_data_queue.size() > 0) { + mad = _audio_data_queue.front(); + _audio_data_queue.pop(); } - if (m_audio_data_queue.size() == 0) { - this->m_audio_have_output = false; + if (_audio_data_queue.size() == 0) { + this->_audio_have_output = false; } } if (mad) { ulock.unlock(); - obs_source_output_audio(this->m_self, &mad->audio); + obs_source_output_audio(this->_self, &mad->audio); ulock.lock(); { - std::lock_guard capture_lock(this->m_audio_lock_capturer); - m_audio_data_free_queue.push(mad); + std::lock_guard capture_lock(this->_audio_lock_capturer); + _audio_data_free_queue.push(mad); } } } @@ -673,8 +673,8 @@ void source::mirror::mirror_instance::audio_output_cb() void source::mirror::mirror_instance::enum_active_sources(obs_source_enum_proc_t enum_callback, void* param) { - if (this->m_scene) { - enum_callback(this->m_self, this->m_scene->get(), param); + if (this->_scene) { + enum_callback(this->_self, this->_scene->get(), param); } } @@ -685,23 +685,23 @@ void source::mirror::mirror_instance::load(obs_data_t* data) void source::mirror::mirror_instance::save(obs_data_t* data) { - if (!this->m_source_item || !this->m_source) { + if (!this->_source_item || !this->_source) { return; } - obs_data_set_string(data, P_SOURCE, obs_source_get_name(m_source->get())); + obs_data_set_string(data, ST_SOURCE, obs_source_get_name(_source->get())); } void source::mirror::mirror_instance::on_source_rename(obs::source* source, std::string, std::string) { - obs_data_t* ref = obs_source_get_settings(this->m_self); - obs_data_set_string(ref, P_SOURCE, obs_source_get_name(source->get())); - obs_source_update(this->m_self, ref); + obs_data_t* ref = obs_source_get_settings(this->_self); + obs_data_set_string(ref, ST_SOURCE, obs_source_get_name(source->get())); + obs_source_update(this->_self, ref); obs_data_release(ref); } void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_data* audio, bool) { - if (!this->m_audio_enabled) { + if (!this->_audio_enabled) { return; } @@ -716,10 +716,10 @@ void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_da std::shared_ptr mad; { // Get free audio data element. - std::lock_guard capture_lock(this->m_audio_lock_capturer); - if (m_audio_data_free_queue.size() > 0) { - mad = m_audio_data_free_queue.front(); - m_audio_data_free_queue.pop(); + std::lock_guard capture_lock(this->_audio_lock_capturer); + if (_audio_data_free_queue.size() > 0) { + mad = _audio_data_free_queue.front(); + _audio_data_free_queue.pop(); } else { mad = std::make_shared(); mad->data.resize(MAX_AUDIO_CHANNELS); @@ -746,21 +746,21 @@ void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_da mad->audio.frames = audio->frames; mad->audio.timestamp = audio->timestamp; mad->audio.samples_per_sec = aoi->samples_per_sec; - if (this->m_audio_layout != SPEAKERS_UNKNOWN) { - mad->audio.speakers = this->m_audio_layout; + if (this->_audio_layout != SPEAKERS_UNKNOWN) { + mad->audio.speakers = this->_audio_layout; } else { mad->audio.speakers = aoi->speakers; } } { // Push used audio data element. - std::lock_guard capture_lock(this->m_audio_lock_capturer); - m_audio_data_queue.push(mad); + std::lock_guard capture_lock(this->_audio_lock_capturer); + _audio_data_queue.push(mad); } { // Signal other side. - std::lock_guard output_lock(this->m_audio_lock_outputter); - this->m_audio_have_output = true; + std::lock_guard output_lock(this->_audio_lock_outputter); + this->_audio_have_output = true; } - this->m_audio_notify.notify_all(); + this->_audio_notify.notify_all(); } diff --git a/source/sources/source-mirror.hpp b/source/sources/source-mirror.hpp index 14160124..9b861e8f 100644 --- a/source/sources/source-mirror.hpp +++ b/source/sources/source-mirror.hpp @@ -43,7 +43,7 @@ namespace source { namespace mirror { class mirror_factory { - obs_source_info osi; + obs_source_info _source_info; public: // Singleton static void initialize(); @@ -81,41 +81,41 @@ namespace source { }; class mirror_instance { - obs_source_t* m_self; - bool m_active; - float_t m_tick; + obs_source_t* _self; + bool _active; + float_t _tick; // Video Rendering - std::shared_ptr m_scene; - std::shared_ptr m_scene_texture_renderer; - std::shared_ptr m_scene_texture; - bool m_scene_rendered; - int m_rescale_alignment; + std::shared_ptr _scene; + std::shared_ptr _scene_texture_renderer; + std::shared_ptr _scene_texture; + bool _scene_rendered; + int _rescale_alignment; // Rescaling - bool m_rescale_enabled; - uint32_t m_rescale_width; - uint32_t m_rescale_height; - bool m_rescale_keep_orig_size; - obs_scale_type m_rescale_type; - obs_bounds_type m_rescale_bounds; + bool _rescale_enabled; + uint32_t _rescale_width; + uint32_t _rescale_height; + bool _rescale_keep_orig_size; + obs_scale_type _rescale_type; + obs_bounds_type _rescale_bounds; // Audio Rendering - bool m_audio_enabled; - std::condition_variable m_audio_notify; - std::thread m_audio_thread; - bool m_audio_kill_thread; - bool m_audio_have_output; - std::mutex m_audio_lock_outputter; - std::mutex m_audio_lock_capturer; - std::queue> m_audio_data_queue; - std::queue> m_audio_data_free_queue; - speaker_layout m_audio_layout; + bool _audio_enabled; + std::condition_variable _audio_notify; + std::thread _audio_thread; + bool _audio_kill_thread; + bool _audio_have_output; + std::mutex _audio_lock_outputter; + std::mutex _audio_lock_capturer; + std::queue> _audio_data_queue; + std::queue> _audio_data_free_queue; + speaker_layout _audio_layout; // Input - std::shared_ptr m_source; - obs_sceneitem_t* m_source_item; - std::string m_source_name; + std::shared_ptr _source; + obs_sceneitem_t* _source_item; + std::string _source_name; private: void release_input(); diff --git a/source/strings.hpp b/source/strings.hpp index ed9ca98f..a8316b5a 100644 --- a/source/strings.hpp +++ b/source/strings.hpp @@ -20,14 +20,14 @@ #pragma once #include "plugin.hpp" -#define P_TRANSLATE(x) obs_module_text(x) -#define P_DESC(x) x ".Description" +#define D_TRANSLATE(x) obs_module_text(x) +#define D_DESC(x) x ".Description" -#define T_FILEFILTERS_IMAGE "*.png *.webp *.tga *.tiff *.jpeg *.jpg *.bmp" -#define T_FILEFILTERS_VIDEO "*.mkv *.webm *.mp4 *.mov *.flv" -#define T_FILEFILTERS_SOUND "*.ogg *.flac *.mp3 *.wav" -#define T_FILEFILTERS_EFFECT "*.effect *.txt" -#define T_FILEFILTERS_ANY "*.*" +#define S_FILEFILTERS_IMAGE "*.png *.webp *.tga *.tiff *.jpeg *.jpg *.bmp" +#define S_FILEFILTERS_VIDEO "*.mkv *.webm *.mp4 *.mov *.flv" +#define S_FILEFILTERS_SOUND "*.ogg *.flac *.mp3 *.wav" +#define S_FILEFILTERS_EFFECT "*.effect *.txt" +#define S_FILEFILTERS_ANY "*.*" #define S_VERSION "Version" diff --git a/source/util-math.hpp b/source/util-math.hpp index caaa81ca..650e4151 100644 --- a/source/util-math.hpp +++ b/source/util-math.hpp @@ -36,14 +36,14 @@ #endif // Constants -#define PI 3.1415926535897932384626433832795 // PI = pi -#define PI2 6.283185307179586476925286766559 // 2PI = 2 * pi -#define PI2_SQROOT 2.506628274631000502415765284811 // sqrt(2 * pi) +#define S_PI 3.1415926535897932384626433832795 // PI = pi +#define S_PI2 6.283185307179586476925286766559 // 2PI = 2 * pi +#define S_PI2_SQROOT 2.506628274631000502415765284811 // sqrt(2 * pi) -#define V_RAD 57.295779513082320876798154814105 // 180/pi -#define V_DEG 0.01745329251994329576923690768489 // pi/180 -#define DEG_TO_RAD(x) (x * V_DEG) -#define RAD_TO_DEG(x) (x * V_RAD) +#define S_RAD 57.295779513082320876798154814105 // 180/pi +#define S_DEG 0.01745329251994329576923690768489 // pi/180 +#define D_DEG_TO_RAD(x) (x * S_DEG) +#define D_RAD_TO_DEG(x) (x * S_RAD) inline size_t GetNearestPowerOfTwoAbove(size_t v) { @@ -114,23 +114,23 @@ namespace util { return true; } -#pragma push_macro("is_power_of_two_as_loop") -#define is_power_of_two_as_loop(x) \ +#pragma push_macro("P_IS_POWER_OF_TWO_AS_LOOP") +#define P_IS_POWER_OF_TWO_AS_LOOP(x) \ template<> \ inline bool is_power_of_two(x v) \ { \ return is_power_of_two_loop(v); \ } - is_power_of_two_as_loop(int8_t); - is_power_of_two_as_loop(uint8_t); - is_power_of_two_as_loop(int16_t); - is_power_of_two_as_loop(uint16_t); - is_power_of_two_as_loop(int32_t); - is_power_of_two_as_loop(uint32_t); - is_power_of_two_as_loop(int64_t); - is_power_of_two_as_loop(uint64_t); -#undef is_power_of_two_as_loop -#pragma pop_macro("is_power_of_two_as_loop") + P_IS_POWER_OF_TWO_AS_LOOP(int8_t); + P_IS_POWER_OF_TWO_AS_LOOP(uint8_t); + P_IS_POWER_OF_TWO_AS_LOOP(int16_t); + P_IS_POWER_OF_TWO_AS_LOOP(uint16_t); + P_IS_POWER_OF_TWO_AS_LOOP(int32_t); + P_IS_POWER_OF_TWO_AS_LOOP(uint32_t); + P_IS_POWER_OF_TWO_AS_LOOP(int64_t); + P_IS_POWER_OF_TWO_AS_LOOP(uint64_t); +#undef P_IS_POWER_OF_TWO_AS_LOOP +#pragma pop_macro("P_IS_POWER_OF_TWO_AS_LOOP") template inline uint64_t get_power_of_two_exponent_floor(T v) diff --git a/source/util-memory.cpp b/source/util-memory.cpp index c155e612..a311a123 100644 --- a/source/util-memory.cpp +++ b/source/util-memory.cpp @@ -22,10 +22,18 @@ #define USE_STD_ALLOC_FREE +#ifdef _MSC_VER +#define D_ALIGNED_ALLOC(a, s) _aligned_malloc(s, a) +#define D_ALIGNED_FREE _aligned_free +#else +#define D_ALIGNED_ALLOC(a, s) aligned_alloc(s, a) +#define D_ALIGNED_FREE free +#endif + void* util::malloc_aligned(size_t align, size_t size) { #ifdef USE_STD_ALLOC_FREE - return aligned_alloc(align, size); + return D_ALIGNED_ALLOC(align, size); #else // Ensure that we have space for the pointer and the data. size_t asize = aligned_offset(align, size + (sizeof(void*) * 2)); @@ -47,7 +55,7 @@ void* util::malloc_aligned(size_t align, size_t size) void util::free_aligned(void* mem) { #ifdef USE_STD_ALLOC_FREE - aligned_free(mem); + D_ALIGNED_FREE(mem); #else void* ptr = reinterpret_cast(*reinterpret_cast(static_cast(mem) - sizeof(void*))); free(ptr); diff --git a/source/utility.hpp b/source/utility.hpp index 0d1531c5..a17b027a 100644 --- a/source/utility.hpp +++ b/source/utility.hpp @@ -48,7 +48,7 @@ typename std::enable_if::enable, Enum>::type oper return static_cast(static_cast(lhs) & static_cast(rhs)); } -#define ENABLE_BITMASK_OPERATORS(x) \ +#define P_ENABLE_BITMASK_OPERATORS(x) \ template<> \ struct enable_bitmask_operators { \ static const bool enable = true; \ @@ -58,7 +58,7 @@ typename std::enable_if::enable, Enum>::type oper #define D_VSTR(s) D_STR(s) #ifdef __cplusplus -#define INITIALIZER(f) \ +#define P_INITIALIZER(f) \ static void f(void); \ struct f##_t_ { \ f##_t_(void) \ @@ -75,12 +75,12 @@ typename std::enable_if::enable, Enum>::type oper __declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \ __pragma(comment(linker, "/include:" p #f "_")) static void f(void) #ifdef _WIN64 -#define INITIALIZER(f) INITIALIZER2_(f, "") +#define P_INITIALIZER(f) INITIALIZER2_(f, "") #else -#define INITIALIZER(f) INITIALIZER2_(f, "_") +#define P_INITIALIZER(f) INITIALIZER2_(f, "_") #endif #else -#define INITIALIZER(f) \ +#define P_INITIALIZER(f) \ static void f(void) __attribute__((constructor)); \ static void f(void) #endif