From be4d42312d635ef0acc188839e70a50152f4f7d2 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 19 Apr 2019 14:18:29 +0200 Subject: [PATCH] project: Fix all remaining portability issues Clang on Windows and Clang on Linux behave differently, and of course GCC on Windows (MinGW) and GCC on Linux do too. This is the point where using either compiler on either platform should successfully compile the project without any issues. Clang and GCC have a ton of warnings however, which definitely need to be fixed in the near future. Some of them are great warnings, like old C style casts, others are non-sense like suggest brackets. Fixes #47 Fixes #60 --- source/filters/filter-blur.cpp | 2 +- source/filters/filter-blur.hpp | 2 -- source/filters/filter-displacement.hpp | 2 -- source/filters/filter-sdf-effects.cpp | 22 ++++++++++---------- source/filters/filter-sdf-effects.hpp | 2 -- source/filters/filter-transform.hpp | 2 -- source/gfx/blur/gfx-blur-base.hpp | 9 ++++---- source/gfx/blur/gfx-blur-gaussian-linear.cpp | 8 +++---- source/gfx/blur/gfx-blur-gaussian.cpp | 12 +++++------ source/obs/obs-source-tracker.hpp | 4 +--- source/sources/source-mirror.hpp | 2 -- source/util-memory.hpp | 8 +++++-- 12 files changed, 34 insertions(+), 41 deletions(-) diff --git a/source/filters/filter-blur.cpp b/source/filters/filter-blur.cpp index 0f6e09df..44b408f3 100644 --- a/source/filters/filter-blur.cpp +++ b/source/filters/filter-blur.cpp @@ -947,7 +947,7 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect) std::string technique = ""; switch (this->m_mask.type) { case Region: - if (this->m_mask.region.feather > FLT_EPSILON) { + if (this->m_mask.region.feather > std::numeric_limits::epsilon()) { if (this->m_mask.region.invert) { technique = "RegionFeatherInverted"; } else { diff --git a/source/filters/filter-blur.hpp b/source/filters/filter-blur.hpp index fb86330d..37a546db 100644 --- a/source/filters/filter-blur.hpp +++ b/source/filters/filter-blur.hpp @@ -52,8 +52,6 @@ namespace filter { }; class blur_factory { - friend class std::_Ptr_base; - obs_source_info source_info; std::list sources; std::shared_ptr color_converter_effect; diff --git a/source/filters/filter-displacement.hpp b/source/filters/filter-displacement.hpp index 88311eaa..a5832fbd 100644 --- a/source/filters/filter-displacement.hpp +++ b/source/filters/filter-displacement.hpp @@ -43,8 +43,6 @@ namespace filter { namespace displacement { class displacement_factory { - friend class std::_Ptr_base; - obs_source_info sourceInfo; public: // Singleton diff --git a/source/filters/filter-sdf-effects.cpp b/source/filters/filter-sdf-effects.cpp index 8204f804..3238926c 100644 --- a/source/filters/filter-sdf-effects.cpp +++ b/source/filters/filter-sdf-effects.cpp @@ -482,7 +482,7 @@ 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) >= DBL_EPSILON); + obs_data_get_bool(data, P_SHADOW_OUTER) && (obs_data_get_double(data, P_SHADOW_OUTER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -505,7 +505,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) { this->m_inner_shadow = - obs_data_get_bool(data, P_SHADOW_INNER) && (obs_data_get_double(data, P_SHADOW_INNER_ALPHA) >= DBL_EPSILON); + obs_data_get_bool(data, P_SHADOW_INNER) && (obs_data_get_double(data, P_SHADOW_INNER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -528,7 +528,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) { this->m_outer_glow = - obs_data_get_bool(data, P_GLOW_OUTER) && (obs_data_get_double(data, P_GLOW_OUTER_ALPHA) >= DBL_EPSILON); + obs_data_get_bool(data, P_GLOW_OUTER) && (obs_data_get_double(data, P_GLOW_OUTER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -546,14 +546,14 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) 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 - FLT_EPSILON)) { - this->m_outer_glow_sharpness = 1.0f - FLT_EPSILON; + if (this->m_outer_glow_sharpness >= (1.0f - std::numeric_limits::epsilon())) { + this->m_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) >= DBL_EPSILON); + obs_data_get_bool(data, P_GLOW_INNER) && (obs_data_get_double(data, P_GLOW_INNER_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -571,14 +571,14 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) 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 - FLT_EPSILON)) { - this->m_inner_glow_sharpness = 1.0f - FLT_EPSILON; + if (this->m_inner_glow_sharpness >= (1.0f - std::numeric_limits::epsilon())) { + this->m_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) >= DBL_EPSILON); + obs_data_get_bool(data, P_OUTLINE) && (obs_data_get_double(data, P_OUTLINE_ALPHA) >= std::numeric_limits::epsilon()); { union { uint32_t color; @@ -597,8 +597,8 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data) 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 - FLT_EPSILON)) { - this->m_outline_sharpness = 1.0f - FLT_EPSILON; + if (this->m_outline_sharpness >= (1.0f - std::numeric_limits::epsilon())) { + this->m_outline_sharpness = 1.0f - std::numeric_limits::epsilon(); } } diff --git a/source/filters/filter-sdf-effects.hpp b/source/filters/filter-sdf-effects.hpp index d0c6fc54..6823ebc7 100644 --- a/source/filters/filter-sdf-effects.hpp +++ b/source/filters/filter-sdf-effects.hpp @@ -41,8 +41,6 @@ namespace filter { class sdf_effects_instance; class sdf_effects_factory { - friend class std::_Ptr_base; - obs_source_info source_info; std::list sources; diff --git a/source/filters/filter-transform.hpp b/source/filters/filter-transform.hpp index 510bb699..b3381a7c 100644 --- a/source/filters/filter-transform.hpp +++ b/source/filters/filter-transform.hpp @@ -29,8 +29,6 @@ namespace filter { namespace transform { class transform_factory { - friend class std::_Ptr_base; - obs_source_info sourceInfo; public: // Singleton diff --git a/source/gfx/blur/gfx-blur-base.hpp b/source/gfx/blur/gfx-blur-base.hpp index 95284cdf..4f107129 100644 --- a/source/gfx/blur/gfx-blur-base.hpp +++ b/source/gfx/blur/gfx-blur-base.hpp @@ -17,6 +17,7 @@ #pragma once #include +#include #include #include "obs/gs/gs-texture.hpp" @@ -32,7 +33,7 @@ namespace gfx { class ibase { public: - virtual ~ibase(){} + virtual ~ibase() {} virtual void set_input(std::shared_ptr<::gs::texture> texture) = 0; @@ -61,7 +62,7 @@ namespace gfx { class ibase_angle { public: - virtual ~ibase_angle(){} + virtual ~ibase_angle() {} virtual double_t get_angle() = 0; @@ -70,7 +71,7 @@ namespace gfx { class ibase_center { public: - virtual ~ibase_center(){} + virtual ~ibase_center() {} virtual void set_center(double_t x, double_t y) = 0; @@ -87,7 +88,7 @@ namespace gfx { class ifactory { public: - virtual ~ifactory(){} + virtual ~ifactory() {} virtual bool is_type_supported(::gfx::blur::type type) = 0; diff --git a/source/gfx/blur/gfx-blur-gaussian-linear.cpp b/source/gfx/blur/gfx-blur-gaussian-linear.cpp index 3e4f2bac..26351ccc 100644 --- a/source/gfx/blur/gfx-blur-gaussian-linear.cpp +++ b/source/gfx/blur/gfx-blur-gaussian-linear.cpp @@ -295,7 +295,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { return m_input_texture; } @@ -322,7 +322,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass - if (m_step_scale.first > DBL_EPSILON) { + if (m_step_scale.first > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); { @@ -338,7 +338,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render() } // Second Pass - if (m_step_scale.second > DBL_EPSILON) { + if (m_step_scale.second > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { @@ -388,7 +388,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear_directional::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { return m_input_texture; } diff --git a/source/gfx/blur/gfx-blur-gaussian.cpp b/source/gfx/blur/gfx-blur-gaussian.cpp index 16afa103..e842a5a5 100644 --- a/source/gfx/blur/gfx-blur-gaussian.cpp +++ b/source/gfx/blur/gfx-blur-gaussian.cpp @@ -302,7 +302,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { return m_input_texture; } @@ -329,7 +329,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE); // First Pass - if (m_step_scale.first > DBL_EPSILON) { + if (m_step_scale.first > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); { @@ -345,7 +345,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render() } // Second Pass - if (m_step_scale.second > DBL_EPSILON) { + if (m_step_scale.second > std::numeric_limits::epsilon()) { effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); { @@ -395,7 +395,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_directional::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { return m_input_texture; } @@ -450,7 +450,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_rotational::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { return m_input_texture; } @@ -527,7 +527,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_zoom::render() std::shared_ptr<::gs::effect> effect = m_data->get_effect(); auto kernel = m_data->get_kernel(size_t(m_size)); - if (!effect || ((m_step_scale.first + m_step_scale.second) < DBL_EPSILON)) { + if (!effect || ((m_step_scale.first + m_step_scale.second) < std::numeric_limits::epsilon())) { return m_input_texture; } diff --git a/source/obs/obs-source-tracker.hpp b/source/obs/obs-source-tracker.hpp index 8c07b684..c6e3f81a 100644 --- a/source/obs/obs-source-tracker.hpp +++ b/source/obs/obs-source-tracker.hpp @@ -34,8 +34,6 @@ namespace obs { class source_tracker { - friend class std::_Ref_count_obj; - std::map source_map; static void source_create_handler(void* ptr, calldata_t* data); @@ -46,7 +44,7 @@ namespace obs { static void finalize(); static std::shared_ptr get(); - private: + public: source_tracker(); ~source_tracker(); diff --git a/source/sources/source-mirror.hpp b/source/sources/source-mirror.hpp index 1ee3eaa2..a2c62736 100644 --- a/source/sources/source-mirror.hpp +++ b/source/sources/source-mirror.hpp @@ -43,8 +43,6 @@ namespace source { namespace mirror { class mirror_factory { - friend class std::_Ptr_base; - obs_source_info osi; public: // Singleton diff --git a/source/util-memory.hpp b/source/util-memory.hpp index a89f9b82..f008c2e8 100644 --- a/source/util-memory.hpp +++ b/source/util-memory.hpp @@ -38,9 +38,13 @@ namespace util { template class AlignmentAllocator { public: - typedef T value_type; - typedef size_t size_type; + typedef T value_type; + typedef size_t size_type; +#ifdef __clang__ typedef ptrdiff_t difference_type; +#else + typedef std::ptrdiff_t difference_type; +#endif typedef T* pointer; typedef const T* const_pointer;