mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
gs-effect: Add ::create for shared_ptr and remove default constructor
This commit is contained in:
parent
9db7cd8da2
commit
71b223dcb5
13 changed files with 38 additions and 27 deletions
|
@ -158,18 +158,18 @@ 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<gs::effect>(file);
|
||||
_color_converter_effect = gs::effect::create(file);
|
||||
} catch (std::runtime_error& ex) {
|
||||
P_LOG_ERROR("<filter-blur> 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<gs::effect>(file);
|
||||
_mask_effect = gs::effect::create(file);
|
||||
} catch (std::runtime_error& ex) {
|
||||
P_LOG_ERROR("<filter-blur> Loading _effect '%s' failed with error(s): %s", file, ex.what());
|
||||
}
|
||||
|
|
|
@ -374,9 +374,9 @@ 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<gs::effect>(file);
|
||||
_effect = gs::effect::create(file);
|
||||
bfree(file);
|
||||
} catch (std::runtime_error& ex) {
|
||||
P_LOG_ERROR("<filter-color-grade> Loading _effect '%s' failed with error(s): %s", file, ex.what());
|
||||
|
|
|
@ -203,7 +203,7 @@ filter::displacement::displacement_instance::displacement_instance(obs_data_t* d
|
|||
char* effectFile = obs_module_file("effects/displace.effect");
|
||||
if (effectFile) {
|
||||
try {
|
||||
_effect = std::make_shared<gs::effect>(effectFile);
|
||||
_effect = gs::effect::create(effectFile);
|
||||
} catch (...) {
|
||||
P_LOG_ERROR("<Displacement Filter:%s> Failed to load displacement effect.", obs_source_get_name(_self));
|
||||
}
|
||||
|
|
|
@ -130,9 +130,9 @@ filter::dynamic_mask::dynamic_mask_instance::dynamic_mask_instance(obs_data_t* d
|
|||
this->_final_rt = std::make_shared<gs::rendertarget>(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<gs::effect>(file);
|
||||
this->_effect = gs::effect::create(file);
|
||||
} catch (std::exception& ex) {
|
||||
P_LOG_ERROR("Loading channel mask _effect failed with error(s):\n%s", ex.what());
|
||||
}
|
||||
|
|
|
@ -116,8 +116,8 @@ void filter::sdf_effects::sdf_effects_factory::on_list_fill()
|
|||
auto gctx = gs::context();
|
||||
|
||||
std::pair<const char*, std::shared_ptr<gs::effect>&> 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);
|
||||
|
@ -126,7 +126,7 @@ void filter::sdf_effects::sdf_effects_factory::on_list_fill()
|
|||
continue;
|
||||
}
|
||||
try {
|
||||
kv.second = std::make_shared<gs::effect>(path);
|
||||
kv.second = gs::effect::create(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,
|
||||
ex.what());
|
||||
|
|
|
@ -38,7 +38,7 @@ gfx::blur::box_linear_data::box_linear_data()
|
|||
{
|
||||
auto gctx = gs::context();
|
||||
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);
|
||||
bfree(file);
|
||||
} catch (...) {
|
||||
|
|
|
@ -38,7 +38,7 @@ gfx::blur::box_data::box_data()
|
|||
{
|
||||
auto gctx = gs::context();
|
||||
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);
|
||||
bfree(file);
|
||||
} catch (...) {
|
||||
|
|
|
@ -54,7 +54,7 @@ gfx::blur::dual_filtering_data::dual_filtering_data()
|
|||
{
|
||||
auto gctx = gs::context();
|
||||
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);
|
||||
bfree(file);
|
||||
} catch (...) {
|
||||
|
|
|
@ -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");
|
||||
_effect = std::make_shared<gs::effect>(file);
|
||||
char* file = obs_module_file("effects/blur/gaussian-linear.effect");
|
||||
_effect = gs::effect::create(file);
|
||||
bfree(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ gfx::blur::gaussian_data::gaussian_data()
|
|||
{
|
||||
auto gctx = gs::context();
|
||||
{
|
||||
char* file = obs_module_file("effects/blur/gaussian._effect");
|
||||
_effect = std::make_shared<gs::effect>(file);
|
||||
char* file = obs_module_file("effects/blur/gaussian.effect");
|
||||
_effect = gs::effect::create(file);
|
||||
bfree(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
|
||||
//#define OBS_LOAD_EFFECT_FILE
|
||||
|
||||
gs::effect::effect() : _effect(nullptr) {}
|
||||
|
||||
gs::effect::effect(std::string file) : effect()
|
||||
gs::effect::effect(std::string file)
|
||||
{
|
||||
#ifdef OBS_LOAD_EFFECT_FILE
|
||||
char* errorMessage = nullptr;
|
||||
|
@ -84,7 +82,7 @@ gs::effect::effect(std::string file) : effect()
|
|||
#endif
|
||||
}
|
||||
|
||||
gs::effect::effect(std::string code, std::string name) : effect()
|
||||
gs::effect::effect(std::string code, std::string name)
|
||||
{
|
||||
char* errorMessage = nullptr;
|
||||
auto gctx = gs::context();
|
||||
|
@ -157,6 +155,16 @@ bool gs::effect::has_parameter(std::string name, effect_parameter::type type)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<gs::effect> gs::effect::create(std::string file)
|
||||
{
|
||||
return std::shared_ptr<gs::effect>(new gs::effect(file));
|
||||
}
|
||||
|
||||
std::shared_ptr<gs::effect> gs::effect::create(std::string code, std::string name)
|
||||
{
|
||||
return std::shared_ptr<gs::effect>(new gs::effect(code, name));
|
||||
}
|
||||
|
||||
gs::effect_parameter::effect_parameter(std::shared_ptr<gs::effect> effect, gs_eparam_t* param)
|
||||
: _effect(effect), _param(param)
|
||||
{
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace gs {
|
|||
|
||||
class effect_parameter {
|
||||
std::shared_ptr<::gs::effect> _effect;
|
||||
gs_eparam_t* _param;
|
||||
gs_effect_param_info _param_info;
|
||||
gs_eparam_t* _param;
|
||||
gs_effect_param_info _param_info;
|
||||
|
||||
public:
|
||||
enum class type : uint8_t {
|
||||
|
@ -147,7 +147,6 @@ namespace gs {
|
|||
gs_effect_t* _effect;
|
||||
|
||||
public:
|
||||
effect();
|
||||
effect(std::string file);
|
||||
effect(std::string code, std::string name);
|
||||
virtual ~effect();
|
||||
|
@ -160,5 +159,9 @@ namespace gs {
|
|||
std::shared_ptr<effect_parameter> get_parameter(std::string name);
|
||||
bool has_parameter(std::string name);
|
||||
bool has_parameter(std::string name, effect_parameter::type type);
|
||||
|
||||
public:
|
||||
static std::shared_ptr<gs::effect> create(std::string file);
|
||||
static std::shared_ptr<gs::effect> create(std::string code, std::string name);
|
||||
};
|
||||
} // namespace gs
|
||||
|
|
|
@ -108,7 +108,7 @@ gs::mipmapper::mipmapper()
|
|||
|
||||
_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);
|
||||
bfree(effect_file);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue