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
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-04-19 14:18:29 +02:00
parent aac52f736d
commit be4d42312d
12 changed files with 34 additions and 41 deletions

View File

@ -947,7 +947,7 @@ void filter::blur::blur_instance::video_render(gs_effect_t* effect)
std::string technique = ""; std::string technique = "";
switch (this->m_mask.type) { switch (this->m_mask.type) {
case Region: case Region:
if (this->m_mask.region.feather > FLT_EPSILON) { if (this->m_mask.region.feather > std::numeric_limits<float_t>::epsilon()) {
if (this->m_mask.region.invert) { if (this->m_mask.region.invert) {
technique = "RegionFeatherInverted"; technique = "RegionFeatherInverted";
} else { } else {

View File

@ -52,8 +52,6 @@ namespace filter {
}; };
class blur_factory { class blur_factory {
friend class std::_Ptr_base<filter::blur::blur_factory>;
obs_source_info source_info; obs_source_info source_info;
std::list<blur_instance*> sources; std::list<blur_instance*> sources;
std::shared_ptr<gs::effect> color_converter_effect; std::shared_ptr<gs::effect> color_converter_effect;

View File

@ -43,8 +43,6 @@
namespace filter { namespace filter {
namespace displacement { namespace displacement {
class displacement_factory { class displacement_factory {
friend class std::_Ptr_base<filter::displacement::displacement_factory>;
obs_source_info sourceInfo; obs_source_info sourceInfo;
public: // Singleton public: // Singleton

View File

@ -482,7 +482,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
{ {
{ {
this->m_outer_shadow = 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<double_t>::epsilon());
{ {
union { union {
uint32_t color; uint32_t color;
@ -505,7 +505,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
{ {
this->m_inner_shadow = 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<double_t>::epsilon());
{ {
union { union {
uint32_t color; uint32_t color;
@ -528,7 +528,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
{ {
this->m_outer_glow = 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<double_t>::epsilon());
{ {
union { union {
uint32_t color; 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_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 = 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)); 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)) { if (this->m_outer_glow_sharpness >= (1.0f - std::numeric_limits<float_t>::epsilon())) {
this->m_outer_glow_sharpness = 1.0f - FLT_EPSILON; this->m_outer_glow_sharpness = 1.0f - std::numeric_limits<float_t>::epsilon();
} }
} }
{ {
this->m_inner_glow = 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<double_t>::epsilon());
{ {
union { union {
uint32_t color; 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_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 = 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)); 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)) { if (this->m_inner_glow_sharpness >= (1.0f - std::numeric_limits<float_t>::epsilon())) {
this->m_inner_glow_sharpness = 1.0f - FLT_EPSILON; this->m_inner_glow_sharpness = 1.0f - std::numeric_limits<float_t>::epsilon();
} }
} }
{ {
this->m_outline = 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<double_t>::epsilon());
{ {
union { union {
uint32_t color; 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_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 = 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)); this->m_outline_sharpness_inv = float_t(1.0f / (1.0f - this->m_outline_sharpness));
if (this->m_outline_sharpness >= (1.0f - FLT_EPSILON)) { if (this->m_outline_sharpness >= (1.0f - std::numeric_limits<float_t>::epsilon())) {
this->m_outline_sharpness = 1.0f - FLT_EPSILON; this->m_outline_sharpness = 1.0f - std::numeric_limits<float_t>::epsilon();
} }
} }

View File

@ -41,8 +41,6 @@ namespace filter {
class sdf_effects_instance; class sdf_effects_instance;
class sdf_effects_factory { class sdf_effects_factory {
friend class std::_Ptr_base<filter::sdf_effects::sdf_effects_factory>;
obs_source_info source_info; obs_source_info source_info;
std::list<sdf_effects_instance*> sources; std::list<sdf_effects_instance*> sources;

View File

@ -29,8 +29,6 @@
namespace filter { namespace filter {
namespace transform { namespace transform {
class transform_factory { class transform_factory {
friend class std::_Ptr_base<filter::transform::transform_factory>;
obs_source_info sourceInfo; obs_source_info sourceInfo;
public: // Singleton public: // Singleton

View File

@ -17,6 +17,7 @@
#pragma once #pragma once
#include <cinttypes> #include <cinttypes>
#include <cmath>
#include <memory> #include <memory>
#include "obs/gs/gs-texture.hpp" #include "obs/gs/gs-texture.hpp"
@ -32,7 +33,7 @@ namespace gfx {
class ibase { class ibase {
public: public:
virtual ~ibase(){} virtual ~ibase() {}
virtual void set_input(std::shared_ptr<::gs::texture> texture) = 0; virtual void set_input(std::shared_ptr<::gs::texture> texture) = 0;
@ -61,7 +62,7 @@ namespace gfx {
class ibase_angle { class ibase_angle {
public: public:
virtual ~ibase_angle(){} virtual ~ibase_angle() {}
virtual double_t get_angle() = 0; virtual double_t get_angle() = 0;
@ -70,7 +71,7 @@ namespace gfx {
class ibase_center { class ibase_center {
public: public:
virtual ~ibase_center(){} virtual ~ibase_center() {}
virtual void set_center(double_t x, double_t y) = 0; virtual void set_center(double_t x, double_t y) = 0;
@ -87,7 +88,7 @@ namespace gfx {
class ifactory { class ifactory {
public: public:
virtual ~ifactory(){} virtual ~ifactory() {}
virtual bool is_type_supported(::gfx::blur::type type) = 0; virtual bool is_type_supported(::gfx::blur::type type) = 0;

View File

@ -295,7 +295,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian_linear::render()
std::shared_ptr<::gs::effect> effect = m_data->get_effect(); std::shared_ptr<::gs::effect> effect = m_data->get_effect();
auto kernel = m_data->get_kernel(size_t(m_size)); 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<double_t>::epsilon())) {
return m_input_texture; 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); effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE);
// First Pass // First Pass
if (m_step_scale.first > DBL_EPSILON) { if (m_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); 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 // Second Pass
if (m_step_scale.second > DBL_EPSILON) { if (m_step_scale.second > std::numeric_limits<double_t>::epsilon()) {
effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); 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(); std::shared_ptr<::gs::effect> effect = m_data->get_effect();
auto kernel = m_data->get_kernel(size_t(m_size)); 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<double_t>::epsilon())) {
return m_input_texture; return m_input_texture;
} }

View File

@ -302,7 +302,7 @@ std::shared_ptr<::gs::texture> gfx::blur::gaussian::render()
std::shared_ptr<::gs::effect> effect = m_data->get_effect(); std::shared_ptr<::gs::effect> effect = m_data->get_effect();
auto kernel = m_data->get_kernel(size_t(m_size)); 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<double_t>::epsilon())) {
return m_input_texture; 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); effect->get_parameter("pKernel").set_float_array(kernel.data(), MAX_KERNEL_SIZE);
// First Pass // First Pass
if (m_step_scale.first > DBL_EPSILON) { if (m_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
effect->get_parameter("pImageTexel").set_float2(float_t(1.f / width), 0.f); 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 // Second Pass
if (m_step_scale.second > DBL_EPSILON) { if (m_step_scale.second > std::numeric_limits<double_t>::epsilon()) {
effect->get_parameter("pImageTexel").set_float2(0.f, float_t(1.f / height)); 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(); std::shared_ptr<::gs::effect> effect = m_data->get_effect();
auto kernel = m_data->get_kernel(size_t(m_size)); 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<double_t>::epsilon())) {
return m_input_texture; 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(); std::shared_ptr<::gs::effect> effect = m_data->get_effect();
auto kernel = m_data->get_kernel(size_t(m_size)); 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<double_t>::epsilon())) {
return m_input_texture; 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(); std::shared_ptr<::gs::effect> effect = m_data->get_effect();
auto kernel = m_data->get_kernel(size_t(m_size)); 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<double_t>::epsilon())) {
return m_input_texture; return m_input_texture;
} }

View File

@ -34,8 +34,6 @@
namespace obs { namespace obs {
class source_tracker { class source_tracker {
friend class std::_Ref_count_obj<obs::source_tracker>;
std::map<std::string, obs_weak_source_t*> source_map; std::map<std::string, obs_weak_source_t*> source_map;
static void source_create_handler(void* ptr, calldata_t* data); static void source_create_handler(void* ptr, calldata_t* data);
@ -46,7 +44,7 @@ namespace obs {
static void finalize(); static void finalize();
static std::shared_ptr<obs::source_tracker> get(); static std::shared_ptr<obs::source_tracker> get();
private: public:
source_tracker(); source_tracker();
~source_tracker(); ~source_tracker();

View File

@ -43,8 +43,6 @@
namespace source { namespace source {
namespace mirror { namespace mirror {
class mirror_factory { class mirror_factory {
friend class std::_Ptr_base<source::mirror::mirror_factory>;
obs_source_info osi; obs_source_info osi;
public: // Singleton public: // Singleton

View File

@ -40,7 +40,11 @@ namespace util {
public: public:
typedef T value_type; typedef T value_type;
typedef size_t size_type; typedef size_t size_type;
#ifdef __clang__
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
#else
typedef std::ptrdiff_t difference_type;
#endif
typedef T* pointer; typedef T* pointer;
typedef const T* const_pointer; typedef const T* const_pointer;