mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-14 15:55:07 +00:00
gfx: Apply coding guidelines
This commit is contained in:
parent
dcd4f7f9f0
commit
578d84be63
38 changed files with 794 additions and 777 deletions
|
@ -81,26 +81,26 @@ using namespace streamfx::filter::blur;
|
||||||
static constexpr std::string_view HELP_URL = "https://github.com/Xaymar/obs-StreamFX/wiki/Filter-Blur";
|
static constexpr std::string_view HELP_URL = "https://github.com/Xaymar/obs-StreamFX/wiki/Filter-Blur";
|
||||||
|
|
||||||
struct local_blur_type_t {
|
struct local_blur_type_t {
|
||||||
std::function<::gfx::blur::ifactory&()> fn;
|
std::function<::streamfx::gfx::blur::ifactory&()> fn;
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
struct local_blur_subtype_t {
|
struct local_blur_subtype_t {
|
||||||
::gfx::blur::type type;
|
::streamfx::gfx::blur::type type;
|
||||||
const char* name;
|
const char* name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::map<std::string, local_blur_type_t> list_of_types = {
|
static std::map<std::string, local_blur_type_t> list_of_types = {
|
||||||
{"box", {&::gfx::blur::box_factory::get, S_BLUR_TYPE_BOX}},
|
{"box", {&::streamfx::gfx::blur::box_factory::get, S_BLUR_TYPE_BOX}},
|
||||||
{"box_linear", {&::gfx::blur::box_linear_factory::get, S_BLUR_TYPE_BOX_LINEAR}},
|
{"box_linear", {&::streamfx::gfx::blur::box_linear_factory::get, S_BLUR_TYPE_BOX_LINEAR}},
|
||||||
{"gaussian", {&::gfx::blur::gaussian_factory::get, S_BLUR_TYPE_GAUSSIAN}},
|
{"gaussian", {&::streamfx::gfx::blur::gaussian_factory::get, S_BLUR_TYPE_GAUSSIAN}},
|
||||||
{"gaussian_linear", {&::gfx::blur::gaussian_linear_factory::get, S_BLUR_TYPE_GAUSSIAN_LINEAR}},
|
{"gaussian_linear", {&::streamfx::gfx::blur::gaussian_linear_factory::get, S_BLUR_TYPE_GAUSSIAN_LINEAR}},
|
||||||
{"dual_filtering", {&::gfx::blur::dual_filtering_factory::get, S_BLUR_TYPE_DUALFILTERING}},
|
{"dual_filtering", {&::streamfx::gfx::blur::dual_filtering_factory::get, S_BLUR_TYPE_DUALFILTERING}},
|
||||||
};
|
};
|
||||||
static std::map<std::string, local_blur_subtype_t> list_of_subtypes = {
|
static std::map<std::string, local_blur_subtype_t> list_of_subtypes = {
|
||||||
{"area", {::gfx::blur::type::Area, S_BLUR_SUBTYPE_AREA}},
|
{"area", {::streamfx::gfx::blur::type::Area, S_BLUR_SUBTYPE_AREA}},
|
||||||
{"directional", {::gfx::blur::type::Directional, S_BLUR_SUBTYPE_DIRECTIONAL}},
|
{"directional", {::streamfx::gfx::blur::type::Directional, S_BLUR_SUBTYPE_DIRECTIONAL}},
|
||||||
{"rotational", {::gfx::blur::type::Rotational, S_BLUR_SUBTYPE_ROTATIONAL}},
|
{"rotational", {::streamfx::gfx::blur::type::Rotational, S_BLUR_SUBTYPE_ROTATIONAL}},
|
||||||
{"zoom", {::gfx::blur::type::Zoom, S_BLUR_SUBTYPE_ZOOM}},
|
{"zoom", {::streamfx::gfx::blur::type::Zoom, S_BLUR_SUBTYPE_ZOOM}},
|
||||||
};
|
};
|
||||||
|
|
||||||
blur_instance::blur_instance(obs_data_t* settings, obs_source_t* self)
|
blur_instance::blur_instance(obs_data_t* settings, obs_source_t* self)
|
||||||
|
@ -313,13 +313,14 @@ void blur_instance::video_tick(float)
|
||||||
} else {
|
} else {
|
||||||
_blur->set_step_scale(1.0, 1.0);
|
_blur->set_step_scale(1.0, 1.0);
|
||||||
}
|
}
|
||||||
if ((_blur->get_type() == ::gfx::blur::type::Directional)
|
if ((_blur->get_type() == ::streamfx::gfx::blur::type::Directional)
|
||||||
|| (_blur->get_type() == ::gfx::blur::type::Rotational)) {
|
|| (_blur->get_type() == ::streamfx::gfx::blur::type::Rotational)) {
|
||||||
auto obj = std::dynamic_pointer_cast<::gfx::blur::base_angle>(_blur);
|
auto obj = std::dynamic_pointer_cast<::streamfx::gfx::blur::base_angle>(_blur);
|
||||||
obj->set_angle(_blur_angle);
|
obj->set_angle(_blur_angle);
|
||||||
}
|
}
|
||||||
if ((_blur->get_type() == ::gfx::blur::type::Zoom) || (_blur->get_type() == ::gfx::blur::type::Rotational)) {
|
if ((_blur->get_type() == ::streamfx::gfx::blur::type::Zoom)
|
||||||
auto obj = std::dynamic_pointer_cast<::gfx::blur::base_center>(_blur);
|
|| (_blur->get_type() == ::streamfx::gfx::blur::type::Rotational)) {
|
||||||
|
auto obj = std::dynamic_pointer_cast<::streamfx::gfx::blur::base_center>(_blur);
|
||||||
obj->set_center(_blur_center.first, _blur_center.second);
|
obj->set_center(_blur_center.first, _blur_center.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,7 +339,7 @@ void blur_instance::video_tick(float)
|
||||||
} else if (_mask.type == mask_type::Source) {
|
} else if (_mask.type == mask_type::Source) {
|
||||||
if (_mask.source.name_old != _mask.source.name) {
|
if (_mask.source.name_old != _mask.source.name) {
|
||||||
try {
|
try {
|
||||||
_mask.source.source_texture = std::make_shared<gfx::source_texture>(_mask.source.name, _self);
|
_mask.source.source_texture = std::make_shared<streamfx::gfx::source_texture>(_mask.source.name, _self);
|
||||||
_mask.source.is_scene = (obs_scene_from_source(_mask.source.source_texture->get_object()) != nullptr);
|
_mask.source.is_scene = (obs_scene_from_source(_mask.source.source_texture->get_object()) != nullptr);
|
||||||
_mask.source.name_old = _mask.source.name;
|
_mask.source.name_old = _mask.source.name;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@ -672,10 +673,10 @@ try {
|
||||||
|
|
||||||
// Blur Sub-Type
|
// Blur Sub-Type
|
||||||
{
|
{
|
||||||
bool has_angle_support = (subtype_found->second.type == ::gfx::blur::type::Directional)
|
bool has_angle_support = (subtype_found->second.type == ::streamfx::gfx::blur::type::Directional)
|
||||||
|| (subtype_found->second.type == ::gfx::blur::type::Rotational);
|
|| (subtype_found->second.type == ::streamfx::gfx::blur::type::Rotational);
|
||||||
bool has_center_support = (subtype_found->second.type == ::gfx::blur::type::Rotational)
|
bool has_center_support = (subtype_found->second.type == ::streamfx::gfx::blur::type::Rotational)
|
||||||
|| (subtype_found->second.type == ::gfx::blur::type::Zoom);
|
|| (subtype_found->second.type == ::streamfx::gfx::blur::type::Zoom);
|
||||||
bool has_stepscale_support = type_found->second.fn().is_step_scale_supported(subtype_found->second.type);
|
bool has_stepscale_support = type_found->second.fn().is_step_scale_supported(subtype_found->second.type);
|
||||||
bool show_scaling = obs_data_get_bool(settings, ST_STEPSCALE) && has_stepscale_support;
|
bool show_scaling = obs_data_get_bool(settings, ST_STEPSCALE) && has_stepscale_support;
|
||||||
|
|
||||||
|
@ -711,7 +712,7 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Masking
|
{ // Masking
|
||||||
using namespace ::gfx::blur;
|
using namespace ::streamfx::gfx::blur;
|
||||||
bool show_mask = obs_data_get_bool(settings, ST_MASK);
|
bool show_mask = obs_data_get_bool(settings, ST_MASK);
|
||||||
mask_type mtype = static_cast<mask_type>(obs_data_get_int(settings, ST_MASK_TYPE));
|
mask_type mtype = static_cast<mask_type>(obs_data_get_int(settings, ST_MASK_TYPE));
|
||||||
bool show_region = (mtype == mask_type::Region) && show_mask;
|
bool show_region = (mtype == mask_type::Region) && show_mask;
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace streamfx::filter::blur {
|
||||||
bool _output_rendered;
|
bool _output_rendered;
|
||||||
|
|
||||||
// Blur
|
// Blur
|
||||||
std::shared_ptr<::gfx::blur::base> _blur;
|
std::shared_ptr<::streamfx::gfx::blur::base> _blur;
|
||||||
double_t _blur_size;
|
double_t _blur_size;
|
||||||
double_t _blur_angle;
|
double_t _blur_angle;
|
||||||
std::pair<double_t, double_t> _blur_center;
|
std::pair<double_t, double_t> _blur_center;
|
||||||
|
@ -82,7 +82,7 @@ namespace streamfx::filter::blur {
|
||||||
std::string name_old;
|
std::string name_old;
|
||||||
std::string name;
|
std::string name;
|
||||||
bool is_scene;
|
bool is_scene;
|
||||||
std::shared_ptr<gfx::source_texture> source_texture;
|
std::shared_ptr<streamfx::gfx::source_texture> source_texture;
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> texture;
|
std::shared_ptr<streamfx::obs::gs::texture> texture;
|
||||||
} source;
|
} source;
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -110,7 +110,7 @@ static constexpr std::string_view HELP_URL = "https://github.com/Xaymar/obs-Stre
|
||||||
// TODO: Figure out a way to merge _lut_rt, _lut_texture, _rt_source, _rt_grad, _tex_source, _tex_grade, _source_updated and _grade_updated.
|
// TODO: Figure out a way to merge _lut_rt, _lut_texture, _rt_source, _rt_grad, _tex_source, _tex_grade, _source_updated and _grade_updated.
|
||||||
// Seriously this is too much GPU space wasted on unused trash.
|
// Seriously this is too much GPU space wasted on unused trash.
|
||||||
|
|
||||||
#define LOCAL_PREFIX "<filter::color-grade> "
|
#define ST_PREFIX "<filter::color-grade> "
|
||||||
|
|
||||||
color_grade_instance::~color_grade_instance() {}
|
color_grade_instance::~color_grade_instance() {}
|
||||||
|
|
||||||
|
@ -127,25 +127,24 @@ color_grade_instance::color_grade_instance(obs_data_t* data, obs_source_t* self)
|
||||||
// Load the color grading effect.
|
// Load the color grading effect.
|
||||||
auto path = streamfx::data_file_path("effects/color-grade.effect");
|
auto path = streamfx::data_file_path("effects/color-grade.effect");
|
||||||
if (!std::filesystem::exists(path)) {
|
if (!std::filesystem::exists(path)) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Failed to locate effect file '%s'.", path.u8string().c_str());
|
DLOG_ERROR(ST_PREFIX "Failed to locate effect file '%s'.", path.u8string().c_str());
|
||||||
throw std::runtime_error("Failed to load color grade effect.");
|
throw std::runtime_error("Failed to load color grade effect.");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
_effect = streamfx::obs::gs::effect::create(path.u8string());
|
_effect = streamfx::obs::gs::effect::create(path.u8string());
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Failed to load effect '%s': %s", path.u8string().c_str(), ex.what());
|
DLOG_ERROR(ST_PREFIX "Failed to load effect '%s': %s", path.u8string().c_str(), ex.what());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize LUT work flow.
|
// Initialize LUT work flow.
|
||||||
try {
|
try {
|
||||||
_lut_producer = std::make_shared<gfx::lut::producer>();
|
_lut_producer = std::make_shared<streamfx::gfx::lut::producer>();
|
||||||
_lut_consumer = std::make_shared<gfx::lut::consumer>();
|
_lut_consumer = std::make_shared<streamfx::gfx::lut::consumer>();
|
||||||
_lut_initialized = true;
|
_lut_initialized = true;
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_WARNING(LOCAL_PREFIX "Failed to initialize LUT rendering, falling back to direct rendering.\n%s",
|
DLOG_WARNING(ST_PREFIX "Failed to initialize LUT rendering, falling back to direct rendering.\n%s", ex.what());
|
||||||
ex.what());
|
|
||||||
_lut_initialized = false;
|
_lut_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +152,7 @@ color_grade_instance::color_grade_instance(obs_data_t* data, obs_source_t* self)
|
||||||
try {
|
try {
|
||||||
allocate_rendertarget(GS_RGBA);
|
allocate_rendertarget(GS_RGBA);
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Failed to acquire render target for rendering: %s", ex.what());
|
DLOG_ERROR(ST_PREFIX "Failed to acquire render target for rendering: %s", ex.what());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,9 +222,9 @@ void color_grade_instance::update(obs_data_t* data)
|
||||||
_lut_enabled = v != 0; // 0 (Direct)
|
_lut_enabled = v != 0; // 0 (Direct)
|
||||||
|
|
||||||
if (v == -1) {
|
if (v == -1) {
|
||||||
_lut_depth = gfx::lut::color_depth::_8;
|
_lut_depth = streamfx::gfx::lut::color_depth::_8;
|
||||||
} else if (v > 0) {
|
} else if (v > 0) {
|
||||||
_lut_depth = static_cast<gfx::lut::color_depth>(v);
|
_lut_depth = static_cast<streamfx::gfx::lut::color_depth>(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +487,7 @@ void color_grade_instance::video_render(gs_effect_t* shader)
|
||||||
_lut_rt.reset();
|
_lut_rt.reset();
|
||||||
_lut_texture.reset();
|
_lut_texture.reset();
|
||||||
_lut_enabled = false;
|
_lut_enabled = false;
|
||||||
DLOG_WARNING(LOCAL_PREFIX "Reverting to direct rendering due to error: %s", ex.what());
|
DLOG_WARNING(ST_PREFIX "Reverting to direct rendering due to error: %s", ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((!_lut_initialized || !_lut_enabled) && !_cache_fresh) {
|
if ((!_lut_initialized || !_lut_enabled) && !_cache_fresh) {
|
||||||
|
@ -852,10 +851,10 @@ obs_properties_t* color_grade_factory::get_properties2(color_grade_instance* dat
|
||||||
std::pair<const char*, int64_t> els[] = {
|
std::pair<const char*, int64_t> els[] = {
|
||||||
{S_STATE_AUTOMATIC, -1},
|
{S_STATE_AUTOMATIC, -1},
|
||||||
{ST_I18N_RENDERMODE_DIRECT, 0},
|
{ST_I18N_RENDERMODE_DIRECT, 0},
|
||||||
{ST_I18N_RENDERMODE_LUT_2BIT, static_cast<int64_t>(gfx::lut::color_depth::_2)},
|
{ST_I18N_RENDERMODE_LUT_2BIT, static_cast<int64_t>(streamfx::gfx::lut::color_depth::_2)},
|
||||||
{ST_I18N_RENDERMODE_LUT_4BIT, static_cast<int64_t>(gfx::lut::color_depth::_4)},
|
{ST_I18N_RENDERMODE_LUT_4BIT, static_cast<int64_t>(streamfx::gfx::lut::color_depth::_4)},
|
||||||
{ST_I18N_RENDERMODE_LUT_6BIT, static_cast<int64_t>(gfx::lut::color_depth::_6)},
|
{ST_I18N_RENDERMODE_LUT_6BIT, static_cast<int64_t>(streamfx::gfx::lut::color_depth::_6)},
|
||||||
{ST_I18N_RENDERMODE_LUT_8BIT, static_cast<int64_t>(gfx::lut::color_depth::_8)},
|
{ST_I18N_RENDERMODE_LUT_8BIT, static_cast<int64_t>(streamfx::gfx::lut::color_depth::_8)},
|
||||||
//{ST_RENDERMODE_LUT_10BIT, static_cast<int64_t>(gfx::lut::color_depth::_10)},
|
//{ST_RENDERMODE_LUT_10BIT, static_cast<int64_t>(gfx::lut::color_depth::_10)},
|
||||||
};
|
};
|
||||||
for (auto kv : els) {
|
for (auto kv : els) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace streamfx::filter::color_grade {
|
||||||
vec3 _tint_hig;
|
vec3 _tint_hig;
|
||||||
vec4 _correction;
|
vec4 _correction;
|
||||||
bool _lut_enabled;
|
bool _lut_enabled;
|
||||||
gfx::lut::color_depth _lut_depth;
|
streamfx::gfx::lut::color_depth _lut_depth;
|
||||||
|
|
||||||
// Capture Cache
|
// Capture Cache
|
||||||
std::shared_ptr<streamfx::obs::gs::rendertarget> _ccache_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _ccache_rt;
|
||||||
|
@ -70,8 +70,8 @@ namespace streamfx::filter::color_grade {
|
||||||
// LUT work flow
|
// LUT work flow
|
||||||
bool _lut_initialized;
|
bool _lut_initialized;
|
||||||
bool _lut_dirty;
|
bool _lut_dirty;
|
||||||
std::shared_ptr<gfx::lut::producer> _lut_producer;
|
std::shared_ptr<streamfx::gfx::lut::producer> _lut_producer;
|
||||||
std::shared_ptr<gfx::lut::consumer> _lut_consumer;
|
std::shared_ptr<streamfx::gfx::lut::consumer> _lut_consumer;
|
||||||
std::shared_ptr<streamfx::obs::gs::rendertarget> _lut_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _lut_rt;
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> _lut_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _lut_texture;
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ void dynamic_mask_instance::update(obs_data_t* settings)
|
||||||
try {
|
try {
|
||||||
auto input = std::make_shared<obs::deprecated_source>(obs_data_get_string(settings, ST_INPUT));
|
auto input = std::make_shared<obs::deprecated_source>(obs_data_get_string(settings, ST_INPUT));
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
auto capture = std::make_shared<gfx::source_texture>(input, _self);
|
auto capture = std::make_shared<streamfx::gfx::source_texture>(input, _self);
|
||||||
|
|
||||||
input->events.rename += std::bind(&dynamic_mask_instance::input_renamed, this, std::placeholders::_1,
|
input->events.rename += std::bind(&dynamic_mask_instance::input_renamed, this, std::placeholders::_1,
|
||||||
std::placeholders::_2, std::placeholders::_3);
|
std::placeholders::_2, std::placeholders::_3);
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace streamfx::filter::dynamic_mask {
|
||||||
|
|
||||||
bool _have_input_texture;
|
bool _have_input_texture;
|
||||||
std::shared_ptr<obs::deprecated_source> _input;
|
std::shared_ptr<obs::deprecated_source> _input;
|
||||||
std::shared_ptr<gfx::source_texture> _input_capture;
|
std::shared_ptr<streamfx::gfx::source_texture> _input_capture;
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> _input_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _input_texture;
|
||||||
std::shared_ptr<obs::tools::visible_source> _input_vs;
|
std::shared_ptr<obs::tools::visible_source> _input_vs;
|
||||||
std::shared_ptr<obs::tools::active_source> _input_ac;
|
std::shared_ptr<obs::tools::active_source> _input_ac;
|
||||||
|
|
|
@ -31,7 +31,7 @@ static constexpr std::string_view HELP_URL =
|
||||||
|
|
||||||
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self)
|
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self)
|
||||||
{
|
{
|
||||||
_fx = std::make_shared<gfx::shader::shader>(self, gfx::shader::shader_mode::Filter);
|
_fx = std::make_shared<streamfx::gfx::shader::shader>(self, streamfx::gfx::shader::shader_mode::Filter);
|
||||||
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
|
|
||||||
update(data);
|
update(data);
|
||||||
|
@ -168,7 +168,7 @@ const char* shader_factory::get_name()
|
||||||
|
|
||||||
void shader_factory::get_defaults2(obs_data_t* data)
|
void shader_factory::get_defaults2(obs_data_t* data)
|
||||||
{
|
{
|
||||||
gfx::shader::shader::defaults(data);
|
streamfx::gfx::shader::shader::defaults(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_properties_t* shader_factory::get_properties2(shader::shader_instance* data)
|
obs_properties_t* shader_factory::get_properties2(shader::shader_instance* data)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
namespace streamfx::filter::shader {
|
namespace streamfx::filter::shader {
|
||||||
class shader_instance : public obs::source_instance {
|
class shader_instance : public obs::source_instance {
|
||||||
std::shared_ptr<gfx::shader::shader> _fx;
|
std::shared_ptr<streamfx::gfx::shader::shader> _fx;
|
||||||
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -18,48 +18,48 @@
|
||||||
#include "gfx-blur-base.hpp"
|
#include "gfx-blur-base.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
void gfx::blur::base::set_step_scale_x(double_t v)
|
void streamfx::gfx::blur::base::set_step_scale_x(double_t v)
|
||||||
{
|
{
|
||||||
this->set_step_scale(v, this->get_step_scale_y());
|
this->set_step_scale(v, this->get_step_scale_y());
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::base::set_step_scale_y(double_t v)
|
void streamfx::gfx::blur::base::set_step_scale_y(double_t v)
|
||||||
{
|
{
|
||||||
this->set_step_scale(this->get_step_scale_x(), v);
|
this->set_step_scale(this->get_step_scale_x(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::base::get_step_scale_x()
|
double_t streamfx::gfx::blur::base::get_step_scale_x()
|
||||||
{
|
{
|
||||||
double_t x, y;
|
double_t x, y;
|
||||||
this->get_step_scale(x, y);
|
this->get_step_scale(x, y);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::base::get_step_scale_y()
|
double_t streamfx::gfx::blur::base::get_step_scale_y()
|
||||||
{
|
{
|
||||||
double_t x, y;
|
double_t x, y;
|
||||||
this->get_step_scale(x, y);
|
this->get_step_scale(x, y);
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::base_center::set_center_x(double_t v)
|
void streamfx::gfx::blur::base_center::set_center_x(double_t v)
|
||||||
{
|
{
|
||||||
this->set_center(v, this->get_center_y());
|
this->set_center(v, this->get_center_y());
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::base_center::set_center_y(double_t v)
|
void streamfx::gfx::blur::base_center::set_center_y(double_t v)
|
||||||
{
|
{
|
||||||
this->set_center(this->get_center_x(), v);
|
this->set_center(this->get_center_x(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::base_center::get_center_x()
|
double_t streamfx::gfx::blur::base_center::get_center_x()
|
||||||
{
|
{
|
||||||
double_t x, y;
|
double_t x, y;
|
||||||
this->get_center(x, y);
|
this->get_center(x, y);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::base_center::get_center_y()
|
double_t streamfx::gfx::blur::base_center::get_center_y()
|
||||||
{
|
{
|
||||||
double_t x, y;
|
double_t x, y;
|
||||||
this->get_center(x, y);
|
this->get_center(x, y);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
enum class type : int64_t {
|
enum class type : int64_t {
|
||||||
Invalid = -1,
|
Invalid = -1,
|
||||||
|
@ -35,7 +35,7 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) = 0;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) = 0;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() = 0;
|
virtual ::streamfx::gfx::blur::type get_type() = 0;
|
||||||
|
|
||||||
virtual double_t get_size() = 0;
|
virtual double_t get_size() = 0;
|
||||||
|
|
||||||
|
@ -88,35 +88,35 @@ namespace gfx {
|
||||||
public:
|
public:
|
||||||
virtual ~ifactory() {}
|
virtual ~ifactory() {}
|
||||||
|
|
||||||
virtual bool is_type_supported(::gfx::blur::type type) = 0;
|
virtual bool is_type_supported(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) = 0;
|
virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_min_size(::gfx::blur::type type) = 0;
|
virtual double_t get_min_size(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_step_size(::gfx::blur::type type) = 0;
|
virtual double_t get_step_size(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_max_size(::gfx::blur::type type) = 0;
|
virtual double_t get_max_size(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_min_angle(::gfx::blur::type type) = 0;
|
virtual double_t get_min_angle(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_step_angle(::gfx::blur::type type) = 0;
|
virtual double_t get_step_angle(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_max_angle(::gfx::blur::type type) = 0;
|
virtual double_t get_max_angle(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual bool is_step_scale_supported(::gfx::blur::type type) = 0;
|
virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_x(::gfx::blur::type type) = 0;
|
virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_x(::gfx::blur::type type) = 0;
|
virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_x(::gfx::blur::type type) = 0;
|
virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_y(::gfx::blur::type type) = 0;
|
virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_y(::gfx::blur::type type) = 0;
|
virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) = 0;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_y(::gfx::blur::type type) = 0;
|
virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) = 0;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_BLUR_SIZE 128 // Also change this in box-linear.effect if modified.
|
#define ST_MAX_BLUR_SIZE 128 // Also change this in box-linear.effect if modified.
|
||||||
|
|
||||||
gfx::blur::box_linear_data::box_linear_data()
|
streamfx::gfx::blur::box_linear_data::box_linear_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
try {
|
try {
|
||||||
|
@ -45,203 +45,204 @@ gfx::blur::box_linear_data::box_linear_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_linear_data::~box_linear_data()
|
streamfx::gfx::blur::box_linear_data::~box_linear_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::obs::gs::effect gfx::blur::box_linear_data::get_effect()
|
streamfx::obs::gs::effect streamfx::gfx::blur::box_linear_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_linear_factory::box_linear_factory() {}
|
streamfx::gfx::blur::box_linear_factory::box_linear_factory() {}
|
||||||
|
|
||||||
gfx::blur::box_linear_factory::~box_linear_factory() {}
|
streamfx::gfx::blur::box_linear_factory::~box_linear_factory() {}
|
||||||
|
|
||||||
bool gfx::blur::box_linear_factory::is_type_supported(::gfx::blur::type type)
|
bool streamfx::gfx::blur::box_linear_factory::is_type_supported(::streamfx::gfx::blur::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::base> gfx::blur::box_linear_factory::create(::gfx::blur::type type)
|
std::shared_ptr<::streamfx::gfx::blur::base>
|
||||||
|
streamfx::gfx::blur::box_linear_factory::create(::streamfx::gfx::blur::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return std::make_shared<::gfx::blur::box_linear>();
|
return std::make_shared<::streamfx::gfx::blur::box_linear>();
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return std::make_shared<::gfx::blur::box_linear_directional>();
|
return std::make_shared<::streamfx::gfx::blur::box_linear_directional>();
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Invalid type.");
|
throw std::runtime_error("Invalid type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_min_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_min_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_step_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_step_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_max_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_max_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(MAX_BLUR_SIZE);
|
return double_t(ST_MAX_BLUR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_min_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::box_linear_factory::get_min_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return -180.0;
|
return -180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_step_angle(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_step_angle(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_max_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::box_linear_factory::get_max_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return 180.0;
|
return 180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::blur::box_linear_factory::is_step_scale_supported(::gfx::blur::type v)
|
bool streamfx::gfx::blur::box_linear_factory::is_step_scale_supported(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
case ::gfx::blur::type::Zoom:
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_min_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_min_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_step_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_step_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_max_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_max_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_min_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_min_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_step_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_step_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_factory::get_max_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_linear_factory::get_max_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::box_linear_data> gfx::blur::box_linear_factory::data()
|
std::shared_ptr<::streamfx::gfx::blur::box_linear_data> streamfx::gfx::blur::box_linear_factory::data()
|
||||||
{
|
{
|
||||||
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<::streamfx::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<::streamfx::gfx::blur::box_linear_data>();
|
||||||
_data = data;
|
_data = data;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::box_linear_factory& gfx::blur::box_linear_factory::get()
|
::streamfx::gfx::blur::box_linear_factory& streamfx::gfx::blur::box_linear_factory::get()
|
||||||
{
|
{
|
||||||
static ::gfx::blur::box_linear_factory instance;
|
static ::streamfx::gfx::blur::box_linear_factory instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_linear::box_linear()
|
streamfx::gfx::blur::box_linear::box_linear()
|
||||||
: _data(::gfx::blur::box_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
: _data(::streamfx::gfx::blur::box_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
_rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_linear::~box_linear() {}
|
streamfx::gfx::blur::box_linear::~box_linear() {}
|
||||||
|
|
||||||
void gfx::blur::box_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
void streamfx::gfx::blur::box_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::box_linear::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::box_linear::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Area;
|
return ::streamfx::gfx::blur::type::Area;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear::get_size()
|
double_t streamfx::gfx::blur::box_linear::get_size()
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_linear::set_size(double_t width)
|
void streamfx::gfx::blur::box_linear::set_size(double_t width)
|
||||||
{
|
{
|
||||||
_size = width;
|
_size = width;
|
||||||
if (_size < 1.0) {
|
if (_size < 1.0) {
|
||||||
_size = 1.0;
|
_size = 1.0;
|
||||||
}
|
}
|
||||||
if (_size > MAX_BLUR_SIZE) {
|
if (_size > ST_MAX_BLUR_SIZE) {
|
||||||
_size = MAX_BLUR_SIZE;
|
_size = ST_MAX_BLUR_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_linear::set_step_scale(double_t x, double_t y)
|
void streamfx::gfx::blur::box_linear::set_step_scale(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
_step_scale = {x, y};
|
_step_scale = {x, y};
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_linear::get_step_scale(double_t& x, double_t& y)
|
void streamfx::gfx::blur::box_linear::get_step_scale(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = _step_scale.first;
|
x = _step_scale.first;
|
||||||
y = _step_scale.second;
|
y = _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear::get_step_scale_x()
|
double_t streamfx::gfx::blur::box_linear::get_step_scale_x()
|
||||||
{
|
{
|
||||||
return _step_scale.first;
|
return _step_scale.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear::get_step_scale_y()
|
double_t streamfx::gfx::blur::box_linear::get_step_scale_y()
|
||||||
{
|
{
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -309,29 +310,29 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::render()
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_linear_directional::box_linear_directional() : _angle(0) {}
|
streamfx::gfx::blur::box_linear_directional::box_linear_directional() : _angle(0) {}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::box_linear_directional::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::box_linear_directional::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Directional;
|
return ::streamfx::gfx::blur::type::Directional;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_linear_directional::get_angle()
|
double_t streamfx::gfx::blur::box_linear_directional::get_angle()
|
||||||
{
|
{
|
||||||
return D_RAD_TO_DEG(_angle);
|
return D_RAD_TO_DEG(_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_linear_directional::set_angle(double_t angle)
|
void streamfx::gfx::blur::box_linear_directional::set_angle(double_t angle)
|
||||||
{
|
{
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_linear_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_linear_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class box_linear_data {
|
class box_linear_data {
|
||||||
streamfx::obs::gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
@ -35,53 +35,53 @@ namespace gfx {
|
||||||
streamfx::obs::gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_linear_factory : public ::gfx::blur::ifactory {
|
class box_linear_factory : public ::streamfx::gfx::blur::ifactory {
|
||||||
std::mutex _data_lock;
|
std::mutex _data_lock;
|
||||||
std::weak_ptr<::gfx::blur::box_linear_data> _data;
|
std::weak_ptr<::streamfx::gfx::blur::box_linear_data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box_linear_factory();
|
box_linear_factory();
|
||||||
virtual ~box_linear_factory() override;
|
virtual ~box_linear_factory() override;
|
||||||
|
|
||||||
virtual bool is_type_supported(::gfx::blur::type type) override;
|
virtual bool is_type_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override;
|
virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_size(::gfx::blur::type type) override;
|
virtual double_t get_min_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_size(::gfx::blur::type type) override;
|
virtual double_t get_step_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_size(::gfx::blur::type type) override;
|
virtual double_t get_max_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_angle(::gfx::blur::type type) override;
|
virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_angle(::gfx::blur::type type) override;
|
virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_angle(::gfx::blur::type type) override;
|
virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual bool is_step_scale_supported(::gfx::blur::type type) override;
|
virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::box_linear_data> data();
|
std::shared_ptr<::streamfx::gfx::blur::box_linear_data> data();
|
||||||
|
|
||||||
public: // Singleton
|
public: // Singleton
|
||||||
static ::gfx::blur::box_linear_factory& get();
|
static ::streamfx::gfx::blur::box_linear_factory& get();
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_linear : public ::gfx::blur::base {
|
class box_linear : public ::streamfx::gfx::blur::base {
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<::gfx::blur::box_linear_data> _data;
|
std::shared_ptr<::streamfx::gfx::blur::box_linear_data> _data;
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
|
@ -97,7 +97,7 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_size() override;
|
virtual double_t get_size() override;
|
||||||
virtual void set_size(double_t width) override;
|
virtual void set_size(double_t width) override;
|
||||||
|
@ -111,13 +111,14 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_linear_directional : public ::gfx::blur::box_linear, public ::gfx::blur::base_angle {
|
class box_linear_directional : public ::streamfx::gfx::blur::box_linear,
|
||||||
|
public ::streamfx::gfx::blur::base_angle {
|
||||||
double_t _angle;
|
double_t _angle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box_linear_directional();
|
box_linear_directional();
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
@ -125,4 +126,4 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_BLUR_SIZE 128 // Also change this in box.effect if modified.
|
#define ST_MAX_BLUR_SIZE 128 // Also change this in box.effect if modified.
|
||||||
|
|
||||||
gfx::blur::box_data::box_data()
|
streamfx::gfx::blur::box_data::box_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
try {
|
try {
|
||||||
|
@ -44,211 +44,213 @@ gfx::blur::box_data::box_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_data::~box_data()
|
streamfx::gfx::blur::box_data::~box_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::obs::gs::effect gfx::blur::box_data::get_effect()
|
streamfx::obs::gs::effect streamfx::gfx::blur::box_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_factory::box_factory() {}
|
streamfx::gfx::blur::box_factory::box_factory() {}
|
||||||
|
|
||||||
gfx::blur::box_factory::~box_factory() {}
|
streamfx::gfx::blur::box_factory::~box_factory() {}
|
||||||
|
|
||||||
bool gfx::blur::box_factory::is_type_supported(::gfx::blur::type type)
|
bool streamfx::gfx::blur::box_factory::is_type_supported(::streamfx::gfx::blur::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Zoom:
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::base> gfx::blur::box_factory::create(::gfx::blur::type type)
|
std::shared_ptr<::streamfx::gfx::blur::base> streamfx::gfx::blur::box_factory::create(::streamfx::gfx::blur::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return std::make_shared<::gfx::blur::box>();
|
return std::make_shared<::streamfx::gfx::blur::box>();
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return std::static_pointer_cast<::gfx::blur::box>(std::make_shared<::gfx::blur::box_directional>());
|
return std::static_pointer_cast<::streamfx::gfx::blur::box>(
|
||||||
case ::gfx::blur::type::Rotational:
|
std::make_shared<::streamfx::gfx::blur::box_directional>());
|
||||||
return std::make_shared<::gfx::blur::box_rotational>();
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
case ::gfx::blur::type::Zoom:
|
return std::make_shared<::streamfx::gfx::blur::box_rotational>();
|
||||||
return std::make_shared<::gfx::blur::box_zoom>();
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
|
return std::make_shared<::streamfx::gfx::blur::box_zoom>();
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Invalid type.");
|
throw std::runtime_error("Invalid type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_min_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_min_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_step_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_step_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_max_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_max_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(MAX_BLUR_SIZE);
|
return double_t(ST_MAX_BLUR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_min_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::box_factory::get_min_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return -180.0;
|
return -180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_step_angle(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_step_angle(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_max_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::box_factory::get_max_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return 180.0;
|
return 180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::blur::box_factory::is_step_scale_supported(::gfx::blur::type v)
|
bool streamfx::gfx::blur::box_factory::is_step_scale_supported(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
case ::gfx::blur::type::Zoom:
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_min_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_min_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_step_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_step_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_max_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_max_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_min_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_min_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_step_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_step_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_factory::get_max_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::box_factory::get_max_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::box_data> gfx::blur::box_factory::data()
|
std::shared_ptr<::streamfx::gfx::blur::box_data> streamfx::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<::streamfx::gfx::blur::box_data> data = _data.lock();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = std::make_shared<::gfx::blur::box_data>();
|
data = std::make_shared<::streamfx::gfx::blur::box_data>();
|
||||||
_data = data;
|
_data = data;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::box_factory& gfx::blur::box_factory::get()
|
::streamfx::gfx::blur::box_factory& streamfx::gfx::blur::box_factory::get()
|
||||||
{
|
{
|
||||||
static ::gfx::blur::box_factory instance;
|
static ::streamfx::gfx::blur::box_factory instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box::box() : _data(::gfx::blur::box_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
streamfx::gfx::blur::box::box()
|
||||||
|
: _data(::streamfx::gfx::blur::box_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<::streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box::~box() {}
|
streamfx::gfx::blur::box::~box() {}
|
||||||
|
|
||||||
void gfx::blur::box::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
void streamfx::gfx::blur::box::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::box::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::box::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Area;
|
return ::streamfx::gfx::blur::type::Area;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box::get_size()
|
double_t streamfx::gfx::blur::box::get_size()
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box::set_size(double_t width)
|
void streamfx::gfx::blur::box::set_size(double_t width)
|
||||||
{
|
{
|
||||||
_size = width;
|
_size = width;
|
||||||
if (_size < 1.0) {
|
if (_size < 1.0) {
|
||||||
_size = 1.0;
|
_size = 1.0;
|
||||||
}
|
}
|
||||||
if (_size > MAX_BLUR_SIZE) {
|
if (_size > ST_MAX_BLUR_SIZE) {
|
||||||
_size = MAX_BLUR_SIZE;
|
_size = ST_MAX_BLUR_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box::set_step_scale(double_t x, double_t y)
|
void streamfx::gfx::blur::box::set_step_scale(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
_step_scale = {x, y};
|
_step_scale = {x, y};
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box::get_step_scale(double_t& x, double_t& y)
|
void streamfx::gfx::blur::box::get_step_scale(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = _step_scale.first;
|
x = _step_scale.first;
|
||||||
y = _step_scale.second;
|
y = _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box::get_step_scale_x()
|
double_t streamfx::gfx::blur::box::get_step_scale_x()
|
||||||
{
|
{
|
||||||
return _step_scale.first;
|
return _step_scale.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box::get_step_scale_y()
|
double_t streamfx::gfx::blur::box::get_step_scale_y()
|
||||||
{
|
{
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -316,29 +318,29 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::render()
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::box_directional::box_directional() : _angle(0) {}
|
streamfx::gfx::blur::box_directional::box_directional() : _angle(0) {}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::box_directional::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::box_directional::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Directional;
|
return ::streamfx::gfx::blur::type::Directional;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_directional::get_angle()
|
double_t streamfx::gfx::blur::box_directional::get_angle()
|
||||||
{
|
{
|
||||||
return D_RAD_TO_DEG(_angle);
|
return D_RAD_TO_DEG(_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_directional::set_angle(double_t angle)
|
void streamfx::gfx::blur::box_directional::set_angle(double_t angle)
|
||||||
{
|
{
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -386,34 +388,34 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_directional::render
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::box_rotational::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::box_rotational::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Rotational;
|
return ::streamfx::gfx::blur::type::Rotational;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_rotational::set_center(double_t x, double_t y)
|
void streamfx::gfx::blur::box_rotational::set_center(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
_center.first = x;
|
_center.first = x;
|
||||||
_center.second = y;
|
_center.second = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_rotational::get_center(double_t& x, double_t& y)
|
void streamfx::gfx::blur::box_rotational::get_center(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = _center.first;
|
x = _center.first;
|
||||||
y = _center.second;
|
y = _center.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::box_rotational::get_angle()
|
double_t streamfx::gfx::blur::box_rotational::get_angle()
|
||||||
{
|
{
|
||||||
return D_RAD_TO_DEG(_angle);
|
return D_RAD_TO_DEG(_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_rotational::set_angle(double_t angle)
|
void streamfx::gfx::blur::box_rotational::set_angle(double_t angle)
|
||||||
{
|
{
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_rotational::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_rotational::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -462,24 +464,24 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_rotational::render(
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::box_zoom::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::box_zoom::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Zoom;
|
return ::streamfx::gfx::blur::type::Zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_zoom::set_center(double_t x, double_t y)
|
void streamfx::gfx::blur::box_zoom::set_center(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
_center.first = x;
|
_center.first = x;
|
||||||
_center.second = y;
|
_center.second = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::box_zoom::get_center(double_t& x, double_t& y)
|
void streamfx::gfx::blur::box_zoom::get_center(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = _center.first;
|
x = _center.first;
|
||||||
y = _center.second;
|
y = _center.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::box_zoom::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::box_zoom::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class box_data {
|
class box_data {
|
||||||
streamfx::obs::gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
@ -35,53 +35,53 @@ namespace gfx {
|
||||||
streamfx::obs::gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_factory : public ::gfx::blur::ifactory {
|
class box_factory : public ::streamfx::gfx::blur::ifactory {
|
||||||
std::mutex _data_lock;
|
std::mutex _data_lock;
|
||||||
std::weak_ptr<::gfx::blur::box_data> _data;
|
std::weak_ptr<::streamfx::gfx::blur::box_data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box_factory();
|
box_factory();
|
||||||
virtual ~box_factory() override;
|
virtual ~box_factory() override;
|
||||||
|
|
||||||
virtual bool is_type_supported(::gfx::blur::type type) override;
|
virtual bool is_type_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override;
|
virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_size(::gfx::blur::type type) override;
|
virtual double_t get_min_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_size(::gfx::blur::type type) override;
|
virtual double_t get_step_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_size(::gfx::blur::type type) override;
|
virtual double_t get_max_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_angle(::gfx::blur::type type) override;
|
virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_angle(::gfx::blur::type type) override;
|
virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_angle(::gfx::blur::type type) override;
|
virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual bool is_step_scale_supported(::gfx::blur::type type) override;
|
virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::box_data> data();
|
std::shared_ptr<::streamfx::gfx::blur::box_data> data();
|
||||||
|
|
||||||
public: // Singleton
|
public: // Singleton
|
||||||
static ::gfx::blur::box_factory& get();
|
static ::streamfx::gfx::blur::box_factory& get();
|
||||||
};
|
};
|
||||||
|
|
||||||
class box : public ::gfx::blur::base {
|
class box : public ::streamfx::gfx::blur::base {
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<::gfx::blur::box_data> _data;
|
std::shared_ptr<::streamfx::gfx::blur::box_data> _data;
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
|
@ -97,7 +97,7 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_size() override;
|
virtual double_t get_size() override;
|
||||||
virtual void set_size(double_t width) override;
|
virtual void set_size(double_t width) override;
|
||||||
|
@ -111,13 +111,13 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_directional : public ::gfx::blur::box, public ::gfx::blur::base_angle {
|
class box_directional : public ::streamfx::gfx::blur::box, public ::streamfx::gfx::blur::base_angle {
|
||||||
double_t _angle;
|
double_t _angle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
box_directional();
|
box_directional();
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
@ -125,14 +125,14 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_rotational : public ::gfx::blur::box,
|
class box_rotational : public ::streamfx::gfx::blur::box,
|
||||||
public ::gfx::blur::base_angle,
|
public ::streamfx::gfx::blur::base_angle,
|
||||||
public ::gfx::blur::base_center {
|
public ::streamfx::gfx::blur::base_center {
|
||||||
std::pair<double_t, double_t> _center;
|
std::pair<double_t, double_t> _center;
|
||||||
double_t _angle;
|
double_t _angle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual void set_center(double_t x, double_t y) override;
|
virtual void set_center(double_t x, double_t y) override;
|
||||||
virtual void get_center(double_t& x, double_t& y) override;
|
virtual void get_center(double_t& x, double_t& y) override;
|
||||||
|
@ -143,11 +143,11 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class box_zoom : public ::gfx::blur::box, public ::gfx::blur::base_center {
|
class box_zoom : public ::streamfx::gfx::blur::box, public ::streamfx::gfx::blur::base_center {
|
||||||
std::pair<double_t, double_t> _center;
|
std::pair<double_t, double_t> _center;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual void set_center(double_t x, double_t y) override;
|
virtual void set_center(double_t x, double_t y) override;
|
||||||
virtual void get_center(double_t& x, double_t& y) override;
|
virtual void get_center(double_t& x, double_t& y) override;
|
||||||
|
@ -155,4 +155,4 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -48,9 +48,9 @@
|
||||||
// 7: 3 Iteration (8x), Arm Size 8, Offset Scale 1.0
|
// 7: 3 Iteration (8x), Arm Size 8, Offset Scale 1.0
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
#define MAX_LEVELS 16
|
#define ST_MAX_LEVELS 16
|
||||||
|
|
||||||
gfx::blur::dual_filtering_data::dual_filtering_data()
|
streamfx::gfx::blur::dual_filtering_data::dual_filtering_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
try {
|
try {
|
||||||
|
@ -61,129 +61,130 @@ gfx::blur::dual_filtering_data::dual_filtering_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::dual_filtering_data::~dual_filtering_data()
|
streamfx::gfx::blur::dual_filtering_data::~dual_filtering_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::obs::gs::effect gfx::blur::dual_filtering_data::get_effect()
|
streamfx::obs::gs::effect streamfx::gfx::blur::dual_filtering_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::dual_filtering_factory::dual_filtering_factory() {}
|
streamfx::gfx::blur::dual_filtering_factory::dual_filtering_factory() {}
|
||||||
|
|
||||||
gfx::blur::dual_filtering_factory::~dual_filtering_factory() {}
|
streamfx::gfx::blur::dual_filtering_factory::~dual_filtering_factory() {}
|
||||||
|
|
||||||
bool gfx::blur::dual_filtering_factory::is_type_supported(::gfx::blur::type type)
|
bool streamfx::gfx::blur::dual_filtering_factory::is_type_supported(::streamfx::gfx::blur::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::base> gfx::blur::dual_filtering_factory::create(::gfx::blur::type type)
|
std::shared_ptr<::streamfx::gfx::blur::base>
|
||||||
|
streamfx::gfx::blur::dual_filtering_factory::create(::streamfx::gfx::blur::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return std::make_shared<::gfx::blur::dual_filtering>();
|
return std::make_shared<::streamfx::gfx::blur::dual_filtering>();
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Invalid type.");
|
throw std::runtime_error("Invalid type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_min_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_min_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.);
|
return double_t(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_step_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_step_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.);
|
return double_t(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_max_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_max_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(MAX_LEVELS);
|
return double_t(ST_MAX_LEVELS);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_min_angle(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_min_angle(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_step_angle(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_step_angle(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_max_angle(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_max_angle(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::blur::dual_filtering_factory::is_step_scale_supported(::gfx::blur::type)
|
bool streamfx::gfx::blur::dual_filtering_factory::is_step_scale_supported(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_min_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_min_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_step_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_step_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_max_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_max_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_min_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_min_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_step_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_step_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering_factory::get_max_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::dual_filtering_factory::get_max_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0);
|
return double_t(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::dual_filtering_data> gfx::blur::dual_filtering_factory::data()
|
std::shared_ptr<::streamfx::gfx::blur::dual_filtering_data> streamfx::gfx::blur::dual_filtering_factory::data()
|
||||||
{
|
{
|
||||||
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<::streamfx::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<::streamfx::gfx::blur::dual_filtering_data>();
|
||||||
_data = data;
|
_data = data;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::dual_filtering_factory& gfx::blur::dual_filtering_factory::get()
|
::streamfx::gfx::blur::dual_filtering_factory& streamfx::gfx::blur::dual_filtering_factory::get()
|
||||||
{
|
{
|
||||||
static ::gfx::blur::dual_filtering_factory instance;
|
static ::streamfx::gfx::blur::dual_filtering_factory instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::dual_filtering::dual_filtering()
|
streamfx::gfx::blur::dual_filtering::dual_filtering()
|
||||||
: _data(::gfx::blur::dual_filtering_factory::get().data()), _size(0), _size_iterations(0)
|
: _data(::streamfx::gfx::blur::dual_filtering_factory::get().data()), _size(0), _size_iterations(0)
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_rts.resize(MAX_LEVELS + 1);
|
_rts.resize(ST_MAX_LEVELS + 1);
|
||||||
for (std::size_t n = 0; n <= MAX_LEVELS; n++) {
|
for (std::size_t n = 0; n <= ST_MAX_LEVELS; n++) {
|
||||||
gs_color_format cf = GS_RGBA;
|
gs_color_format cf = GS_RGBA;
|
||||||
#if 0
|
#if 0
|
||||||
cf = GS_RGBA16F;
|
cf = GS_RGBA16F;
|
||||||
|
@ -194,37 +195,37 @@ gfx::blur::dual_filtering::dual_filtering()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::dual_filtering::~dual_filtering() {}
|
streamfx::gfx::blur::dual_filtering::~dual_filtering() {}
|
||||||
|
|
||||||
void gfx::blur::dual_filtering::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
void streamfx::gfx::blur::dual_filtering::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::dual_filtering::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::dual_filtering::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Area;
|
return ::streamfx::gfx::blur::type::Area;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::dual_filtering::get_size()
|
double_t streamfx::gfx::blur::dual_filtering::get_size()
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::dual_filtering::set_size(double_t width)
|
void streamfx::gfx::blur::dual_filtering::set_size(double_t width)
|
||||||
{
|
{
|
||||||
_size = width;
|
_size = width;
|
||||||
_size_iterations = size_t(round(width));
|
_size_iterations = size_t(round(width));
|
||||||
if (_size_iterations >= MAX_LEVELS) {
|
if (_size_iterations >= ST_MAX_LEVELS) {
|
||||||
_size_iterations = MAX_LEVELS;
|
_size_iterations = ST_MAX_LEVELS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::dual_filtering::set_step_scale(double_t, double_t) {}
|
void streamfx::gfx::blur::dual_filtering::set_step_scale(double_t, double_t) {}
|
||||||
|
|
||||||
void gfx::blur::dual_filtering::get_step_scale(double_t&, double_t&) {}
|
void streamfx::gfx::blur::dual_filtering::get_step_scale(double_t&, double_t&) {}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::dual_filtering::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -327,7 +328,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::render(
|
||||||
return _rts[0]->get_texture();
|
return _rts[0]->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::dual_filtering::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::dual_filtering::get()
|
||||||
{
|
{
|
||||||
return _rts[0]->get_texture();
|
return _rts[0]->get_texture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class dual_filtering_data {
|
class dual_filtering_data {
|
||||||
streamfx::obs::gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
@ -36,52 +36,52 @@ namespace gfx {
|
||||||
streamfx::obs::gs::effect get_effect();
|
streamfx::obs::gs::effect get_effect();
|
||||||
};
|
};
|
||||||
|
|
||||||
class dual_filtering_factory : public ::gfx::blur::ifactory {
|
class dual_filtering_factory : public ::streamfx::gfx::blur::ifactory {
|
||||||
std::mutex _data_lock;
|
std::mutex _data_lock;
|
||||||
std::weak_ptr<::gfx::blur::dual_filtering_data> _data;
|
std::weak_ptr<::streamfx::gfx::blur::dual_filtering_data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dual_filtering_factory();
|
dual_filtering_factory();
|
||||||
virtual ~dual_filtering_factory() override;
|
virtual ~dual_filtering_factory() override;
|
||||||
|
|
||||||
virtual bool is_type_supported(::gfx::blur::type type) override;
|
virtual bool is_type_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override;
|
virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_size(::gfx::blur::type type) override;
|
virtual double_t get_min_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_size(::gfx::blur::type type) override;
|
virtual double_t get_step_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_size(::gfx::blur::type type) override;
|
virtual double_t get_max_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_angle(::gfx::blur::type type) override;
|
virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_angle(::gfx::blur::type type) override;
|
virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_angle(::gfx::blur::type type) override;
|
virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual bool is_step_scale_supported(::gfx::blur::type type) override;
|
virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::dual_filtering_data> data();
|
std::shared_ptr<::streamfx::gfx::blur::dual_filtering_data> data();
|
||||||
|
|
||||||
public: // Singleton
|
public: // Singleton
|
||||||
static ::gfx::blur::dual_filtering_factory& get();
|
static ::streamfx::gfx::blur::dual_filtering_factory& get();
|
||||||
};
|
};
|
||||||
|
|
||||||
class dual_filtering : public ::gfx::blur::base {
|
class dual_filtering : public ::streamfx::gfx::blur::base {
|
||||||
std::shared_ptr<::gfx::blur::dual_filtering_data> _data;
|
std::shared_ptr<::streamfx::gfx::blur::dual_filtering_data> _data;
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::size_t _size_iterations;
|
std::size_t _size_iterations;
|
||||||
|
@ -96,7 +96,7 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_size() override;
|
virtual double_t get_size() override;
|
||||||
|
|
||||||
|
@ -111,4 +111,4 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -33,29 +33,29 @@
|
||||||
// function first goes up at the point, and then once we pass the critical point
|
// function first goes up at the point, and then once we pass the critical point
|
||||||
// will go down again and it is not handled well. This is a pretty basic
|
// will go down again and it is not handled well. This is a pretty basic
|
||||||
// approximation anyway at the moment.
|
// approximation anyway at the moment.
|
||||||
#define MAX_KERNEL_SIZE 128
|
#define ST_MAX_KERNEL_SIZE 128
|
||||||
#define MAX_BLUR_SIZE (MAX_KERNEL_SIZE - 1)
|
#define ST_MAX_BLUR_SIZE (ST_MAX_KERNEL_SIZE - 1)
|
||||||
#define SEARCH_DENSITY double_t(1. / 500.)
|
#define ST_SEARCH_DENSITY double_t(1. / 500.)
|
||||||
#define SEARCH_THRESHOLD double_t(1. / (MAX_KERNEL_SIZE * 5))
|
#define ST_SEARCH_THRESHOLD double_t(1. / (ST_MAX_KERNEL_SIZE * 5))
|
||||||
#define SEARCH_EXTENSION 1
|
#define ST_SEARCH_EXTENSION 1
|
||||||
#define SEARCH_RANGE MAX_KERNEL_SIZE * 2
|
#define ST_SEARCH_RANGE ST_MAX_KERNEL_SIZE * 2
|
||||||
|
|
||||||
gfx::blur::gaussian_linear_data::gaussian_linear_data()
|
streamfx::gfx::blur::gaussian_linear_data::gaussian_linear_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect =
|
_effect =
|
||||||
streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian-linear.effect").u8string());
|
streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian-linear.effect").u8string());
|
||||||
|
|
||||||
// Precalculate Kernels
|
// Precalculate Kernels
|
||||||
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
|
for (std::size_t kernel_size = 1; kernel_size <= ST_MAX_BLUR_SIZE; kernel_size++) {
|
||||||
std::vector<double_t> kernel_math(MAX_KERNEL_SIZE);
|
std::vector<double_t> kernel_math(ST_MAX_KERNEL_SIZE);
|
||||||
std::vector<float_t> kernel_data(MAX_KERNEL_SIZE);
|
std::vector<float_t> kernel_data(ST_MAX_KERNEL_SIZE);
|
||||||
double_t actual_width = 1.;
|
double_t actual_width = 1.;
|
||||||
|
|
||||||
// Find actual kernel width.
|
// Find actual kernel width.
|
||||||
for (double_t h = SEARCH_DENSITY; h < SEARCH_RANGE; h += SEARCH_DENSITY) {
|
for (double_t h = ST_SEARCH_DENSITY; h < ST_SEARCH_RANGE; h += ST_SEARCH_DENSITY) {
|
||||||
if (streamfx::util::math::gaussian<double_t>(double_t(kernel_size + SEARCH_EXTENSION), h)
|
if (streamfx::util::math::gaussian<double_t>(double_t(kernel_size + ST_SEARCH_EXTENSION), h)
|
||||||
> SEARCH_THRESHOLD) {
|
> ST_SEARCH_THRESHOLD) {
|
||||||
actual_width = h;
|
actual_width = h;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -78,158 +78,159 @@ gfx::blur::gaussian_linear_data::gaussian_linear_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear_data::~gaussian_linear_data()
|
streamfx::gfx::blur::gaussian_linear_data::~gaussian_linear_data()
|
||||||
{
|
{
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::obs::gs::effect gfx::blur::gaussian_linear_data::get_effect()
|
streamfx::obs::gs::effect streamfx::gfx::blur::gaussian_linear_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float_t> const& gfx::blur::gaussian_linear_data::get_kernel(std::size_t width)
|
std::vector<float_t> const& streamfx::gfx::blur::gaussian_linear_data::get_kernel(std::size_t width)
|
||||||
{
|
{
|
||||||
if (width < 1)
|
if (width < 1)
|
||||||
width = 1;
|
width = 1;
|
||||||
if (width > MAX_BLUR_SIZE)
|
if (width > ST_MAX_BLUR_SIZE)
|
||||||
width = MAX_BLUR_SIZE;
|
width = ST_MAX_BLUR_SIZE;
|
||||||
width -= 1;
|
width -= 1;
|
||||||
return _kernels[width];
|
return _kernels[width];
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear_factory::gaussian_linear_factory() {}
|
streamfx::gfx::blur::gaussian_linear_factory::gaussian_linear_factory() {}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear_factory::~gaussian_linear_factory() {}
|
streamfx::gfx::blur::gaussian_linear_factory::~gaussian_linear_factory() {}
|
||||||
|
|
||||||
bool gfx::blur::gaussian_linear_factory::is_type_supported(::gfx::blur::type v)
|
bool streamfx::gfx::blur::gaussian_linear_factory::is_type_supported(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::base> gfx::blur::gaussian_linear_factory::create(::gfx::blur::type v)
|
std::shared_ptr<::streamfx::gfx::blur::base>
|
||||||
|
streamfx::gfx::blur::gaussian_linear_factory::create(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return std::make_shared<::gfx::blur::gaussian_linear>();
|
return std::make_shared<::streamfx::gfx::blur::gaussian_linear>();
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return std::static_pointer_cast<::gfx::blur::gaussian_linear>(
|
return std::static_pointer_cast<::streamfx::gfx::blur::gaussian_linear>(
|
||||||
std::make_shared<::gfx::blur::gaussian_linear_directional>());
|
std::make_shared<::streamfx::gfx::blur::gaussian_linear_directional>());
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Invalid type.");
|
throw std::runtime_error("Invalid type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_min_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_step_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_max_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(MAX_BLUR_SIZE);
|
return double_t(ST_MAX_BLUR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_min_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return -180.0;
|
return -180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_step_angle(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_angle(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_max_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return 180.0;
|
return 180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::blur::gaussian_linear_factory::is_step_scale_supported(::gfx::blur::type v)
|
bool streamfx::gfx::blur::gaussian_linear_factory::is_step_scale_supported(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
case ::gfx::blur::type::Zoom:
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_min_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_step_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_max_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_min_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_min_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_step_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_step_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_factory::get_max_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_linear_factory::get_max_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::gaussian_linear_data> gfx::blur::gaussian_linear_factory::data()
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_linear_data> streamfx::gfx::blur::gaussian_linear_factory::data()
|
||||||
{
|
{
|
||||||
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<::streamfx::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<::streamfx::gfx::blur::gaussian_linear_data>();
|
||||||
_data = data;
|
_data = data;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::gaussian_linear_factory& gfx::blur::gaussian_linear_factory::get()
|
::streamfx::gfx::blur::gaussian_linear_factory& streamfx::gfx::blur::gaussian_linear_factory::get()
|
||||||
{
|
{
|
||||||
static ::gfx::blur::gaussian_linear_factory instance;
|
static ::streamfx::gfx::blur::gaussian_linear_factory instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear::gaussian_linear()
|
streamfx::gfx::blur::gaussian_linear::gaussian_linear()
|
||||||
: _data(::gfx::blur::gaussian_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
: _data(::streamfx::gfx::blur::gaussian_linear_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -237,55 +238,55 @@ gfx::blur::gaussian_linear::gaussian_linear()
|
||||||
_rendertarget2 = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear::~gaussian_linear() {}
|
streamfx::gfx::blur::gaussian_linear::~gaussian_linear() {}
|
||||||
|
|
||||||
void gfx::blur::gaussian_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
void streamfx::gfx::blur::gaussian_linear::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::gaussian_linear::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_linear::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Area;
|
return ::streamfx::gfx::blur::type::Area;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear::get_size()
|
double_t streamfx::gfx::blur::gaussian_linear::get_size()
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_linear::set_size(double_t width)
|
void streamfx::gfx::blur::gaussian_linear::set_size(double_t width)
|
||||||
{
|
{
|
||||||
if (width < 1.)
|
if (width < 1.)
|
||||||
width = 1.;
|
width = 1.;
|
||||||
if (width > MAX_BLUR_SIZE)
|
if (width > ST_MAX_BLUR_SIZE)
|
||||||
width = MAX_BLUR_SIZE;
|
width = ST_MAX_BLUR_SIZE;
|
||||||
_size = width;
|
_size = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_linear::set_step_scale(double_t x, double_t y)
|
void streamfx::gfx::blur::gaussian_linear::set_step_scale(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
_step_scale.first = x;
|
_step_scale.first = x;
|
||||||
_step_scale.second = y;
|
_step_scale.second = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_linear::get_step_scale(double_t& x, double_t& y)
|
void streamfx::gfx::blur::gaussian_linear::get_step_scale(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = _step_scale.first;
|
x = _step_scale.first;
|
||||||
y = _step_scale.second;
|
y = _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear::get_step_scale_x()
|
double_t streamfx::gfx::blur::gaussian_linear::get_step_scale_x()
|
||||||
{
|
{
|
||||||
return _step_scale.first;
|
return _step_scale.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear::get_step_scale_y()
|
double_t streamfx::gfx::blur::gaussian_linear::get_step_scale_y()
|
||||||
{
|
{
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_linear::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -320,7 +321,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::render
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||||
effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE);
|
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||||
|
|
||||||
// First Pass
|
// First Pass
|
||||||
if (_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
|
if (_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
|
||||||
|
@ -366,31 +367,31 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::render
|
||||||
return this->get();
|
return this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_linear::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear_directional::gaussian_linear_directional() : _angle(0.) {}
|
streamfx::gfx::blur::gaussian_linear_directional::gaussian_linear_directional() : _angle(0.) {}
|
||||||
|
|
||||||
gfx::blur::gaussian_linear_directional::~gaussian_linear_directional() {}
|
streamfx::gfx::blur::gaussian_linear_directional::~gaussian_linear_directional() {}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::gaussian_linear_directional::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_linear_directional::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Directional;
|
return ::streamfx::gfx::blur::type::Directional;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_linear_directional::get_angle()
|
double_t streamfx::gfx::blur::gaussian_linear_directional::get_angle()
|
||||||
{
|
{
|
||||||
return D_RAD_TO_DEG(_angle);
|
return D_RAD_TO_DEG(_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_linear_directional::set_angle(double_t angle)
|
void streamfx::gfx::blur::gaussian_linear_directional::set_angle(double_t angle)
|
||||||
{
|
{
|
||||||
_angle = D_DEG_TO_RAD(angle);
|
_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_linear_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -428,7 +429,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_linear_directi
|
||||||
.set_float2(float_t(1.f / width * cos(_angle)), float_t(1.f / height * sin(_angle)));
|
.set_float2(float_t(1.f / width * cos(_angle)), float_t(1.f / height * sin(_angle)));
|
||||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||||
effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE);
|
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||||
|
|
||||||
// First Pass
|
// First Pass
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class gaussian_linear_data {
|
class gaussian_linear_data {
|
||||||
streamfx::obs::gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
@ -39,53 +39,53 @@ namespace gfx {
|
||||||
std::vector<float_t> const& get_kernel(std::size_t width);
|
std::vector<float_t> const& get_kernel(std::size_t width);
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_linear_factory : public ::gfx::blur::ifactory {
|
class gaussian_linear_factory : public ::streamfx::gfx::blur::ifactory {
|
||||||
std::mutex _data_lock;
|
std::mutex _data_lock;
|
||||||
std::weak_ptr<::gfx::blur::gaussian_linear_data> _data;
|
std::weak_ptr<::streamfx::gfx::blur::gaussian_linear_data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian_linear_factory();
|
gaussian_linear_factory();
|
||||||
virtual ~gaussian_linear_factory() override;
|
virtual ~gaussian_linear_factory() override;
|
||||||
|
|
||||||
virtual bool is_type_supported(::gfx::blur::type type) override;
|
virtual bool is_type_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override;
|
virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_size(::gfx::blur::type type) override;
|
virtual double_t get_min_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_size(::gfx::blur::type type) override;
|
virtual double_t get_step_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_size(::gfx::blur::type type) override;
|
virtual double_t get_max_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_angle(::gfx::blur::type type) override;
|
virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_angle(::gfx::blur::type type) override;
|
virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_angle(::gfx::blur::type type) override;
|
virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual bool is_step_scale_supported(::gfx::blur::type type) override;
|
virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::gaussian_linear_data> data();
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_linear_data> data();
|
||||||
|
|
||||||
public: // Singleton
|
public: // Singleton
|
||||||
static ::gfx::blur::gaussian_linear_factory& get();
|
static ::streamfx::gfx::blur::gaussian_linear_factory& get();
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_linear : public ::gfx::blur::base {
|
class gaussian_linear : public ::streamfx::gfx::blur::base {
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<::gfx::blur::gaussian_linear_data> _data;
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_linear_data> _data;
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
|
@ -101,7 +101,7 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_size() override;
|
virtual double_t get_size() override;
|
||||||
|
|
||||||
|
@ -120,14 +120,15 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_linear_directional : public ::gfx::blur::gaussian_linear, public ::gfx::blur::base_angle {
|
class gaussian_linear_directional : public ::streamfx::gfx::blur::gaussian_linear,
|
||||||
|
public ::streamfx::gfx::blur::base_angle {
|
||||||
double_t _angle;
|
double_t _angle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian_linear_directional();
|
gaussian_linear_directional();
|
||||||
virtual ~gaussian_linear_directional() override;
|
virtual ~gaussian_linear_directional() override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
|
|
||||||
|
@ -136,4 +137,4 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -34,28 +34,28 @@
|
||||||
// function first goes up at the point, and then once we pass the critical point
|
// function first goes up at the point, and then once we pass the critical point
|
||||||
// will go down again and it is not handled well. This is a pretty basic
|
// will go down again and it is not handled well. This is a pretty basic
|
||||||
// approximation anyway at the moment.
|
// approximation anyway at the moment.
|
||||||
#define MAX_KERNEL_SIZE 128
|
#define ST_MAX_KERNEL_SIZE 128
|
||||||
#define MAX_BLUR_SIZE (MAX_KERNEL_SIZE - 1)
|
#define ST_MAX_BLUR_SIZE (ST_MAX_KERNEL_SIZE - 1)
|
||||||
#define SEARCH_DENSITY double_t(1. / 500.)
|
#define ST_SEARCH_DENSITY double_t(1. / 500.)
|
||||||
#define SEARCH_THRESHOLD double_t(1. / (MAX_KERNEL_SIZE * 5))
|
#define ST_SEARCH_THRESHOLD double_t(1. / (ST_MAX_KERNEL_SIZE * 5))
|
||||||
#define SEARCH_EXTENSION 1
|
#define ST_SEARCH_EXTENSION 1
|
||||||
#define SEARCH_RANGE MAX_KERNEL_SIZE * 2
|
#define ST_SEARCH_RANGE ST_MAX_KERNEL_SIZE * 2
|
||||||
|
|
||||||
gfx::blur::gaussian_data::gaussian_data()
|
streamfx::gfx::blur::gaussian_data::gaussian_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian.effect").u8string());
|
_effect = streamfx::obs::gs::effect::create(streamfx::data_file_path("effects/blur/gaussian.effect").u8string());
|
||||||
|
|
||||||
// Precalculate Kernels
|
// Precalculate Kernels
|
||||||
for (std::size_t kernel_size = 1; kernel_size <= MAX_BLUR_SIZE; kernel_size++) {
|
for (std::size_t kernel_size = 1; kernel_size <= ST_MAX_BLUR_SIZE; kernel_size++) {
|
||||||
std::vector<double_t> kernel_math(MAX_KERNEL_SIZE);
|
std::vector<double_t> kernel_math(ST_MAX_KERNEL_SIZE);
|
||||||
std::vector<float_t> kernel_data(MAX_KERNEL_SIZE);
|
std::vector<float_t> kernel_data(ST_MAX_KERNEL_SIZE);
|
||||||
double_t actual_width = 1.;
|
double_t actual_width = 1.;
|
||||||
|
|
||||||
// Find actual kernel width.
|
// Find actual kernel width.
|
||||||
for (double_t h = SEARCH_DENSITY; h < SEARCH_RANGE; h += SEARCH_DENSITY) {
|
for (double_t h = ST_SEARCH_DENSITY; h < ST_SEARCH_RANGE; h += ST_SEARCH_DENSITY) {
|
||||||
if (streamfx::util::math::gaussian<double_t>(double_t(kernel_size + SEARCH_EXTENSION), h)
|
if (streamfx::util::math::gaussian<double_t>(double_t(kernel_size + ST_SEARCH_EXTENSION), h)
|
||||||
> SEARCH_THRESHOLD) {
|
> ST_SEARCH_THRESHOLD) {
|
||||||
actual_width = h;
|
actual_width = h;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -78,220 +78,223 @@ gfx::blur::gaussian_data::gaussian_data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_data::~gaussian_data()
|
streamfx::gfx::blur::gaussian_data::~gaussian_data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_effect.reset();
|
_effect.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::obs::gs::effect gfx::blur::gaussian_data::get_effect()
|
streamfx::obs::gs::effect streamfx::gfx::blur::gaussian_data::get_effect()
|
||||||
{
|
{
|
||||||
return _effect;
|
return _effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float_t> const& gfx::blur::gaussian_data::get_kernel(std::size_t width)
|
std::vector<float_t> const& streamfx::gfx::blur::gaussian_data::get_kernel(std::size_t width)
|
||||||
{
|
{
|
||||||
if (width < 1)
|
if (width < 1)
|
||||||
width = 1;
|
width = 1;
|
||||||
if (width > MAX_BLUR_SIZE)
|
if (width > ST_MAX_BLUR_SIZE)
|
||||||
width = MAX_BLUR_SIZE;
|
width = ST_MAX_BLUR_SIZE;
|
||||||
width -= 1;
|
width -= 1;
|
||||||
return _kernels[width];
|
return _kernels[width];
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_factory::gaussian_factory() {}
|
streamfx::gfx::blur::gaussian_factory::gaussian_factory() {}
|
||||||
|
|
||||||
gfx::blur::gaussian_factory::~gaussian_factory() {}
|
streamfx::gfx::blur::gaussian_factory::~gaussian_factory() {}
|
||||||
|
|
||||||
bool gfx::blur::gaussian_factory::is_type_supported(::gfx::blur::type v)
|
bool streamfx::gfx::blur::gaussian_factory::is_type_supported(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return true;
|
return true;
|
||||||
case ::gfx::blur::type::Zoom:
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::base> gfx::blur::gaussian_factory::create(::gfx::blur::type v)
|
std::shared_ptr<::streamfx::gfx::blur::base>
|
||||||
|
streamfx::gfx::blur::gaussian_factory::create(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
return std::make_shared<::gfx::blur::gaussian>();
|
return std::make_shared<::streamfx::gfx::blur::gaussian>();
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return std::static_pointer_cast<::gfx::blur::gaussian>(std::make_shared<::gfx::blur::gaussian_directional>());
|
return std::static_pointer_cast<::streamfx::gfx::blur::gaussian>(
|
||||||
case ::gfx::blur::type::Rotational:
|
std::make_shared<::streamfx::gfx::blur::gaussian_directional>());
|
||||||
return std::make_shared<::gfx::blur::gaussian_rotational>();
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
case ::gfx::blur::type::Zoom:
|
return std::make_shared<::streamfx::gfx::blur::gaussian_rotational>();
|
||||||
return std::make_shared<::gfx::blur::gaussian_zoom>();
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
|
return std::make_shared<::streamfx::gfx::blur::gaussian_zoom>();
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Invalid type.");
|
throw std::runtime_error("Invalid type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_min_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_min_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_step_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_step_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1.0);
|
return double_t(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_max_size(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_max_size(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(MAX_BLUR_SIZE);
|
return double_t(ST_MAX_BLUR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_min_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::gaussian_factory::get_min_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return -180.0;
|
return -180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_step_angle(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_step_angle(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_max_angle(::gfx::blur::type v)
|
double_t streamfx::gfx::blur::gaussian_factory::get_max_angle(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
case ::gfx::blur::type::Rotational:
|
case ::streamfx::gfx::blur::type::Rotational:
|
||||||
return 180.0;
|
return 180.0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::blur::gaussian_factory::is_step_scale_supported(::gfx::blur::type v)
|
bool streamfx::gfx::blur::gaussian_factory::is_step_scale_supported(::streamfx::gfx::blur::type v)
|
||||||
{
|
{
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case ::gfx::blur::type::Area:
|
case ::streamfx::gfx::blur::type::Area:
|
||||||
case ::gfx::blur::type::Zoom:
|
case ::streamfx::gfx::blur::type::Zoom:
|
||||||
case ::gfx::blur::type::Directional:
|
case ::streamfx::gfx::blur::type::Directional:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_min_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_min_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_step_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_step_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_max_step_scale_x(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_max_step_scale_x(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_min_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_min_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_step_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_step_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(0.01);
|
return double_t(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_factory::get_max_step_scale_y(::gfx::blur::type)
|
double_t streamfx::gfx::blur::gaussian_factory::get_max_step_scale_y(::streamfx::gfx::blur::type)
|
||||||
{
|
{
|
||||||
return double_t(1000.0);
|
return double_t(1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::gaussian_data> gfx::blur::gaussian_factory::data()
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_data> streamfx::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<::streamfx::gfx::blur::gaussian_data> data = _data.lock();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = std::make_shared<::gfx::blur::gaussian_data>();
|
data = std::make_shared<::streamfx::gfx::blur::gaussian_data>();
|
||||||
_data = data;
|
_data = data;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::gaussian_factory& gfx::blur::gaussian_factory::get()
|
::streamfx::gfx::blur::gaussian_factory& streamfx::gfx::blur::gaussian_factory::get()
|
||||||
{
|
{
|
||||||
static ::gfx::blur::gaussian_factory instance;
|
static ::streamfx::gfx::blur::gaussian_factory instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian::gaussian() : _data(::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
streamfx::gfx::blur::gaussian::gaussian()
|
||||||
|
: _data(::streamfx::gfx::blur::gaussian_factory::get().data()), _size(1.), _step_scale({1., 1.})
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_rendertarget = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
_rendertarget2 = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rendertarget2 = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian::~gaussian() {}
|
streamfx::gfx::blur::gaussian::~gaussian() {}
|
||||||
|
|
||||||
void gfx::blur::gaussian::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
void streamfx::gfx::blur::gaussian::set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
_input_texture = texture;
|
_input_texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::gaussian::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Area;
|
return ::streamfx::gfx::blur::type::Area;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian::get_size()
|
double_t streamfx::gfx::blur::gaussian::get_size()
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian::set_size(double_t width)
|
void streamfx::gfx::blur::gaussian::set_size(double_t width)
|
||||||
{
|
{
|
||||||
if (width < 1.)
|
if (width < 1.)
|
||||||
width = 1.;
|
width = 1.;
|
||||||
if (width > MAX_BLUR_SIZE)
|
if (width > ST_MAX_BLUR_SIZE)
|
||||||
width = MAX_BLUR_SIZE;
|
width = ST_MAX_BLUR_SIZE;
|
||||||
_size = width;
|
_size = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian::set_step_scale(double_t x, double_t y)
|
void streamfx::gfx::blur::gaussian::set_step_scale(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
_step_scale.first = x;
|
_step_scale.first = x;
|
||||||
_step_scale.second = y;
|
_step_scale.second = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian::get_step_scale(double_t& x, double_t& y)
|
void streamfx::gfx::blur::gaussian::get_step_scale(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = _step_scale.first;
|
x = _step_scale.first;
|
||||||
y = _step_scale.second;
|
y = _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian::get_step_scale_x()
|
double_t streamfx::gfx::blur::gaussian::get_step_scale_x()
|
||||||
{
|
{
|
||||||
return _step_scale.first;
|
return _step_scale.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian::get_step_scale_y()
|
double_t streamfx::gfx::blur::gaussian::get_step_scale_y()
|
||||||
{
|
{
|
||||||
return _step_scale.second;
|
return _step_scale.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -326,7 +329,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::render()
|
||||||
effect.get_parameter("pImage").set_texture(_input_texture);
|
effect.get_parameter("pImage").set_texture(_input_texture);
|
||||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||||
effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE);
|
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||||
|
|
||||||
// First Pass
|
// First Pass
|
||||||
if (_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
|
if (_step_scale.first > std::numeric_limits<double_t>::epsilon()) {
|
||||||
|
@ -372,31 +375,31 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::render()
|
||||||
return this->get();
|
return this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian::get()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian::get()
|
||||||
{
|
{
|
||||||
return _rendertarget->get_texture();
|
return _rendertarget->get_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::blur::gaussian_directional::gaussian_directional() : m_angle(0.) {}
|
streamfx::gfx::blur::gaussian_directional::gaussian_directional() : m_angle(0.) {}
|
||||||
|
|
||||||
gfx::blur::gaussian_directional::~gaussian_directional() {}
|
streamfx::gfx::blur::gaussian_directional::~gaussian_directional() {}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::gaussian_directional::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_directional::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Directional;
|
return ::streamfx::gfx::blur::type::Directional;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_directional::get_angle()
|
double_t streamfx::gfx::blur::gaussian_directional::get_angle()
|
||||||
{
|
{
|
||||||
return D_RAD_TO_DEG(m_angle);
|
return D_RAD_TO_DEG(m_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_directional::set_angle(double_t angle)
|
void streamfx::gfx::blur::gaussian_directional::set_angle(double_t angle)
|
||||||
{
|
{
|
||||||
m_angle = D_DEG_TO_RAD(angle);
|
m_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_directional::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_directional::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -434,7 +437,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_directional::r
|
||||||
.set_float2(float_t(1.f / width * cos(m_angle)), float_t(1.f / height * sin(m_angle)));
|
.set_float2(float_t(1.f / width * cos(m_angle)), float_t(1.f / height * sin(m_angle)));
|
||||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||||
effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE);
|
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||||
|
|
||||||
// First Pass
|
// First Pass
|
||||||
{
|
{
|
||||||
|
@ -450,12 +453,12 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_directional::r
|
||||||
return this->get();
|
return this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::gaussian_rotational::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_rotational::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Rotational;
|
return ::streamfx::gfx::blur::type::Rotational;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_rotational::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_rotational::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -494,7 +497,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_rotational::re
|
||||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||||
effect.get_parameter("pAngle").set_float(float_t(m_angle / _size));
|
effect.get_parameter("pAngle").set_float(float_t(m_angle / _size));
|
||||||
effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second));
|
effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second));
|
||||||
effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE);
|
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||||
|
|
||||||
// First Pass
|
// First Pass
|
||||||
{
|
{
|
||||||
|
@ -510,34 +513,34 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_rotational::re
|
||||||
return this->get();
|
return this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_rotational::set_center(double_t x, double_t y)
|
void streamfx::gfx::blur::gaussian_rotational::set_center(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
m_center.first = x;
|
m_center.first = x;
|
||||||
m_center.second = y;
|
m_center.second = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_rotational::get_center(double_t& x, double_t& y)
|
void streamfx::gfx::blur::gaussian_rotational::get_center(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = m_center.first;
|
x = m_center.first;
|
||||||
y = m_center.second;
|
y = m_center.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_t gfx::blur::gaussian_rotational::get_angle()
|
double_t streamfx::gfx::blur::gaussian_rotational::get_angle()
|
||||||
{
|
{
|
||||||
return double_t(D_RAD_TO_DEG(m_angle));
|
return double_t(D_RAD_TO_DEG(m_angle));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_rotational::set_angle(double_t angle)
|
void streamfx::gfx::blur::gaussian_rotational::set_angle(double_t angle)
|
||||||
{
|
{
|
||||||
m_angle = D_DEG_TO_RAD(angle);
|
m_angle = D_DEG_TO_RAD(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
::gfx::blur::type gfx::blur::gaussian_zoom::get_type()
|
::streamfx::gfx::blur::type streamfx::gfx::blur::gaussian_zoom::get_type()
|
||||||
{
|
{
|
||||||
return ::gfx::blur::type::Zoom;
|
return ::streamfx::gfx::blur::type::Zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_zoom::render()
|
std::shared_ptr<::streamfx::obs::gs::texture> streamfx::gfx::blur::gaussian_zoom::render()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -574,7 +577,7 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_zoom::render()
|
||||||
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
effect.get_parameter("pStepScale").set_float2(float_t(_step_scale.first), float_t(_step_scale.second));
|
||||||
effect.get_parameter("pSize").set_float(float_t(_size));
|
effect.get_parameter("pSize").set_float(float_t(_size));
|
||||||
effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second));
|
effect.get_parameter("pCenter").set_float2(float_t(m_center.first), float_t(m_center.second));
|
||||||
effect.get_parameter("pKernel").set_value(kernel.data(), MAX_KERNEL_SIZE);
|
effect.get_parameter("pKernel").set_value(kernel.data(), ST_MAX_KERNEL_SIZE);
|
||||||
|
|
||||||
// First Pass
|
// First Pass
|
||||||
{
|
{
|
||||||
|
@ -590,13 +593,13 @@ std::shared_ptr<::streamfx::obs::gs::texture> gfx::blur::gaussian_zoom::render()
|
||||||
return this->get();
|
return this->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_zoom::set_center(double_t x, double_t y)
|
void streamfx::gfx::blur::gaussian_zoom::set_center(double_t x, double_t y)
|
||||||
{
|
{
|
||||||
m_center.first = x;
|
m_center.first = x;
|
||||||
m_center.second = y;
|
m_center.second = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::blur::gaussian_zoom::get_center(double_t& x, double_t& y)
|
void streamfx::gfx::blur::gaussian_zoom::get_center(double_t& x, double_t& y)
|
||||||
{
|
{
|
||||||
x = m_center.first;
|
x = m_center.first;
|
||||||
y = m_center.second;
|
y = m_center.second;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace blur {
|
namespace blur {
|
||||||
class gaussian_data {
|
class gaussian_data {
|
||||||
streamfx::obs::gs::effect _effect;
|
streamfx::obs::gs::effect _effect;
|
||||||
|
@ -39,53 +39,53 @@ namespace gfx {
|
||||||
std::vector<float_t> const& get_kernel(std::size_t width);
|
std::vector<float_t> const& get_kernel(std::size_t width);
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_factory : public ::gfx::blur::ifactory {
|
class gaussian_factory : public ::streamfx::gfx::blur::ifactory {
|
||||||
std::mutex _data_lock;
|
std::mutex _data_lock;
|
||||||
std::weak_ptr<::gfx::blur::gaussian_data> _data;
|
std::weak_ptr<::streamfx::gfx::blur::gaussian_data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian_factory();
|
gaussian_factory();
|
||||||
virtual ~gaussian_factory() override;
|
virtual ~gaussian_factory() override;
|
||||||
|
|
||||||
virtual bool is_type_supported(::gfx::blur::type type) override;
|
virtual bool is_type_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<::gfx::blur::base> create(::gfx::blur::type type) override;
|
virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_size(::gfx::blur::type type) override;
|
virtual double_t get_min_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_size(::gfx::blur::type type) override;
|
virtual double_t get_step_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_size(::gfx::blur::type type) override;
|
virtual double_t get_max_size(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_angle(::gfx::blur::type type) override;
|
virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_angle(::gfx::blur::type type) override;
|
virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_angle(::gfx::blur::type type) override;
|
virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual bool is_step_scale_supported(::gfx::blur::type type) override;
|
virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_x(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_min_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_step_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
virtual double_t get_max_step_scale_y(::gfx::blur::type type) override;
|
virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override;
|
||||||
|
|
||||||
std::shared_ptr<::gfx::blur::gaussian_data> data();
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_data> data();
|
||||||
|
|
||||||
public: // Singleton
|
public: // Singleton
|
||||||
static ::gfx::blur::gaussian_factory& get();
|
static ::streamfx::gfx::blur::gaussian_factory& get();
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian : public ::gfx::blur::base {
|
class gaussian : public ::streamfx::gfx::blur::base {
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<::gfx::blur::gaussian_data> _data;
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_data> _data;
|
||||||
|
|
||||||
double_t _size;
|
double_t _size;
|
||||||
std::pair<double_t, double_t> _step_scale;
|
std::pair<double_t, double_t> _step_scale;
|
||||||
|
@ -101,7 +101,7 @@ namespace gfx {
|
||||||
|
|
||||||
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_size() override;
|
virtual double_t get_size() override;
|
||||||
|
|
||||||
|
@ -120,14 +120,14 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_directional : public ::gfx::blur::gaussian, public ::gfx::blur::base_angle {
|
class gaussian_directional : public ::streamfx::gfx::blur::gaussian, public ::streamfx::gfx::blur::base_angle {
|
||||||
double_t m_angle;
|
double_t m_angle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gaussian_directional();
|
gaussian_directional();
|
||||||
virtual ~gaussian_directional() override;
|
virtual ~gaussian_directional() override;
|
||||||
|
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual double_t get_angle() override;
|
virtual double_t get_angle() override;
|
||||||
virtual void set_angle(double_t angle) override;
|
virtual void set_angle(double_t angle) override;
|
||||||
|
@ -135,14 +135,14 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_rotational : public ::gfx::blur::gaussian,
|
class gaussian_rotational : public ::streamfx::gfx::blur::gaussian,
|
||||||
public ::gfx::blur::base_angle,
|
public ::streamfx::gfx::blur::base_angle,
|
||||||
public ::gfx::blur::base_center {
|
public ::streamfx::gfx::blur::base_center {
|
||||||
std::pair<double_t, double_t> m_center;
|
std::pair<double_t, double_t> m_center;
|
||||||
double_t m_angle;
|
double_t m_angle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual void set_center(double_t x, double_t y) override;
|
virtual void set_center(double_t x, double_t y) override;
|
||||||
virtual void get_center(double_t& x, double_t& y) override;
|
virtual void get_center(double_t& x, double_t& y) override;
|
||||||
|
@ -153,11 +153,11 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gaussian_zoom : public ::gfx::blur::gaussian, public ::gfx::blur::base_center {
|
class gaussian_zoom : public ::streamfx::gfx::blur::gaussian, public ::streamfx::gfx::blur::base_center {
|
||||||
std::pair<double_t, double_t> m_center;
|
std::pair<double_t, double_t> m_center;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ::gfx::blur::type get_type() override;
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
||||||
|
|
||||||
virtual void set_center(double_t x, double_t y) override;
|
virtual void set_center(double_t x, double_t y) override;
|
||||||
virtual void get_center(double_t& x, double_t& y) override;
|
virtual void get_center(double_t& x, double_t& y) override;
|
||||||
|
@ -165,4 +165,4 @@ namespace gfx {
|
||||||
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
||||||
};
|
};
|
||||||
} // namespace blur
|
} // namespace blur
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
|
|
||||||
gfx::source_texture::~source_texture()
|
streamfx::gfx::source_texture::~source_texture()
|
||||||
{
|
{
|
||||||
if (_child && _parent) {
|
if (_child && _parent) {
|
||||||
obs_source_remove_active_child(_parent->get(), _child->get());
|
obs_source_remove_active_child(_parent->get(), _child->get());
|
||||||
|
@ -29,7 +29,7 @@ gfx::source_texture::~source_texture()
|
||||||
_child.reset();
|
_child.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(obs_source_t* parent)
|
streamfx::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");
|
||||||
|
@ -38,7 +38,7 @@ gfx::source_texture::source_texture(obs_source_t* parent)
|
||||||
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent)
|
streamfx::gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent) : source_texture(_parent)
|
||||||
{
|
{
|
||||||
if (!_source) {
|
if (!_source) {
|
||||||
throw std::invalid_argument("source must not be null");
|
throw std::invalid_argument("source must not be null");
|
||||||
|
@ -49,7 +49,7 @@ gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent
|
||||||
_child = std::make_shared<streamfx::obs::deprecated_source>(_source, true, true);
|
_child = std::make_shared<streamfx::obs::deprecated_source>(_source, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : source_texture(_parent)
|
streamfx::gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : source_texture(_parent)
|
||||||
{
|
{
|
||||||
if (!_name) {
|
if (!_name) {
|
||||||
throw std::invalid_argument("name must not be null");
|
throw std::invalid_argument("name must not be null");
|
||||||
|
@ -60,10 +60,11 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent) : source_texture(_name.c_str(), _parent)
|
streamfx::gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent)
|
||||||
|
: source_texture(_name.c_str(), _parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_source> pchild,
|
streamfx::gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_source> pchild,
|
||||||
std::shared_ptr<streamfx::obs::deprecated_source> pparent)
|
std::shared_ptr<streamfx::obs::deprecated_source> pparent)
|
||||||
{
|
{
|
||||||
if (!pchild) {
|
if (!pchild) {
|
||||||
|
@ -80,11 +81,12 @@ gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_so
|
||||||
this->_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
this->_rt = std::make_shared<streamfx::obs::gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_source> _child, obs_source_t* _parent)
|
streamfx::gfx::source_texture::source_texture(std::shared_ptr<streamfx::obs::deprecated_source> _child,
|
||||||
|
obs_source_t* _parent)
|
||||||
: source_texture(_child, std::make_shared<streamfx::obs::deprecated_source>(_parent, false, false))
|
: source_texture(_child, std::make_shared<streamfx::obs::deprecated_source>(_parent, false, false))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
obs_source_t* gfx::source_texture::get_object()
|
obs_source_t* streamfx::gfx::source_texture::get_object()
|
||||||
{
|
{
|
||||||
if (_child) {
|
if (_child) {
|
||||||
return _child->get();
|
return _child->get();
|
||||||
|
@ -92,12 +94,12 @@ obs_source_t* gfx::source_texture::get_object()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_source_t* gfx::source_texture::get_parent()
|
obs_source_t* streamfx::gfx::source_texture::get_parent()
|
||||||
{
|
{
|
||||||
return _parent->get();
|
return _parent->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::source_texture::clear()
|
void streamfx::gfx::source_texture::clear()
|
||||||
{
|
{
|
||||||
if (_child && _parent) {
|
if (_child && _parent) {
|
||||||
obs_source_remove_active_child(_parent->get(), _child->get());
|
obs_source_remove_active_child(_parent->get(), _child->get());
|
||||||
|
@ -106,7 +108,7 @@ void gfx::source_texture::clear()
|
||||||
_child.reset();
|
_child.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> gfx::source_texture::render(std::size_t width, std::size_t height)
|
std::shared_ptr<streamfx::obs::gs::texture> streamfx::gfx::source_texture::render(std::size_t width, std::size_t height)
|
||||||
{
|
{
|
||||||
if ((width == 0) || (width >= 16384)) {
|
if ((width == 0) || (width >= 16384)) {
|
||||||
throw std::runtime_error("Width too large or too small.");
|
throw std::runtime_error("Width too large or too small.");
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
#include "obs/obs-source.hpp"
|
#include "obs/obs-source.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
class source_texture {
|
class source_texture {
|
||||||
std::shared_ptr<streamfx::obs::deprecated_source> _parent;
|
std::shared_ptr<streamfx::obs::deprecated_source> _parent;
|
||||||
std::shared_ptr<streamfx::obs::deprecated_source> _child;
|
std::shared_ptr<streamfx::obs::deprecated_source> _child;
|
||||||
|
@ -92,4 +92,4 @@ namespace gfx {
|
||||||
return factory_instance;
|
return factory_instance;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -22,16 +22,17 @@
|
||||||
|
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
|
|
||||||
gfx::lut::consumer::consumer()
|
streamfx::gfx::lut::consumer::consumer()
|
||||||
{
|
{
|
||||||
_data = gfx::lut::data::instance();
|
_data = streamfx::gfx::lut::data::instance();
|
||||||
if (!_data->consumer_effect())
|
if (!_data->consumer_effect())
|
||||||
throw std::runtime_error("Unable to get LUT consumer effect.");
|
throw std::runtime_error("Unable to get LUT consumer effect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::lut::consumer::~consumer() {}
|
streamfx::gfx::lut::consumer::~consumer() {}
|
||||||
|
|
||||||
std::shared_ptr<streamfx::obs::gs::effect> gfx::lut::consumer::prepare(gfx::lut::color_depth depth,
|
std::shared_ptr<streamfx::obs::gs::effect>
|
||||||
|
streamfx::gfx::lut::consumer::prepare(streamfx::gfx::lut::color_depth depth,
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> lut)
|
std::shared_ptr<streamfx::obs::gs::texture> lut)
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
@ -62,7 +63,8 @@ std::shared_ptr<streamfx::obs::gs::effect> gfx::lut::consumer::prepare(gfx::lut:
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::lut::consumer::consume(gfx::lut::color_depth depth, std::shared_ptr<streamfx::obs::gs::texture> lut,
|
void streamfx::gfx::lut::consumer::consume(streamfx::gfx::lut::color_depth depth,
|
||||||
|
std::shared_ptr<streamfx::obs::gs::texture> lut,
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> texture)
|
std::shared_ptr<streamfx::obs::gs::texture> texture)
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
|
@ -25,18 +25,18 @@
|
||||||
#include "obs/gs/gs-effect.hpp"
|
#include "obs/gs/gs-effect.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
|
||||||
namespace gfx::lut {
|
namespace streamfx::gfx::lut {
|
||||||
class consumer {
|
class consumer {
|
||||||
std::shared_ptr<gfx::lut::data> _data;
|
std::shared_ptr<streamfx::gfx::lut::data> _data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
consumer();
|
consumer();
|
||||||
~consumer();
|
~consumer();
|
||||||
|
|
||||||
std::shared_ptr<streamfx::obs::gs::effect> prepare(gfx::lut::color_depth depth,
|
std::shared_ptr<streamfx::obs::gs::effect> prepare(streamfx::gfx::lut::color_depth depth,
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> lut);
|
std::shared_ptr<streamfx::obs::gs::texture> lut);
|
||||||
|
|
||||||
void consume(gfx::lut::color_depth depth, std::shared_ptr<streamfx::obs::gs::texture> lut,
|
void consume(streamfx::gfx::lut::color_depth depth, std::shared_ptr<streamfx::obs::gs::texture> lut,
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> texture);
|
std::shared_ptr<streamfx::obs::gs::texture> texture);
|
||||||
};
|
};
|
||||||
} // namespace gfx::lut
|
} // namespace streamfx::gfx::lut
|
||||||
|
|
|
@ -22,34 +22,34 @@
|
||||||
|
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
|
|
||||||
gs_color_format format_from_depth(gfx::lut::color_depth depth)
|
gs_color_format format_from_depth(streamfx::gfx::lut::color_depth depth)
|
||||||
{
|
{
|
||||||
switch (depth) {
|
switch (depth) {
|
||||||
case gfx::lut::color_depth::_2:
|
case streamfx::gfx::lut::color_depth::_2:
|
||||||
case gfx::lut::color_depth::_4:
|
case streamfx::gfx::lut::color_depth::_4:
|
||||||
case gfx::lut::color_depth::_6:
|
case streamfx::gfx::lut::color_depth::_6:
|
||||||
case gfx::lut::color_depth::_8:
|
case streamfx::gfx::lut::color_depth::_8:
|
||||||
return gs_color_format::GS_RGBA;
|
return gs_color_format::GS_RGBA;
|
||||||
case gfx::lut::color_depth::_10:
|
case streamfx::gfx::lut::color_depth::_10:
|
||||||
return gs_color_format::GS_R10G10B10A2;
|
return gs_color_format::GS_R10G10B10A2;
|
||||||
case gfx::lut::color_depth::_12:
|
case streamfx::gfx::lut::color_depth::_12:
|
||||||
case gfx::lut::color_depth::_14:
|
case streamfx::gfx::lut::color_depth::_14:
|
||||||
case gfx::lut::color_depth::_16:
|
case streamfx::gfx::lut::color_depth::_16:
|
||||||
return gs_color_format::GS_RGBA16;
|
return gs_color_format::GS_RGBA16;
|
||||||
}
|
}
|
||||||
return GS_RGBA32F;
|
return GS_RGBA32F;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::lut::producer::producer()
|
streamfx::gfx::lut::producer::producer()
|
||||||
{
|
{
|
||||||
_data = gfx::lut::data::instance();
|
_data = streamfx::gfx::lut::data::instance();
|
||||||
if (!_data->producer_effect())
|
if (!_data->producer_effect())
|
||||||
throw std::runtime_error("Unable to get LUT producer effect.");
|
throw std::runtime_error("Unable to get LUT producer effect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::lut::producer::~producer() {}
|
streamfx::gfx::lut::producer::~producer() {}
|
||||||
|
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> gfx::lut::producer::produce(gfx::lut::color_depth depth)
|
std::shared_ptr<streamfx::obs::gs::texture> streamfx::gfx::lut::producer::produce(streamfx::gfx::lut::color_depth depth)
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,15 @@
|
||||||
#include "obs/gs/gs-effect.hpp"
|
#include "obs/gs/gs-effect.hpp"
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
|
|
||||||
namespace gfx::lut {
|
namespace streamfx::gfx::lut {
|
||||||
class producer {
|
class producer {
|
||||||
std::shared_ptr<gfx::lut::data> _data;
|
std::shared_ptr<streamfx::gfx::lut::data> _data;
|
||||||
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _rt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
producer();
|
producer();
|
||||||
~producer();
|
~producer();
|
||||||
|
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> produce(gfx::lut::color_depth depth);
|
std::shared_ptr<streamfx::obs::gs::texture> produce(streamfx::gfx::lut::color_depth depth);
|
||||||
};
|
};
|
||||||
} // namespace gfx::lut
|
} // namespace streamfx::gfx::lut
|
||||||
|
|
|
@ -27,24 +27,24 @@
|
||||||
|
|
||||||
using namespace streamfx;
|
using namespace streamfx;
|
||||||
|
|
||||||
#define LOCAL_PREFIX "<gfx::lut::data> "
|
#define ST_PREFIX "<gfx::lut::data> "
|
||||||
|
|
||||||
std::shared_ptr<gfx::lut::data> gfx::lut::data::instance()
|
std::shared_ptr<streamfx::gfx::lut::data> streamfx::gfx::lut::data::instance()
|
||||||
{
|
{
|
||||||
static std::weak_ptr<gfx::lut::data> _instance;
|
static std::weak_ptr<streamfx::gfx::lut::data> _instance;
|
||||||
static std::mutex _mutex;
|
static std::mutex _mutex;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
|
||||||
auto reference = _instance.lock();
|
auto reference = _instance.lock();
|
||||||
if (!reference) {
|
if (!reference) {
|
||||||
reference = std::shared_ptr<gfx::lut::data>(new gfx::lut::data());
|
reference = std::shared_ptr<streamfx::gfx::lut::data>(new streamfx::gfx::lut::data());
|
||||||
_instance = reference;
|
_instance = reference;
|
||||||
}
|
}
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
streamfx::gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
||||||
try {
|
try {
|
||||||
_producer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_producer_path);
|
_producer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_producer_path);
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Loading LUT Producer effect failed: %s", ex.what());
|
DLOG_ERROR(ST_PREFIX "Loading LUT Producer effect failed: %s", ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,12 +62,12 @@ gfx::lut::data::data() : _producer_effect(), _consumer_effect()
|
||||||
try {
|
try {
|
||||||
_consumer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_consumer_path);
|
_consumer_effect = std::make_shared<streamfx::obs::gs::effect>(lut_consumer_path);
|
||||||
} catch (std::exception const& ex) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR(LOCAL_PREFIX "Loading LUT Consumer effect failed: %s", ex.what());
|
DLOG_ERROR(ST_PREFIX "Loading LUT Consumer effect failed: %s", ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::lut::data::~data()
|
streamfx::gfx::lut::data::~data()
|
||||||
{
|
{
|
||||||
auto gctx = streamfx::obs::gs::context();
|
auto gctx = streamfx::obs::gs::context();
|
||||||
_producer_effect.reset();
|
_producer_effect.reset();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "obs/gs/gs-effect.hpp"
|
#include "obs/gs/gs-effect.hpp"
|
||||||
|
|
||||||
namespace gfx::lut {
|
namespace streamfx::gfx::lut {
|
||||||
class data {
|
class data {
|
||||||
std::shared_ptr<streamfx::obs::gs::effect> _producer_effect;
|
std::shared_ptr<streamfx::obs::gs::effect> _producer_effect;
|
||||||
std::shared_ptr<streamfx::obs::gs::effect> _consumer_effect;
|
std::shared_ptr<streamfx::obs::gs::effect> _consumer_effect;
|
||||||
|
@ -59,4 +59,4 @@ namespace gfx::lut {
|
||||||
_14 = 14,
|
_14 = 14,
|
||||||
_16 = 16,
|
_16 = 16,
|
||||||
};
|
};
|
||||||
} // namespace gfx::lut
|
} // namespace streamfx::gfx::lut
|
||||||
|
|
|
@ -60,7 +60,7 @@ inline bool get_annotation_float(streamfx::obs::gs::effect_parameter param, std:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::basic_field_type gfx::shader::get_field_type_from_string(std::string v)
|
streamfx::gfx::shader::basic_field_type streamfx::gfx::shader::get_field_type_from_string(std::string v)
|
||||||
{
|
{
|
||||||
std::map<std::string, basic_field_type> matches = {
|
std::map<std::string, basic_field_type> matches = {
|
||||||
{"input", basic_field_type::Input},
|
{"input", basic_field_type::Input},
|
||||||
|
@ -76,7 +76,7 @@ gfx::shader::basic_field_type gfx::shader::get_field_type_from_string(std::strin
|
||||||
return basic_field_type::Input;
|
return basic_field_type::Input;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::basic_parameter::basic_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
streamfx::gfx::shader::basic_parameter::basic_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: parameter(param, prefix), _field_type(basic_field_type::Input), _suffix(), _keys(), _names(), _min(), _max(),
|
: parameter(param, prefix), _field_type(basic_field_type::Input), _suffix(), _keys(), _names(), _min(), _max(),
|
||||||
_step(), _values()
|
_step(), _values()
|
||||||
{
|
{
|
||||||
|
@ -153,14 +153,15 @@ gfx::shader::basic_parameter::basic_parameter(streamfx::obs::gs::effect_paramete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::basic_parameter::~basic_parameter() {}
|
streamfx::gfx::shader::basic_parameter::~basic_parameter() {}
|
||||||
|
|
||||||
void gfx::shader::basic_parameter::load_parameter_data(streamfx::obs::gs::effect_parameter parameter, basic_data& data)
|
void streamfx::gfx::shader::basic_parameter::load_parameter_data(streamfx::obs::gs::effect_parameter parameter,
|
||||||
|
basic_data& data)
|
||||||
{
|
{
|
||||||
parameter.get_default_value(&data.i32, 1);
|
parameter.get_default_value(&data.i32, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::bool_parameter::bool_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
streamfx::gfx::shader::bool_parameter::bool_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: basic_parameter(param, prefix)
|
: basic_parameter(param, prefix)
|
||||||
{
|
{
|
||||||
_min.resize(0);
|
_min.resize(0);
|
||||||
|
@ -171,9 +172,9 @@ gfx::shader::bool_parameter::bool_parameter(streamfx::obs::gs::effect_parameter
|
||||||
_data.resize(get_size(), 1);
|
_data.resize(get_size(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::bool_parameter::~bool_parameter() {}
|
streamfx::gfx::shader::bool_parameter::~bool_parameter() {}
|
||||||
|
|
||||||
void gfx::shader::bool_parameter::defaults(obs_data_t* settings)
|
void streamfx::gfx::shader::bool_parameter::defaults(obs_data_t* settings)
|
||||||
{
|
{
|
||||||
// TODO: Support for bool[]
|
// TODO: Support for bool[]
|
||||||
if (get_size() == 1) {
|
if (get_size() == 1) {
|
||||||
|
@ -181,7 +182,7 @@ void gfx::shader::bool_parameter::defaults(obs_data_t* settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t* settings)
|
void streamfx::gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t* settings)
|
||||||
{
|
{
|
||||||
if (!is_visible())
|
if (!is_visible())
|
||||||
return;
|
return;
|
||||||
|
@ -197,7 +198,7 @@ void gfx::shader::bool_parameter::properties(obs_properties_t* props, obs_data_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::bool_parameter::update(obs_data_t* settings)
|
void streamfx::gfx::shader::bool_parameter::update(obs_data_t* settings)
|
||||||
{
|
{
|
||||||
if (is_automatic())
|
if (is_automatic())
|
||||||
return;
|
return;
|
||||||
|
@ -208,12 +209,12 @@ void gfx::shader::bool_parameter::update(obs_data_t* settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::bool_parameter::assign()
|
void streamfx::gfx::shader::bool_parameter::assign()
|
||||||
{
|
{
|
||||||
get_parameter().set_value(_data.data(), _data.size());
|
get_parameter().set_value(_data.data(), _data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::float_parameter::float_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
streamfx::gfx::shader::float_parameter::float_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: basic_parameter(param, prefix)
|
: basic_parameter(param, prefix)
|
||||||
{
|
{
|
||||||
_data.resize(get_size());
|
_data.resize(get_size());
|
||||||
|
@ -249,9 +250,9 @@ gfx::shader::float_parameter::float_parameter(streamfx::obs::gs::effect_paramete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::float_parameter::~float_parameter() {}
|
streamfx::gfx::shader::float_parameter::~float_parameter() {}
|
||||||
|
|
||||||
void gfx::shader::float_parameter::defaults(obs_data_t* settings)
|
void streamfx::gfx::shader::float_parameter::defaults(obs_data_t* settings)
|
||||||
{
|
{
|
||||||
std::vector<float_t> defaults;
|
std::vector<float_t> defaults;
|
||||||
defaults.resize(get_size());
|
defaults.resize(get_size());
|
||||||
|
@ -262,27 +263,28 @@ void gfx::shader::float_parameter::defaults(obs_data_t* settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline obs_property_t* build_float_property(gfx::shader::basic_field_type ft, obs_properties_t* props,
|
static inline obs_property_t* build_float_property(streamfx::gfx::shader::basic_field_type ft, obs_properties_t* props,
|
||||||
const char* key, const char* name, float_t min, float_t max,
|
const char* key, const char* name, float_t min, float_t max,
|
||||||
float_t step, std::list<gfx::shader::basic_enum_data> edata)
|
float_t step,
|
||||||
|
std::list<streamfx::gfx::shader::basic_enum_data> edata)
|
||||||
{
|
{
|
||||||
switch (ft) {
|
switch (ft) {
|
||||||
case gfx::shader::basic_field_type::Enum: {
|
case streamfx::gfx::shader::basic_field_type::Enum: {
|
||||||
auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_FLOAT);
|
auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_FLOAT);
|
||||||
for (auto& el : edata) {
|
for (auto& el : edata) {
|
||||||
obs_property_list_add_float(p, el.name.c_str(), el.data.f32);
|
obs_property_list_add_float(p, el.name.c_str(), el.data.f32);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
case gfx::shader::basic_field_type::Slider:
|
case streamfx::gfx::shader::basic_field_type::Slider:
|
||||||
return obs_properties_add_float_slider(props, key, name, min, max, step);
|
return obs_properties_add_float_slider(props, key, name, min, max, step);
|
||||||
default:
|
default:
|
||||||
case gfx::shader::basic_field_type::Input:
|
case streamfx::gfx::shader::basic_field_type::Input:
|
||||||
return obs_properties_add_float(props, key, name, min, max, step);
|
return obs_properties_add_float(props, key, name, min, max, step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_t* settings)
|
void streamfx::gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_t* settings)
|
||||||
{
|
{
|
||||||
if (!is_visible())
|
if (!is_visible())
|
||||||
return;
|
return;
|
||||||
|
@ -305,41 +307,41 @@ void gfx::shader::float_parameter::properties(obs_properties_t* props, obs_data_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::float_parameter::update(obs_data_t* settings)
|
void streamfx::gfx::shader::float_parameter::update(obs_data_t* settings)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < get_size(); idx++) {
|
for (std::size_t idx = 0; idx < get_size(); idx++) {
|
||||||
_data[idx].f32 = static_cast<float_t>(obs_data_get_double(settings, key_at(idx).data())) * _scale[idx].f32;
|
_data[idx].f32 = static_cast<float_t>(obs_data_get_double(settings, key_at(idx).data())) * _scale[idx].f32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::float_parameter::assign()
|
void streamfx::gfx::shader::float_parameter::assign()
|
||||||
{
|
{
|
||||||
if (is_automatic())
|
if (is_automatic())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
get_parameter().set_value(_data.data(), get_size());
|
get_parameter().set_value(_data.data(), get_size());
|
||||||
}
|
}
|
||||||
static inline obs_property_t* build_int_property(gfx::shader::basic_field_type ft, obs_properties_t* props,
|
static inline obs_property_t* build_int_property(streamfx::gfx::shader::basic_field_type ft, obs_properties_t* props,
|
||||||
const char* key, const char* name, int32_t min, int32_t max,
|
const char* key, const char* name, int32_t min, int32_t max,
|
||||||
int32_t step, std::list<gfx::shader::basic_enum_data> edata)
|
int32_t step, std::list<streamfx::gfx::shader::basic_enum_data> edata)
|
||||||
{
|
{
|
||||||
switch (ft) {
|
switch (ft) {
|
||||||
case gfx::shader::basic_field_type::Enum: {
|
case streamfx::gfx::shader::basic_field_type::Enum: {
|
||||||
auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
auto p = obs_properties_add_list(props, key, name, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||||
for (auto& el : edata) {
|
for (auto& el : edata) {
|
||||||
obs_property_list_add_int(p, el.name.c_str(), el.data.i32);
|
obs_property_list_add_int(p, el.name.c_str(), el.data.i32);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
case gfx::shader::basic_field_type::Slider:
|
case streamfx::gfx::shader::basic_field_type::Slider:
|
||||||
return obs_properties_add_int_slider(props, key, name, min, max, step);
|
return obs_properties_add_int_slider(props, key, name, min, max, step);
|
||||||
default:
|
default:
|
||||||
case gfx::shader::basic_field_type::Input:
|
case streamfx::gfx::shader::basic_field_type::Input:
|
||||||
return obs_properties_add_int(props, key, name, min, max, step);
|
return obs_properties_add_int(props, key, name, min, max, step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::int_parameter::int_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
streamfx::gfx::shader::int_parameter::int_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
: basic_parameter(param, prefix)
|
: basic_parameter(param, prefix)
|
||||||
{
|
{
|
||||||
_data.resize(get_size());
|
_data.resize(get_size());
|
||||||
|
@ -375,9 +377,9 @@ gfx::shader::int_parameter::int_parameter(streamfx::obs::gs::effect_parameter pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::int_parameter::~int_parameter() {}
|
streamfx::gfx::shader::int_parameter::~int_parameter() {}
|
||||||
|
|
||||||
void gfx::shader::int_parameter::defaults(obs_data_t* settings)
|
void streamfx::gfx::shader::int_parameter::defaults(obs_data_t* settings)
|
||||||
{
|
{
|
||||||
std::vector<int32_t> defaults;
|
std::vector<int32_t> defaults;
|
||||||
defaults.resize(get_size());
|
defaults.resize(get_size());
|
||||||
|
@ -387,7 +389,7 @@ void gfx::shader::int_parameter::defaults(obs_data_t* settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t* settings)
|
void streamfx::gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t* settings)
|
||||||
{
|
{
|
||||||
if (!is_visible())
|
if (!is_visible())
|
||||||
return;
|
return;
|
||||||
|
@ -410,14 +412,14 @@ void gfx::shader::int_parameter::properties(obs_properties_t* props, obs_data_t*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::int_parameter::update(obs_data_t* settings)
|
void streamfx::gfx::shader::int_parameter::update(obs_data_t* settings)
|
||||||
{
|
{
|
||||||
for (std::size_t idx = 0; idx < get_size(); idx++) {
|
for (std::size_t idx = 0; idx < get_size(); idx++) {
|
||||||
_data[idx].i32 = static_cast<int32_t>(obs_data_get_int(settings, key_at(idx).data()) * _scale[idx].i32);
|
_data[idx].i32 = static_cast<int32_t>(obs_data_get_int(settings, key_at(idx).data()) * _scale[idx].i32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::int_parameter::assign()
|
void streamfx::gfx::shader::int_parameter::assign()
|
||||||
{
|
{
|
||||||
if (is_automatic())
|
if (is_automatic())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "gfx-shader-param.hpp"
|
#include "gfx-shader-param.hpp"
|
||||||
#include "obs/gs/gs-effect-parameter.hpp"
|
#include "obs/gs/gs-effect-parameter.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace shader {
|
namespace shader {
|
||||||
enum class basic_field_type {
|
enum class basic_field_type {
|
||||||
Input,
|
Input,
|
||||||
|
@ -143,4 +143,4 @@ namespace gfx {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace shader
|
} // namespace shader
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -20,17 +20,18 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "gfx-shader-param-basic.hpp"
|
#include "gfx-shader-param-basic.hpp"
|
||||||
|
|
||||||
#define ANNO_ORDER "order"
|
#define ST_ANNO_ORDER "order"
|
||||||
#define ANNO_VISIBILITY "visible"
|
#define ST_ANNO_VISIBILITY "visible"
|
||||||
#define ANNO_AUTOMATIC "automatic"
|
#define ST_ANNO_AUTOMATIC "automatic"
|
||||||
#define ANNO_NAME "name"
|
#define ST_ANNO_NAME "name"
|
||||||
#define ANNO_DESCRIPTION "description"
|
#define ST_ANNO_DESCRIPTION "description"
|
||||||
#define ANNO_TYPE "type"
|
#define ST_ANNO_TYPE "type"
|
||||||
#define ANNO_SIZE "size"
|
#define ST_ANNO_SIZE "size"
|
||||||
|
|
||||||
typedef streamfx::obs::gs::effect_parameter::type eptype;
|
typedef streamfx::obs::gs::effect_parameter::type eptype;
|
||||||
|
|
||||||
gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
streamfx::gfx::shader::parameter_type
|
||||||
|
streamfx::gfx::shader::get_type_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case eptype::Boolean:
|
case eptype::Boolean:
|
||||||
|
@ -55,7 +56,7 @@ gfx::shader::parameter_type gfx::shader::get_type_from_effect_type(streamfx::obs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
std::size_t streamfx::gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
default:
|
default:
|
||||||
|
@ -82,7 +83,7 @@ std::size_t gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::parameter_type gfx::shader::get_type_from_string(std::string v)
|
streamfx::gfx::shader::parameter_type streamfx::gfx::shader::get_type_from_string(std::string v)
|
||||||
{
|
{
|
||||||
if ((v == "bool") || (v == "boolean")) {
|
if ((v == "bool") || (v == "boolean")) {
|
||||||
return parameter_type::Boolean;
|
return parameter_type::Boolean;
|
||||||
|
@ -110,7 +111,7 @@ gfx::shader::parameter_type gfx::shader::get_type_from_string(std::string v)
|
||||||
throw std::invalid_argument("Invalid parameter type string.");
|
throw std::invalid_argument("Invalid parameter type string.");
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std::string key_prefix)
|
streamfx::gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std::string key_prefix)
|
||||||
: _param(param), _order(0), _key(_param.get_name()), _visible(true), _automatic(false), _name(_key), _description()
|
: _param(param), _order(0), _key(_param.get_name()), _visible(true), _automatic(false), _name(_key), _description()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -120,46 +121,46 @@ gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Order
|
// Read Order
|
||||||
if (auto anno = _param.get_annotation(ANNO_VISIBILITY); anno) {
|
if (auto anno = _param.get_annotation(ST_ANNO_VISIBILITY); anno) {
|
||||||
_visible = anno.get_default_bool();
|
_visible = anno.get_default_bool();
|
||||||
}
|
}
|
||||||
if (auto anno = _param.get_annotation(ANNO_AUTOMATIC); anno) {
|
if (auto anno = _param.get_annotation(ST_ANNO_AUTOMATIC); anno) {
|
||||||
_automatic = anno.get_default_bool();
|
_automatic = anno.get_default_bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Order
|
// Read Order
|
||||||
if (auto anno = _param.get_annotation(ANNO_ORDER); anno) {
|
if (auto anno = _param.get_annotation(ST_ANNO_ORDER); anno) {
|
||||||
_order = anno.get_default_int();
|
_order = anno.get_default_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Name
|
// Read Name
|
||||||
if (auto anno = _param.get_annotation(ANNO_NAME); anno) {
|
if (auto anno = _param.get_annotation(ST_ANNO_NAME); anno) {
|
||||||
if (std::string v = anno.get_default_string(); v.length() > 0) {
|
if (std::string v = anno.get_default_string(); v.length() > 0) {
|
||||||
_name = v;
|
_name = v;
|
||||||
} else {
|
} else {
|
||||||
throw std::out_of_range("'" ANNO_NAME "' annotation has zero length.");
|
throw std::out_of_range("'" ST_ANNO_NAME "' annotation has zero length.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Description
|
// Read Description
|
||||||
if (auto anno = _param.get_annotation(ANNO_DESCRIPTION); anno) {
|
if (auto anno = _param.get_annotation(ST_ANNO_DESCRIPTION); anno) {
|
||||||
if (std::string v = anno.get_default_string(); v.length() > 0) {
|
if (std::string v = anno.get_default_string(); v.length() > 0) {
|
||||||
_description = v;
|
_description = v;
|
||||||
} else {
|
} else {
|
||||||
throw std::out_of_range("'" ANNO_DESCRIPTION "' annotation has zero length.");
|
throw std::out_of_range("'" ST_ANNO_DESCRIPTION "' annotation has zero length.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Type override.
|
// Read Type override.
|
||||||
_type = get_type_from_effect_type(_param.get_type());
|
_type = get_type_from_effect_type(_param.get_type());
|
||||||
if (auto anno = _param.get_annotation(ANNO_TYPE); anno) {
|
if (auto anno = _param.get_annotation(ST_ANNO_TYPE); anno) {
|
||||||
// We have a type override.
|
// We have a type override.
|
||||||
_type = get_type_from_string(anno.get_default_string());
|
_type = get_type_from_string(anno.get_default_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Size override.
|
// Read Size override.
|
||||||
_size = get_length_from_effect_type(_param.get_type());
|
_size = get_length_from_effect_type(_param.get_type());
|
||||||
if (auto anno = _param.get_annotation(ANNO_SIZE); anno) {
|
if (auto anno = _param.get_annotation(ST_ANNO_SIZE); anno) {
|
||||||
std::size_t ov = static_cast<size_t>(anno.get_default_int());
|
std::size_t ov = static_cast<size_t>(anno.get_default_int());
|
||||||
if (ov > 0)
|
if (ov > 0)
|
||||||
_size = ov;
|
_size = ov;
|
||||||
|
@ -167,34 +168,34 @@ gfx::shader::parameter::parameter(streamfx::obs::gs::effect_parameter param, std
|
||||||
_size = std::clamp<size_t>(_size, size_t{1}, size_t{32});
|
_size = std::clamp<size_t>(_size, size_t{1}, size_t{32});
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::parameter::defaults(obs_data_t* settings) {}
|
void streamfx::gfx::shader::parameter::defaults(obs_data_t* settings) {}
|
||||||
|
|
||||||
void gfx::shader::parameter::properties(obs_properties_t* props, obs_data_t* settings) {}
|
void streamfx::gfx::shader::parameter::properties(obs_properties_t* props, obs_data_t* settings) {}
|
||||||
|
|
||||||
void gfx::shader::parameter::update(obs_data_t* settings) {}
|
void streamfx::gfx::shader::parameter::update(obs_data_t* settings) {}
|
||||||
|
|
||||||
void gfx::shader::parameter::assign() {}
|
void streamfx::gfx::shader::parameter::assign() {}
|
||||||
|
|
||||||
std::shared_ptr<gfx::shader::parameter>
|
std::shared_ptr<streamfx::gfx::shader::parameter>
|
||||||
gfx::shader::parameter::make_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
streamfx::gfx::shader::parameter::make_parameter(streamfx::obs::gs::effect_parameter param, std::string prefix)
|
||||||
{
|
{
|
||||||
if (!param) {
|
if (!param) {
|
||||||
throw std::runtime_error("Bad call to make_parameter. This is a bug in the plugin.");
|
throw std::runtime_error("Bad call to make_parameter. This is a bug in the plugin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_type real_type = get_type_from_effect_type(param.get_type());
|
parameter_type real_type = get_type_from_effect_type(param.get_type());
|
||||||
if (auto anno = param.get_annotation(ANNO_TYPE); anno) {
|
if (auto anno = param.get_annotation(ST_ANNO_TYPE); anno) {
|
||||||
// We have a type override.
|
// We have a type override.
|
||||||
real_type = get_type_from_string(param.get_default_string());
|
real_type = get_type_from_string(param.get_default_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (real_type) {
|
switch (real_type) {
|
||||||
case parameter_type::Boolean:
|
case parameter_type::Boolean:
|
||||||
return std::make_shared<gfx::shader::bool_parameter>(param, prefix);
|
return std::make_shared<streamfx::gfx::shader::bool_parameter>(param, prefix);
|
||||||
case parameter_type::Integer:
|
case parameter_type::Integer:
|
||||||
return std::make_shared<gfx::shader::int_parameter>(param, prefix);
|
return std::make_shared<streamfx::gfx::shader::int_parameter>(param, prefix);
|
||||||
case parameter_type::Float:
|
case parameter_type::Float:
|
||||||
return std::make_shared<gfx::shader::float_parameter>(param, prefix);
|
return std::make_shared<streamfx::gfx::shader::float_parameter>(param, prefix);
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "obs/gs/gs-effect-parameter.hpp"
|
#include "obs/gs/gs-effect-parameter.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace shader {
|
namespace shader {
|
||||||
enum class parameter_type {
|
enum class parameter_type {
|
||||||
// Unknown type, could be anything.
|
// Unknown type, could be anything.
|
||||||
|
@ -141,4 +141,4 @@ namespace gfx {
|
||||||
std::string prefix);
|
std::string prefix);
|
||||||
};
|
};
|
||||||
} // namespace shader
|
} // namespace shader
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#define ST_SHADER_SEED ST_SHADER ".Seed"
|
#define ST_SHADER_SEED ST_SHADER ".Seed"
|
||||||
#define ST_PARAMETERS ST ".Parameters"
|
#define ST_PARAMETERS ST ".Parameters"
|
||||||
|
|
||||||
gfx::shader::shader::shader(obs_source_t* self, shader_mode mode)
|
streamfx::gfx::shader::shader::shader(obs_source_t* self, shader_mode mode)
|
||||||
: _self(self), _mode(mode), _base_width(1), _base_height(1), _active(true),
|
: _self(self), _mode(mode), _base_width(1), _base_height(1), _active(true),
|
||||||
|
|
||||||
_shader(), _shader_file(), _shader_tech("Draw"), _shader_file_mt(), _shader_file_sz(), _shader_file_tick(0),
|
_shader(), _shader_file(), _shader_tech("Draw"), _shader_file_mt(), _shader_file_sz(), _shader_file_tick(0),
|
||||||
|
@ -52,9 +52,9 @@ gfx::shader::shader::shader(obs_source_t* self, shader_mode mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::shader::shader::~shader() {}
|
streamfx::gfx::shader::shader::~shader() {}
|
||||||
|
|
||||||
bool gfx::shader::shader::is_shader_different(const std::filesystem::path& file)
|
bool streamfx::gfx::shader::shader::is_shader_different(const std::filesystem::path& file)
|
||||||
try {
|
try {
|
||||||
if (std::filesystem::exists(file)) {
|
if (std::filesystem::exists(file)) {
|
||||||
// Check if the file name differs.
|
// Check if the file name differs.
|
||||||
|
@ -78,7 +78,7 @@ try {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::shader::shader::is_technique_different(const std::string& tech)
|
bool streamfx::gfx::shader::shader::is_technique_different(const std::string& tech)
|
||||||
{
|
{
|
||||||
// Is the technique different?
|
// Is the technique different?
|
||||||
if (tech != _shader_tech)
|
if (tech != _shader_tech)
|
||||||
|
@ -87,8 +87,8 @@ bool gfx::shader::shader::is_technique_different(const std::string& tech)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::shader::shader::load_shader(const std::filesystem::path& file, const std::string& tech, bool& shader_dirty,
|
bool streamfx::gfx::shader::shader::load_shader(const std::filesystem::path& file, const std::string& tech,
|
||||||
bool& param_dirty)
|
bool& shader_dirty, bool& param_dirty)
|
||||||
try {
|
try {
|
||||||
if (!std::filesystem::exists(file))
|
if (!std::filesystem::exists(file))
|
||||||
return false;
|
return false;
|
||||||
|
@ -142,7 +142,7 @@ try {
|
||||||
if (fnd != _shader_params.end())
|
if (fnd != _shader_params.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto param = gfx::shader::parameter::make_parameter(el, ST_PARAMETERS);
|
auto param = streamfx::gfx::shader::parameter::make_parameter(el, ST_PARAMETERS);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
_shader_params.insert_or_assign(el.get_name(), param);
|
_shader_params.insert_or_assign(el.get_name(), param);
|
||||||
|
@ -161,7 +161,7 @@ try {
|
||||||
if (fnd != _shader_params.end())
|
if (fnd != _shader_params.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto param = gfx::shader::parameter::make_parameter(el, ST_PARAMETERS);
|
auto param = streamfx::gfx::shader::parameter::make_parameter(el, ST_PARAMETERS);
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
_shader_params.insert_or_assign(el.get_name(), param);
|
_shader_params.insert_or_assign(el.get_name(), param);
|
||||||
|
@ -180,7 +180,7 @@ try {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::defaults(obs_data_t* data)
|
void streamfx::gfx::shader::shader::defaults(obs_data_t* data)
|
||||||
{
|
{
|
||||||
obs_data_set_default_string(data, ST_SHADER_FILE, "");
|
obs_data_set_default_string(data, ST_SHADER_FILE, "");
|
||||||
obs_data_set_default_string(data, ST_SHADER_TECHNIQUE, "");
|
obs_data_set_default_string(data, ST_SHADER_TECHNIQUE, "");
|
||||||
|
@ -189,7 +189,7 @@ void gfx::shader::shader::defaults(obs_data_t* data)
|
||||||
obs_data_set_default_int(data, ST_SHADER_SEED, static_cast<long long>(time(NULL)));
|
obs_data_set_default_int(data, ST_SHADER_SEED, static_cast<long long>(time(NULL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::properties(obs_properties_t* pr)
|
void streamfx::gfx::shader::shader::properties(obs_properties_t* pr)
|
||||||
{
|
{
|
||||||
_have_current_params = false;
|
_have_current_params = false;
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ void gfx::shader::shader::properties(obs_properties_t* pr)
|
||||||
obs_properties_add_button2(
|
obs_properties_add_button2(
|
||||||
grp, ST_REFRESH, D_TRANSLATE(ST_REFRESH),
|
grp, ST_REFRESH, D_TRANSLATE(ST_REFRESH),
|
||||||
[](obs_properties_t* props, obs_property_t* prop, void* priv) {
|
[](obs_properties_t* props, obs_property_t* prop, void* priv) {
|
||||||
return reinterpret_cast<gfx::shader::shader*>(priv)->on_refresh_properties(props, prop);
|
return reinterpret_cast<streamfx::gfx::shader::shader*>(priv)->on_refresh_properties(props, prop);
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ void gfx::shader::shader::properties(obs_properties_t* pr)
|
||||||
on_refresh_properties(pr, nullptr);
|
on_refresh_properties(pr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::shader::shader::on_refresh_properties(obs_properties_t* props, obs_property_t* prop)
|
bool streamfx::gfx::shader::shader::on_refresh_properties(obs_properties_t* props, obs_property_t* prop)
|
||||||
{
|
{
|
||||||
if (_shader) { // Clear list of techniques and rebuild it.
|
if (_shader) { // Clear list of techniques and rebuild it.
|
||||||
obs_property_t* p_tech_list = obs_properties_get(props, ST_SHADER_TECHNIQUE);
|
obs_property_t* p_tech_list = obs_properties_get(props, ST_SHADER_TECHNIQUE);
|
||||||
|
@ -278,7 +278,7 @@ bool gfx::shader::shader::on_refresh_properties(obs_properties_t* props, obs_pro
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::shader::shader::on_shader_or_technique_modified(obs_properties_t* props, obs_property_t* prop,
|
bool streamfx::gfx::shader::shader::on_shader_or_technique_modified(obs_properties_t* props, obs_property_t* prop,
|
||||||
obs_data_t* data)
|
obs_data_t* data)
|
||||||
{
|
{
|
||||||
bool shader_dirty = false;
|
bool shader_dirty = false;
|
||||||
|
@ -314,7 +314,7 @@ bool gfx::shader::shader::on_shader_or_technique_modified(obs_properties_t* prop
|
||||||
return shader_dirty || param_dirty || !_have_current_params;
|
return shader_dirty || param_dirty || !_have_current_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::shader::shader::update_shader(obs_data_t* data, bool& shader_dirty, bool& param_dirty)
|
bool streamfx::gfx::shader::shader::update_shader(obs_data_t* data, bool& shader_dirty, bool& param_dirty)
|
||||||
{
|
{
|
||||||
const char* file_c = obs_data_get_string(data, ST_SHADER_FILE);
|
const char* file_c = obs_data_get_string(data, ST_SHADER_FILE);
|
||||||
std::string file = file_c ? file_c : "";
|
std::string file = file_c ? file_c : "";
|
||||||
|
@ -324,22 +324,22 @@ bool gfx::shader::shader::update_shader(obs_data_t* data, bool& shader_dirty, bo
|
||||||
return load_shader(file, tech, shader_dirty, param_dirty);
|
return load_shader(file, tech, shader_dirty, param_dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::pair<gfx::shader::size_type, double_t> parse_text_as_size(const char* text)
|
inline std::pair<streamfx::gfx::shader::size_type, double_t> parse_text_as_size(const char* text)
|
||||||
{
|
{
|
||||||
double_t v = 0;
|
double_t v = 0;
|
||||||
if (sscanf(text, "%lf", &v) == 1) {
|
if (sscanf(text, "%lf", &v) == 1) {
|
||||||
const char* prc_chr = strrchr(text, '%');
|
const char* prc_chr = strrchr(text, '%');
|
||||||
if (prc_chr && (*prc_chr == '%')) {
|
if (prc_chr && (*prc_chr == '%')) {
|
||||||
return {gfx::shader::size_type::Percent, v / 100.0};
|
return {streamfx::gfx::shader::size_type::Percent, v / 100.0};
|
||||||
} else {
|
} else {
|
||||||
return {gfx::shader::size_type::Pixel, v};
|
return {streamfx::gfx::shader::size_type::Pixel, v};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {gfx::shader::size_type::Percent, 1.0};
|
return {streamfx::gfx::shader::size_type::Percent, 1.0};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::update(obs_data_t* data)
|
void streamfx::gfx::shader::shader::update(obs_data_t* data)
|
||||||
{
|
{
|
||||||
bool v1, v2;
|
bool v1, v2;
|
||||||
update_shader(data, v1, v2);
|
update_shader(data, v1, v2);
|
||||||
|
@ -368,7 +368,7 @@ void gfx::shader::shader::update(obs_data_t* data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gfx::shader::shader::width()
|
uint32_t streamfx::gfx::shader::shader::width()
|
||||||
{
|
{
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
case shader_mode::Transition:
|
case shader_mode::Transition:
|
||||||
|
@ -392,7 +392,7 @@ uint32_t gfx::shader::shader::width()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gfx::shader::shader::height()
|
uint32_t streamfx::gfx::shader::shader::height()
|
||||||
{
|
{
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
case shader_mode::Transition:
|
case shader_mode::Transition:
|
||||||
|
@ -416,17 +416,17 @@ uint32_t gfx::shader::shader::height()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gfx::shader::shader::base_width()
|
uint32_t streamfx::gfx::shader::shader::base_width()
|
||||||
{
|
{
|
||||||
return _base_width;
|
return _base_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t gfx::shader::shader::base_height()
|
uint32_t streamfx::gfx::shader::shader::base_height()
|
||||||
{
|
{
|
||||||
return _base_height;
|
return _base_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gfx::shader::shader::tick(float_t time)
|
bool streamfx::gfx::shader::shader::tick(float_t time)
|
||||||
{
|
{
|
||||||
_shader_file_tick = static_cast<float_t>(static_cast<double_t>(_shader_file_tick) + static_cast<double_t>(time));
|
_shader_file_tick = static_cast<float_t>(static_cast<double_t>(_shader_file_tick) + static_cast<double_t>(time));
|
||||||
if (_shader_file_tick >= 1.0f / 3.0f) {
|
if (_shader_file_tick >= 1.0f / 3.0f) {
|
||||||
|
@ -459,7 +459,7 @@ bool gfx::shader::shader::tick(float_t time)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::prepare_render()
|
void streamfx::gfx::shader::shader::prepare_render()
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -503,7 +503,7 @@ void gfx::shader::shader::prepare_render()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::render(gs_effect* effect)
|
void streamfx::gfx::shader::shader::render(gs_effect* effect)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -538,13 +538,13 @@ void gfx::shader::shader::render(gs_effect* effect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_size(uint32_t w, uint32_t h)
|
void streamfx::gfx::shader::shader::set_size(uint32_t w, uint32_t h)
|
||||||
{
|
{
|
||||||
_base_width = w;
|
_base_width = w;
|
||||||
_base_height = h;
|
_base_height = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_input_a(std::shared_ptr<streamfx::obs::gs::texture> tex)
|
void streamfx::gfx::shader::shader::set_input_a(std::shared_ptr<streamfx::obs::gs::texture> tex)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -564,7 +564,7 @@ void gfx::shader::shader::set_input_a(std::shared_ptr<streamfx::obs::gs::texture
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_input_b(std::shared_ptr<streamfx::obs::gs::texture> tex)
|
void streamfx::gfx::shader::shader::set_input_b(std::shared_ptr<streamfx::obs::gs::texture> tex)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -584,7 +584,7 @@ void gfx::shader::shader::set_input_b(std::shared_ptr<streamfx::obs::gs::texture
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_transition_time(float_t t)
|
void streamfx::gfx::shader::shader::set_transition_time(float_t t)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -596,7 +596,7 @@ void gfx::shader::shader::set_transition_time(float_t t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_transition_size(uint32_t w, uint32_t h)
|
void streamfx::gfx::shader::shader::set_transition_size(uint32_t w, uint32_t h)
|
||||||
{
|
{
|
||||||
if (!_shader)
|
if (!_shader)
|
||||||
return;
|
return;
|
||||||
|
@ -607,7 +607,7 @@ void gfx::shader::shader::set_transition_size(uint32_t w, uint32_t h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx::shader::shader::set_active(bool active)
|
void streamfx::gfx::shader::shader::set_active(bool active)
|
||||||
{
|
{
|
||||||
_active = active;
|
_active = active;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "obs/gs/gs-effect.hpp"
|
#include "obs/gs/gs-effect.hpp"
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
|
|
||||||
namespace gfx {
|
namespace streamfx::gfx {
|
||||||
namespace shader {
|
namespace shader {
|
||||||
enum class size_type {
|
enum class size_type {
|
||||||
Pixel,
|
Pixel,
|
||||||
|
@ -128,4 +128,4 @@ namespace gfx {
|
||||||
void set_active(bool active);
|
void set_active(bool active);
|
||||||
};
|
};
|
||||||
} // namespace shader
|
} // namespace shader
|
||||||
} // namespace gfx
|
} // namespace streamfx::gfx
|
||||||
|
|
|
@ -31,7 +31,7 @@ static constexpr std::string_view HELP_URL =
|
||||||
|
|
||||||
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self), _fx()
|
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self), _fx()
|
||||||
{
|
{
|
||||||
_fx = std::make_shared<::gfx::shader::shader>(self, ::gfx::shader::shader_mode::Source);
|
_fx = std::make_shared<::streamfx::gfx::shader::shader>(self, ::streamfx::gfx::shader::shader_mode::Source);
|
||||||
|
|
||||||
update(data);
|
update(data);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ const char* shader_factory::get_name()
|
||||||
|
|
||||||
void shader_factory::get_defaults2(obs_data_t* data)
|
void shader_factory::get_defaults2(obs_data_t* data)
|
||||||
{
|
{
|
||||||
::gfx::shader::shader::defaults(data);
|
::streamfx::gfx::shader::shader::defaults(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_properties_t* shader_factory::get_properties2(shader_instance* data)
|
obs_properties_t* shader_factory::get_properties2(shader_instance* data)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
namespace streamfx::source::shader {
|
namespace streamfx::source::shader {
|
||||||
class shader_instance : public obs::source_instance {
|
class shader_instance : public obs::source_instance {
|
||||||
std::shared_ptr<gfx::shader::shader> _fx;
|
std::shared_ptr<streamfx::gfx::shader::shader> _fx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
shader_instance(obs_data_t* data, obs_source_t* self);
|
shader_instance(obs_data_t* data, obs_source_t* self);
|
||||||
|
|
|
@ -31,7 +31,7 @@ static constexpr std::string_view HELP_URL =
|
||||||
|
|
||||||
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self)
|
shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::source_instance(data, self)
|
||||||
{
|
{
|
||||||
_fx = std::make_shared<gfx::shader::shader>(self, gfx::shader::shader_mode::Transition);
|
_fx = std::make_shared<streamfx::gfx::shader::shader>(self, streamfx::gfx::shader::shader_mode::Transition);
|
||||||
|
|
||||||
update(data);
|
update(data);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ const char* shader_factory::get_name()
|
||||||
|
|
||||||
void shader_factory::get_defaults2(obs_data_t* data)
|
void shader_factory::get_defaults2(obs_data_t* data)
|
||||||
{
|
{
|
||||||
gfx::shader::shader::defaults(data);
|
streamfx::gfx::shader::shader::defaults(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_properties_t* shader_factory::get_properties2(shader::shader_instance* data)
|
obs_properties_t* shader_factory::get_properties2(shader::shader_instance* data)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
namespace streamfx::transition::shader {
|
namespace streamfx::transition::shader {
|
||||||
class shader_instance : public obs::source_instance {
|
class shader_instance : public obs::source_instance {
|
||||||
std::shared_ptr<gfx::shader::shader> _fx;
|
std::shared_ptr<streamfx::gfx::shader::shader> _fx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
shader_instance(obs_data_t* data, obs_source_t* self);
|
shader_instance(obs_data_t* data, obs_source_t* self);
|
||||||
|
|
Loading…
Reference in a new issue