mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
gs-effect: Pass unmodified parameters as const reference
This commit is contained in:
parent
1d9a4ddbf5
commit
2faa68f9be
2 changed files with 15 additions and 14 deletions
|
@ -54,7 +54,7 @@ static std::string load_file_as_code(std::filesystem::path file)
|
|||
return std::string(buf.data(), buf.data() + size);
|
||||
}
|
||||
|
||||
gs::effect::effect(std::string code, std::string name)
|
||||
gs::effect::effect(const std::string& code, const std::string& name)
|
||||
{
|
||||
auto gctx = gs::context();
|
||||
|
||||
|
@ -91,7 +91,7 @@ gs::effect_technique gs::effect::get_technique(size_t idx)
|
|||
return gs::effect_technique(get()->techniques.array + idx, this);
|
||||
}
|
||||
|
||||
gs::effect_technique gs::effect::get_technique(std::string name)
|
||||
gs::effect_technique gs::effect::get_technique(const std::string& name)
|
||||
{
|
||||
for (size_t idx = 0; idx < count_techniques(); idx++) {
|
||||
auto ptr = get()->techniques.array + idx;
|
||||
|
@ -103,7 +103,7 @@ gs::effect_technique gs::effect::get_technique(std::string name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool gs::effect::has_technique(std::string name)
|
||||
bool gs::effect::has_technique(const std::string& name)
|
||||
{
|
||||
if (get_technique(name))
|
||||
return true;
|
||||
|
@ -124,7 +124,7 @@ gs::effect_parameter gs::effect::get_parameter(size_t idx)
|
|||
return gs::effect_parameter(get()->params.array + idx, this);
|
||||
}
|
||||
|
||||
gs::effect_parameter gs::effect::get_parameter(std::string name)
|
||||
gs::effect_parameter gs::effect::get_parameter(const std::string& name)
|
||||
{
|
||||
for (size_t idx = 0; idx < count_parameters(); idx++) {
|
||||
auto ptr = get()->params.array + idx;
|
||||
|
@ -136,14 +136,14 @@ gs::effect_parameter gs::effect::get_parameter(std::string name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool gs::effect::has_parameter(std::string name)
|
||||
bool gs::effect::has_parameter(const std::string& name)
|
||||
{
|
||||
if (get_parameter(name))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool gs::effect::has_parameter(std::string name, effect_parameter::type type)
|
||||
bool gs::effect::has_parameter(const std::string& name, effect_parameter::type type)
|
||||
{
|
||||
auto eprm = get_parameter(name);
|
||||
if (eprm)
|
||||
|
|
|
@ -42,20 +42,20 @@ namespace gs {
|
|||
class effect : public std::shared_ptr<gs_effect_t> {
|
||||
public:
|
||||
effect(){};
|
||||
effect(std::string code, std::string name);
|
||||
effect(const std::string& code, const std::string& name);
|
||||
effect(std::filesystem::path file);
|
||||
~effect();
|
||||
|
||||
size_t count_techniques();
|
||||
gs::effect_technique get_technique(size_t idx);
|
||||
gs::effect_technique get_technique(std::string name);
|
||||
bool has_technique(std::string name);
|
||||
gs::effect_technique get_technique(const std::string& name);
|
||||
bool has_technique(const std::string& name);
|
||||
|
||||
size_t count_parameters();
|
||||
gs::effect_parameter get_parameter(size_t idx);
|
||||
gs::effect_parameter get_parameter(std::string name);
|
||||
bool has_parameter(std::string name);
|
||||
bool has_parameter(std::string name, effect_parameter::type type);
|
||||
gs::effect_parameter get_parameter(const std::string& name);
|
||||
bool has_parameter(const std::string& name);
|
||||
bool has_parameter(const std::string& name, effect_parameter::type type);
|
||||
|
||||
public /* Legacy Support */:
|
||||
inline gs_effect_t* get_object()
|
||||
|
@ -63,11 +63,12 @@ namespace gs {
|
|||
return get();
|
||||
}
|
||||
|
||||
static gs::effect create(std::string file)
|
||||
static gs::effect create(const std::string& file)
|
||||
{
|
||||
return gs::effect(file);
|
||||
};
|
||||
static gs::effect create(std::string code, std::string name)
|
||||
|
||||
static gs::effect create(const std::string& code, const std::string& name)
|
||||
{
|
||||
return gs::effect(code, name);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue