project: Apply formatting

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-08-24 12:59:32 +02:00
parent 8beaf49d10
commit deeb6719c4
18 changed files with 88 additions and 87 deletions

View file

@ -147,8 +147,8 @@ filter::blur::blur_factory::blur_factory()
// Translation Cache // Translation Cache
/// File Filter for Images /// File Filter for Images
_translation_map.insert({std::string("image-filter"), std::string(D_TRANSLATE(S_FILETYPE_IMAGES)) _translation_map.insert({std::string("image-filter"), std::string(D_TRANSLATE(S_FILETYPE_IMAGES))
+ std::string(" (" S_FILEFILTERS_IMAGE ");;") + std::string(" (" S_FILEFILTERS_IMAGE ");;")
+ std::string("* (*.*)")}); + std::string("* (*.*)")});
} }
filter::blur::blur_factory::~blur_factory() {} filter::blur::blur_factory::~blur_factory() {}
@ -669,7 +669,8 @@ obs_properties_t* filter::blur::blur_instance::get_properties()
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_IMAGE), mask_type::Image);
obs_property_list_add_int(p, D_TRANSLATE(ST_MASK_TYPE_SOURCE), mask_type::Source); obs_property_list_add_int(p, D_TRANSLATE(ST_MASK_TYPE_SOURCE), mask_type::Source);
/// Region /// Region
p = obs_properties_add_float_slider(pr, ST_MASK_REGION_LEFT, D_TRANSLATE(ST_MASK_REGION_LEFT), 0.0, 100.0, 0.01); 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))); 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); 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))); obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_MASK_REGION_TOP)));
@ -780,7 +781,7 @@ void filter::blur::blur_instance::update(obs_data_t* settings)
break; break;
} }
if ((_mask.type == mask_type::Image) || (_mask.type == mask_type::Source)) { if ((_mask.type == mask_type::Image) || (_mask.type == mask_type::Source)) {
uint32_t color = static_cast<uint32_t>(obs_data_get_int(settings, ST_MASK_COLOR)); uint32_t color = static_cast<uint32_t>(obs_data_get_int(settings, ST_MASK_COLOR));
_mask.color.r = ((color >> 0) & 0xFF) / 255.0f; _mask.color.r = ((color >> 0) & 0xFF) / 255.0f;
_mask.color.g = ((color >> 8) & 0xFF) / 255.0f; _mask.color.g = ((color >> 8) & 0xFF) / 255.0f;
_mask.color.b = ((color >> 16) & 0xFF) / 255.0f; _mask.color.b = ((color >> 16) & 0xFF) / 255.0f;

View file

@ -251,7 +251,7 @@ void filter::dynamic_mask::dynamic_mask_instance::update(obs_data_t* settings)
this->_input = std::make_shared<obs::source>(obs_data_get_string(settings, ST_INPUT)); this->_input = std::make_shared<obs::source>(obs_data_get_string(settings, ST_INPUT));
this->_input_capture = std::make_shared<gfx::source_texture>(this->_input, _self); this->_input_capture = std::make_shared<gfx::source_texture>(this->_input, _self);
this->_input->events.rename += std::bind(&filter::dynamic_mask::dynamic_mask_instance::input_renamed, this, this->_input->events.rename += std::bind(&filter::dynamic_mask::dynamic_mask_instance::input_renamed, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
} catch (...) { } catch (...) {
this->_input.reset(); this->_input.reset();
this->_input_capture.reset(); this->_input_capture.reset();
@ -477,7 +477,8 @@ void filter::dynamic_mask::dynamic_mask_instance::video_render(gs_effect_t* in_e
obs_source_skip_video_filter(this->_self); obs_source_skip_video_filter(this->_self);
return; return;
} }
if (!this->_filter_texture->get_object() || !this->_input_texture->get_object() || !this->_final_texture->get_object()) { if (!this->_filter_texture->get_object() || !this->_input_texture->get_object()
|| !this->_final_texture->get_object()) {
obs_source_skip_video_filter(this->_self); obs_source_skip_video_filter(this->_self);
return; return;
} }

View file

@ -375,8 +375,8 @@ obs_properties_t* filter::sdf_effects::sdf_effects_instance::get_properties()
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_OFFSET_Y))); 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)); 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))); 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, p = obs_properties_add_float_slider(props, ST_SHADOW_OUTER_ALPHA, D_TRANSLATE(ST_SHADOW_OUTER_ALPHA), 0.0,
0.1); 100.0, 0.1);
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_ALPHA))); obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_OUTER_ALPHA)));
} }
@ -398,8 +398,8 @@ obs_properties_t* filter::sdf_effects::sdf_effects_instance::get_properties()
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_OFFSET_Y))); 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)); 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))); 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, p = obs_properties_add_float_slider(props, ST_SHADOW_INNER_ALPHA, D_TRANSLATE(ST_SHADOW_INNER_ALPHA), 0.0,
0.1); 100.0, 0.1);
obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_ALPHA))); obs_property_set_long_description(p, D_TRANSLATE(D_DESC(ST_SHADOW_INNER_ALPHA)));
} }
@ -456,7 +456,8 @@ obs_properties_t* filter::sdf_effects::sdf_effects_instance::get_properties()
p = obs_properties_add_float_slider(props, ST_OUTLINE_WIDTH, D_TRANSLATE(ST_OUTLINE_WIDTH), 0.0, 16.0, 0.01); 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, D_TRANSLATE(D_DESC(ST_OUTLINE_OFFSET))); 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); 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, D_TRANSLATE(D_DESC(ST_OUTLINE_SHARPNESS))); 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, p = obs_properties_add_float_slider(props, ST_OUTLINE_SHARPNESS, D_TRANSLATE(ST_OUTLINE_SHARPNESS), 0.00, 100.0,
@ -492,7 +493,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
uint8_t r, g, b, a; uint8_t r, g, b, a;
} c; } c;
}; };
color = uint32_t(obs_data_get_int(data, ST_SHADOW_OUTER_COLOR)); 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.x = float_t(c.r / 255.0);
this->_outer_shadow_color.y = float_t(c.g / 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.z = float_t(c.b / 255.0);
@ -516,7 +517,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
uint8_t r, g, b, a; uint8_t r, g, b, a;
} c; } c;
}; };
color = uint32_t(obs_data_get_int(data, ST_SHADOW_INNER_COLOR)); 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.x = float_t(c.r / 255.0);
this->_inner_shadow_color.y = float_t(c.g / 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.z = float_t(c.b / 255.0);
@ -540,7 +541,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
uint8_t r, g, b, a; uint8_t r, g, b, a;
} c; } c;
}; };
color = uint32_t(obs_data_get_int(data, ST_GLOW_OUTER_COLOR)); 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.x = float_t(c.r / 255.0);
this->_outer_glow_color.y = float_t(c.g / 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.z = float_t(c.b / 255.0);
@ -566,7 +567,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
uint8_t r, g, b, a; uint8_t r, g, b, a;
} c; } c;
}; };
color = uint32_t(obs_data_get_int(data, ST_GLOW_INNER_COLOR)); 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.x = float_t(c.r / 255.0);
this->_inner_glow_color.y = float_t(c.g / 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.z = float_t(c.b / 255.0);
@ -582,7 +583,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
{ {
this->_outline = obs_data_get_bool(data, ST_OUTLINE) this->_outline = obs_data_get_bool(data, ST_OUTLINE)
&& (obs_data_get_double(data, ST_OUTLINE_ALPHA) >= std::numeric_limits<double_t>::epsilon()); && (obs_data_get_double(data, ST_OUTLINE_ALPHA) >= std::numeric_limits<double_t>::epsilon());
{ {
union { union {
uint32_t color; uint32_t color;
@ -591,7 +592,7 @@ void filter::sdf_effects::sdf_effects_instance::update(obs_data_t* data)
uint8_t r, g, b, a; uint8_t r, g, b, a;
} c; } c;
}; };
color = uint32_t(obs_data_get_int(data, ST_OUTLINE_COLOR)); color = uint32_t(obs_data_get_int(data, ST_OUTLINE_COLOR));
this->_outline_color.x = float_t(c.r / 255.0); this->_outline_color.x = float_t(c.r / 255.0);
this->_outline_color.y = float_t(c.g / 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.z = float_t(c.b / 255.0);
@ -801,7 +802,7 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect
consumer_effect->get_parameter("pShadowMax")->set_float(this->_outer_shadow_range_max); consumer_effect->get_parameter("pShadowMax")->set_float(this->_outer_shadow_range_max);
consumer_effect->get_parameter("pShadowOffset") consumer_effect->get_parameter("pShadowOffset")
->set_float2(this->_outer_shadow_offset_x / float_t(baseW), ->set_float2(this->_outer_shadow_offset_x / float_t(baseW),
this->_outer_shadow_offset_y / float_t(baseH)); this->_outer_shadow_offset_y / float_t(baseH));
while (gs_effect_loop(consumer_effect->get_object(), "ShadowOuter")) { while (gs_effect_loop(consumer_effect->get_object(), "ShadowOuter")) {
gs_draw_sprite(0, 0, 1, 1); gs_draw_sprite(0, 0, 1, 1);
} }
@ -815,7 +816,7 @@ void filter::sdf_effects::sdf_effects_instance::video_render(gs_effect_t* effect
consumer_effect->get_parameter("pShadowMax")->set_float(this->_inner_shadow_range_max); consumer_effect->get_parameter("pShadowMax")->set_float(this->_inner_shadow_range_max);
consumer_effect->get_parameter("pShadowOffset") consumer_effect->get_parameter("pShadowOffset")
->set_float2(this->_inner_shadow_offset_x / float_t(baseW), ->set_float2(this->_inner_shadow_offset_x / float_t(baseW),
this->_inner_shadow_offset_y / float_t(baseH)); this->_inner_shadow_offset_y / float_t(baseH));
while (gs_effect_loop(consumer_effect->get_object(), "ShadowInner")) { while (gs_effect_loop(consumer_effect->get_object(), "ShadowInner")) {
gs_draw_sprite(0, 0, 1, 1); gs_draw_sprite(0, 0, 1, 1);
} }

View file

@ -39,7 +39,7 @@ gfx::blur::box_linear_data::box_linear_data()
auto gctx = gs::context(); auto gctx = gs::context();
try { try {
char* file = obs_module_file("effects/blur/box-linear.effect"); char* file = obs_module_file("effects/blur/box-linear.effect");
_effect = std::make_shared<::gs::effect>(file); _effect = std::make_shared<::gs::effect>(file);
bfree(file); bfree(file);
} catch (...) { } catch (...) {
P_LOG_ERROR("<gfx::blur::box_linear> Failed to load _effect."); P_LOG_ERROR("<gfx::blur::box_linear> Failed to load _effect.");
@ -174,7 +174,7 @@ std::shared_ptr<::gfx::blur::box_linear_data> gfx::blur::box_linear_factory::dat
std::unique_lock<std::mutex> ulock(_data_lock); std::unique_lock<std::mutex> ulock(_data_lock);
std::shared_ptr<::gfx::blur::box_linear_data> data = _data.lock(); std::shared_ptr<::gfx::blur::box_linear_data> data = _data.lock();
if (!data) { if (!data) {
data = std::make_shared<::gfx::blur::box_linear_data>(); data = std::make_shared<::gfx::blur::box_linear_data>();
_data = data; _data = data;
} }
return data; return data;

View file

@ -39,7 +39,7 @@ gfx::blur::box_data::box_data()
auto gctx = gs::context(); auto gctx = gs::context();
try { try {
char* file = obs_module_file("effects/blur/box.effect"); char* file = obs_module_file("effects/blur/box.effect");
_effect = std::make_shared<::gs::effect>(file); _effect = std::make_shared<::gs::effect>(file);
bfree(file); bfree(file);
} catch (...) { } catch (...) {
P_LOG_ERROR("<gfx::blur::box> Failed to load _effect."); P_LOG_ERROR("<gfx::blur::box> Failed to load _effect.");
@ -182,7 +182,7 @@ std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data()
std::unique_lock<std::mutex> ulock(_data_lock); std::unique_lock<std::mutex> ulock(_data_lock);
std::shared_ptr<::gfx::blur::box_data> data = _data.lock(); std::shared_ptr<::gfx::blur::box_data> data = _data.lock();
if (!data) { if (!data) {
data = std::make_shared<::gfx::blur::box_data>(); data = std::make_shared<::gfx::blur::box_data>();
_data = data; _data = data;
} }
return data; return data;
@ -196,7 +196,7 @@ std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data()
gfx::blur::box::box() : _data(::gfx::blur::box_factory::get().data()), _size(1.), _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(); auto gctx = gs::context();
_rendertarget = 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); _rendertarget2 = std::make_shared<::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
} }

View file

@ -55,7 +55,7 @@ gfx::blur::dual_filtering_data::dual_filtering_data()
auto gctx = gs::context(); auto gctx = gs::context();
try { try {
char* file = obs_module_file("effects/blur/dual-filtering.effect"); char* file = obs_module_file("effects/blur/dual-filtering.effect");
_effect = std::make_shared<::gs::effect>(file); _effect = std::make_shared<::gs::effect>(file);
bfree(file); bfree(file);
} catch (...) { } catch (...) {
P_LOG_ERROR("<gfx::blur::box_linear> Failed to load _effect."); P_LOG_ERROR("<gfx::blur::box_linear> Failed to load _effect.");
@ -167,7 +167,7 @@ std::shared_ptr<::gfx::blur::dual_filtering_data> gfx::blur::dual_filtering_fact
std::unique_lock<std::mutex> ulock(_data_lock); std::unique_lock<std::mutex> ulock(_data_lock);
std::shared_ptr<::gfx::blur::dual_filtering_data> data = _data.lock(); std::shared_ptr<::gfx::blur::dual_filtering_data> data = _data.lock();
if (!data) { if (!data) {
data = std::make_shared<::gfx::blur::dual_filtering_data>(); data = std::make_shared<::gfx::blur::dual_filtering_data>();
_data = data; _data = data;
} }
return data; return data;

View file

@ -46,7 +46,7 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data()
{ {
char* file = obs_module_file("effects/blur/gaussian-linear.effect"); char* file = obs_module_file("effects/blur/gaussian-linear.effect");
_effect = gs::effect::create(file); _effect = gs::effect::create(file);
bfree(file); bfree(file);
} }
@ -219,7 +219,7 @@ std::shared_ptr<::gfx::blur::gaussian_linear_data> gfx::blur::gaussian_linear_fa
std::unique_lock<std::mutex> ulock(_data_lock); std::unique_lock<std::mutex> ulock(_data_lock);
std::shared_ptr<::gfx::blur::gaussian_linear_data> data = _data.lock(); std::shared_ptr<::gfx::blur::gaussian_linear_data> data = _data.lock();
if (!data) { if (!data) {
data = std::make_shared<::gfx::blur::gaussian_linear_data>(); data = std::make_shared<::gfx::blur::gaussian_linear_data>();
_data = data; _data = data;
} }
return data; return data;

View file

@ -46,7 +46,7 @@ gfx::blur::gaussian_data::gaussian_data()
auto gctx = gs::context(); auto gctx = gs::context();
{ {
char* file = obs_module_file("effects/blur/gaussian.effect"); char* file = obs_module_file("effects/blur/gaussian.effect");
_effect = gs::effect::create(file); _effect = gs::effect::create(file);
bfree(file); bfree(file);
} }
@ -227,7 +227,7 @@ std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data()
std::unique_lock<std::mutex> ulock(_data_lock); std::unique_lock<std::mutex> ulock(_data_lock);
std::shared_ptr<::gfx::blur::gaussian_data> data = _data.lock(); std::shared_ptr<::gfx::blur::gaussian_data> data = _data.lock();
if (!data) { if (!data) {
data = std::make_shared<::gfx::blur::gaussian_data>(); data = std::make_shared<::gfx::blur::gaussian_data>();
_data = data; _data = data;
} }
return data; return data;
@ -239,10 +239,9 @@ std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data()
return instance; return instance;
} }
gfx::blur::gaussian::gaussian() gfx::blur::gaussian::gaussian() : _data(::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.})
: _data(::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.})
{ {
auto gctx = gs::context(); auto gctx = gs::context();
_rendertarget = 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); _rendertarget2 = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
} }

View file

@ -32,8 +32,8 @@ gfx::source_texture::source_texture(obs_source_t* parent)
if (!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<obs::source>(parent, false, false); _parent = std::make_shared<obs::source>(parent, false, false);
_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE); _rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
} }
gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent) gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent)
@ -72,9 +72,9 @@ gfx::source_texture::source_texture(std::shared_ptr<obs::source> pchild, std::sh
if (!obs_source_add_active_child(pparent->get(), pchild->get())) { 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->_child = pchild;
this->_parent = pparent; this->_parent = pparent;
this->_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE); this->_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
} }
gfx::source_texture::source_texture(std::shared_ptr<obs::source> _child, obs_source_t* _parent) gfx::source_texture::source_texture(std::shared_ptr<obs::source> _child, obs_source_t* _parent)

View file

@ -79,7 +79,7 @@ gs::mipmapper::~mipmapper()
gs::mipmapper::mipmapper() gs::mipmapper::mipmapper()
{ {
_vb = std::make_unique<gs::vertex_buffer>(uint32_t(6u), uint8_t(1u)); _vb = std::make_unique<gs::vertex_buffer>(uint32_t(6u), uint8_t(1u));
auto v0 = _vb->at(0); auto v0 = _vb->at(0);
v0.position->x = 0; v0.position->x = 0;
v0.position->y = 0; v0.position->y = 0;
@ -109,7 +109,7 @@ gs::mipmapper::mipmapper()
_vb->update(); _vb->update();
char* effect_file = obs_module_file("effects/mipgen.effect"); char* effect_file = obs_module_file("effects/mipgen.effect");
_effect = std::make_unique<gs::effect>(effect_file); _effect = std::make_unique<gs::effect>(effect_file);
bfree(effect_file); bfree(effect_file);
} }
@ -267,9 +267,8 @@ void gs::mipmapper::rebuild(std::shared_ptr<gs::texture> source, std::shared_ptr
#if defined(WIN32) || defined(WIN64) #if defined(WIN32) || defined(WIN64)
if (device_type == GS_DEVICE_DIRECT3D_11) { if (device_type == GS_DEVICE_DIRECT3D_11) {
// Copy // Copy
ID3D11Texture2D* rt = ID3D11Texture2D* rt = reinterpret_cast<ID3D11Texture2D*>(gs_texture_get_obj(_rt->get_object()));
reinterpret_cast<ID3D11Texture2D*>(gs_texture_get_obj(_rt->get_object())); uint32_t level = uint32_t(D3D11CalcSubresource(UINT(mip), 0, UINT(mip_levels)));
uint32_t level = uint32_t(D3D11CalcSubresource(UINT(mip), 0, UINT(mip_levels)));
dev->context->CopySubresourceRegion(target_t2, level, 0, 0, 0, rt, 0, NULL); dev->context->CopySubresourceRegion(target_t2, level, 0, 0, 0, rt, 0, NULL);
} }
#endif #endif

View file

@ -42,7 +42,7 @@ gs::rendertarget::rendertarget(gs_color_format colorFormat, gs_zstencil_format z
: _color_format(colorFormat), _zstencil_format(zsFormat) : _color_format(colorFormat), _zstencil_format(zsFormat)
{ {
_is_being_rendered = false; _is_being_rendered = false;
auto gctx = gs::context(); auto gctx = gs::context();
_render_target = gs_texrender_create(colorFormat, zsFormat); _render_target = gs_texrender_create(colorFormat, zsFormat);
if (!_render_target) { if (!_render_target) {
throw std::runtime_error("Failed to create render target."); throw std::runtime_error("Failed to create render target.");

View file

@ -21,7 +21,7 @@
gs::sampler::sampler() gs::sampler::sampler()
{ {
_dirty = true; _dirty = true;
_sampler_info = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0}; _sampler_info = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0};
_sampler_state = nullptr; _sampler_state = nullptr;
} }
@ -34,7 +34,7 @@ gs::sampler::~sampler()
void gs::sampler::set_filter(gs_sample_filter v) void gs::sampler::set_filter(gs_sample_filter v)
{ {
_dirty = true; _dirty = true;
_sampler_info.filter = v; _sampler_info.filter = v;
} }
@ -45,7 +45,7 @@ gs_sample_filter gs::sampler::get_filter()
void gs::sampler::set_address_mode_u(gs_address_mode v) void gs::sampler::set_address_mode_u(gs_address_mode v)
{ {
_dirty = true; _dirty = true;
_sampler_info.address_u = v; _sampler_info.address_u = v;
} }
@ -56,7 +56,7 @@ gs_address_mode gs::sampler::get_address_mode_u()
void gs::sampler::set_address_mode_v(gs_address_mode v) void gs::sampler::set_address_mode_v(gs_address_mode v)
{ {
_dirty = true; _dirty = true;
_sampler_info.address_v = v; _sampler_info.address_v = v;
} }
@ -67,7 +67,7 @@ gs_address_mode gs::sampler::get_address_mode_v()
void gs::sampler::set_address_mode_w(gs_address_mode v) void gs::sampler::set_address_mode_w(gs_address_mode v)
{ {
_dirty = true; _dirty = true;
_sampler_info.address_w = v; _sampler_info.address_w = v;
} }
@ -78,7 +78,7 @@ gs_address_mode gs::sampler::get_address_mode_w()
void gs::sampler::set_max_anisotropy(int v) void gs::sampler::set_max_anisotropy(int v)
{ {
_dirty = true; _dirty = true;
_sampler_info.max_anisotropy = v; _sampler_info.max_anisotropy = v;
} }
@ -89,13 +89,13 @@ int gs::sampler::get_max_anisotropy()
void gs::sampler::set_border_color(uint32_t v) void gs::sampler::set_border_color(uint32_t v)
{ {
_dirty = true; _dirty = true;
_sampler_info.border_color = v; _sampler_info.border_color = v;
} }
void gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) void gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{ {
_dirty = true; _dirty = true;
_sampler_info.border_color = a << 24 | r << 16 | g << 8 | b; _sampler_info.border_color = a << 24 | r << 16 | g << 8 | b;
} }
@ -121,7 +121,7 @@ gs_sampler_state* gs::sampler::refresh()
{ {
gs_samplerstate_destroy(_sampler_state); gs_samplerstate_destroy(_sampler_state);
_sampler_state = gs_samplerstate_create(&_sampler_info); _sampler_state = gs_samplerstate_create(&_sampler_info);
_dirty = false; _dirty = false;
return _sampler_state; return _sampler_state;
} }

View file

@ -52,10 +52,10 @@ gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, ui
} }
auto gctx = gs::context(); auto gctx = gs::context();
_texture = gs_texture_create( _texture = gs_texture_create(
width, height, format, mip_levels, mip_data, width, height, format, mip_levels, mip_data,
(((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0) (((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0)
| (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0)); | (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0));
if (!_texture) if (!_texture)
throw std::runtime_error("Failed to create texture."); throw std::runtime_error("Failed to create texture.");
@ -84,10 +84,10 @@ gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f
} }
auto gctx = gs::context(); auto gctx = gs::context();
_texture = gs_voltexture_create( _texture = gs_voltexture_create(
width, height, depth, format, mip_levels, mip_data, width, height, depth, format, mip_levels, mip_data,
(((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0) (((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0)
| (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0)); | (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0));
if (!_texture) if (!_texture)
throw std::runtime_error("Failed to create texture."); throw std::runtime_error("Failed to create texture.");
@ -110,10 +110,10 @@ gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels,
} }
auto gctx = gs::context(); auto gctx = gs::context();
_texture = gs_cubetexture_create( _texture = gs_cubetexture_create(
size, format, mip_levels, mip_data, size, format, mip_levels, mip_data,
(((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0) (((texture_flags & flags::Dynamic) == flags::Dynamic) ? GS_DYNAMIC : 0)
| (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0)); | (((texture_flags & flags::BuildMipMaps) == flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0));
if (!_texture) if (!_texture)
throw std::runtime_error("Failed to create texture."); throw std::runtime_error("Failed to create texture.");
@ -128,7 +128,7 @@ gs::texture::texture(std::string file)
throw std::ios_base::failure(file); throw std::ios_base::failure(file);
auto gctx = gs::context(); auto gctx = gs::context();
_texture = gs_texture_create_from_file(file.c_str()); _texture = gs_texture_create_from_file(file.c_str());
if (!_texture) if (!_texture)
throw std::runtime_error("Failed to load texture."); throw std::runtime_error("Failed to load texture.");

View file

@ -107,11 +107,10 @@ gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers)
_data->num_tex = _layers; _data->num_tex = _layers;
if (_layers > 0) { if (_layers > 0) {
_data->tvarray = _layer_data = _data->tvarray = _layer_data = (gs_tvertarray*)util::malloc_aligned(16, sizeof(gs_tvertarray) * _layers);
(gs_tvertarray*)util::malloc_aligned(16, sizeof(gs_tvertarray) * _layers);
for (size_t n = 0; n < _layers; n++) { 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].array = _uvs[n] = (vec4*)util::malloc_aligned(16, sizeof(vec4) * _capacity);
_layer_data[n].width = 4; _layer_data[n].width = 4;
memset(_uvs[n], 0, sizeof(vec4) * _capacity); memset(_uvs[n], 0, sizeof(vec4) * _capacity);
} }
} else { } else {
@ -119,8 +118,8 @@ gs::vertex_buffer::vertex_buffer(uint32_t vertices, uint8_t uvlayers)
} }
// Allocate GPU // Allocate GPU
auto gctx = gs::context(); auto gctx = gs::context();
_buffer = gs_vertexbuffer_create(_data, GS_DYNAMIC); _buffer = gs_vertexbuffer_create(_data, GS_DYNAMIC);
memset(_data, 0, sizeof(gs_vb_data)); memset(_data, 0, sizeof(gs_vb_data));
_data->num = _capacity; _data->num = _capacity;
_data->num_tex = _layers; _data->num_tex = _layers;
@ -191,9 +190,9 @@ gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other)
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
_uvs[n] = other._uvs[n]; _uvs[n] = other._uvs[n];
} }
_data = other._data; _data = other._data;
_buffer = other._buffer; _buffer = other._buffer;
_layer_data = other._layer_data; _layer_data = other._layer_data;
} }
void gs::vertex_buffer::operator=(vertex_buffer const&& other) void gs::vertex_buffer::operator=(vertex_buffer const&& other)
@ -249,9 +248,9 @@ void gs::vertex_buffer::operator=(vertex_buffer const&& other)
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) { for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
_uvs[n] = other._uvs[n]; _uvs[n] = other._uvs[n];
} }
_data = other._data; _data = other._data;
_buffer = other._buffer; _buffer = other._buffer;
_layer_data = other._layer_data; _layer_data = other._layer_data;
} }
void gs::vertex_buffer::resize(uint32_t new_size) void gs::vertex_buffer::resize(uint32_t new_size)
@ -337,8 +336,8 @@ gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU)
throw std::out_of_range("size is larger than capacity"); throw std::out_of_range("size is larger than capacity");
// Update VertexBuffer data. // Update VertexBuffer data.
auto gctx = gs::context(); auto gctx = gs::context();
_data = gs_vertexbuffer_get_data(_buffer); _data = gs_vertexbuffer_get_data(_buffer);
memset(_data, 0, sizeof(gs_vb_data)); memset(_data, 0, sizeof(gs_vb_data));
_data->num = _capacity; _data->num = _capacity;
_data->points = _positions; _data->points = _positions;

View file

@ -411,17 +411,17 @@ obs::source::source()
#define auto_signal_c(SIGNAL) \ #define auto_signal_c(SIGNAL) \
{ \ { \
this->events.SIGNAL.set_listen_callback([this] { \ this->events.SIGNAL.set_listen_callback([this] { \
if (!this->_self) \ if (!this->_self) \
return; \ return; \
auto sh = obs_source_get_signal_handler(this->_self); \ auto sh = obs_source_get_signal_handler(this->_self); \
if (sh) { \ if (sh) { \
signal_handler_connect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ signal_handler_connect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \
} \ } \
}); \ }); \
this->events.SIGNAL.set_silence_callback([this] { \ this->events.SIGNAL.set_silence_callback([this] { \
if (!this->_self) \ if (!this->_self) \
return; \ return; \
auto sh = obs_source_get_signal_handler(this->_self); \ auto sh = obs_source_get_signal_handler(this->_self); \
if (sh) { \ if (sh) { \
signal_handler_disconnect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ signal_handler_disconnect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \
} \ } \

View file

@ -412,7 +412,7 @@ void source::mirror::mirror_instance::acquire_input(std::string source_name)
// If everything worked fine, we now set everything up. // If everything worked fine, we now set everything up.
this->_source = new_source; this->_source = new_source;
this->_source->events.rename += std::bind(&source::mirror::mirror_instance::on_source_rename, this, this->_source->events.rename += std::bind(&source::mirror::mirror_instance::on_source_rename, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
if ((obs_source_get_output_flags(this->_source->get()) & OBS_SOURCE_AUDIO) != 0) { if ((obs_source_get_output_flags(this->_source->get()) & OBS_SOURCE_AUDIO) != 0) {
this->_source->events.audio_data += this->_source->events.audio_data +=
std::bind(&source::mirror::mirror_instance::on_audio_data, this, std::placeholders::_1, std::bind(&source::mirror::mirror_instance::on_audio_data, this, std::placeholders::_1,
@ -580,8 +580,8 @@ void source::mirror::mirror_instance::video_tick(float time)
} }
obs_sceneitem_set_info(this->_source_item, &info); obs_sceneitem_set_info(this->_source_item, &info);
obs_sceneitem_force_update_transform(this->_source_item); obs_sceneitem_force_update_transform(this->_source_item);
obs_sceneitem_set_scale_filter(this->_source_item, this->_rescale_enabled ? this->_rescale_type obs_sceneitem_set_scale_filter(this->_source_item,
: obs_scale_type::OBS_SCALE_POINT); this->_rescale_enabled ? this->_rescale_type : obs_scale_type::OBS_SCALE_POINT);
} }
_scene_rendered = false; _scene_rendered = false;
@ -742,7 +742,7 @@ void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_da
memcpy(mad->data[plane].data(), audio->data[plane], audio->frames * sizeof(float_t)); memcpy(mad->data[plane].data(), audio->data[plane], audio->frames * sizeof(float_t));
mad->audio.data[plane] = reinterpret_cast<uint8_t*>(mad->data[plane].data()); mad->audio.data[plane] = reinterpret_cast<uint8_t*>(mad->data[plane].data());
} }
mad->audio.format = aoi->format; mad->audio.format = aoi->format;
mad->audio.frames = audio->frames; mad->audio.frames = audio->frames;
mad->audio.timestamp = audio->timestamp; mad->audio.timestamp = audio->timestamp;
mad->audio.samples_per_sec = aoi->samples_per_sec; mad->audio.samples_per_sec = aoi->samples_per_sec;

View file

@ -256,7 +256,8 @@ bool source::shader::shader_instance::valid_param(std::shared_ptr<gs::effect_par
void source::shader::shader_instance::override_param(std::shared_ptr<gs::effect> effect) {} void source::shader::shader_instance::override_param(std::shared_ptr<gs::effect> effect) {}
void source::shader::shader_instance::enum_active_sources(obs_source_enum_proc_t r, void* p) { void source::shader::shader_instance::enum_active_sources(obs_source_enum_proc_t r, void* p)
{
_fx->enum_active_sources(r, p); _fx->enum_active_sources(r, p);
} }