2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
|
|
|
// Copyright (C) 2019-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
#pragma once
|
2020-04-02 15:02:01 +00:00
|
|
|
#include "common.hpp"
|
2019-04-02 00:56:15 +00:00
|
|
|
#include "gfx-blur-base.hpp"
|
2022-11-28 08:11:55 +00:00
|
|
|
#include "gfx/gfx-util.hpp"
|
2019-04-02 00:56:15 +00:00
|
|
|
#include "obs/gs/gs-effect.hpp"
|
|
|
|
#include "obs/gs/gs-rendertarget.hpp"
|
|
|
|
#include "obs/gs/gs-texture.hpp"
|
|
|
|
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-disable.hpp"
|
|
|
|
#include <mutex>
|
|
|
|
#include <vector>
|
|
|
|
#include "warning-enable.hpp"
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
namespace streamfx::gfx {
|
2019-04-02 00:56:15 +00:00
|
|
|
namespace blur {
|
|
|
|
class gaussian_data {
|
2021-06-08 08:35:34 +00:00
|
|
|
streamfx::obs::gs::effect _effect;
|
2022-11-28 08:11:55 +00:00
|
|
|
std::shared_ptr<streamfx::gfx::util> _gfx_util;
|
2021-06-08 08:35:34 +00:00
|
|
|
std::map<size_t, std::vector<float>> _kernels;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
gaussian_data();
|
2019-04-19 07:42:15 +00:00
|
|
|
virtual ~gaussian_data();
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
streamfx::obs::gs::effect get_effect();
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2022-11-28 08:11:55 +00:00
|
|
|
std::shared_ptr<streamfx::gfx::util> get_gfx_util();
|
|
|
|
|
2020-04-08 21:38:42 +00:00
|
|
|
std::vector<float_t> const& get_kernel(std::size_t width);
|
2019-04-02 00:56:15 +00:00
|
|
|
};
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
class gaussian_factory : public ::streamfx::gfx::blur::ifactory {
|
|
|
|
std::mutex _data_lock;
|
|
|
|
std::weak_ptr<::streamfx::gfx::blur::gaussian_data> _data;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
gaussian_factory();
|
2019-04-19 07:42:15 +00:00
|
|
|
virtual ~gaussian_factory() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual bool is_type_supported(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual std::shared_ptr<::streamfx::gfx::blur::base> create(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_min_size(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_step_size(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_max_size(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_min_angle(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_step_angle(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_max_angle(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual bool is_step_scale_supported(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_min_step_scale_x(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_step_step_scale_x(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_max_step_scale_x(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_min_step_scale_y(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_step_step_scale_y(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual double_t get_max_step_scale_y(::streamfx::gfx::blur::type type) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_data> data();
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
public: // Singleton
|
2021-06-08 02:47:04 +00:00
|
|
|
static ::streamfx::gfx::blur::gaussian_factory& get();
|
2019-04-02 00:56:15 +00:00
|
|
|
};
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
class gaussian : public ::streamfx::gfx::blur::base {
|
2019-04-02 00:56:15 +00:00
|
|
|
protected:
|
2021-06-08 02:47:04 +00:00
|
|
|
std::shared_ptr<::streamfx::gfx::blur::gaussian_data> _data;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
double_t _size;
|
|
|
|
std::pair<double_t, double_t> _step_scale;
|
|
|
|
std::shared_ptr<::streamfx::obs::gs::texture> _input_texture;
|
|
|
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
private:
|
2021-06-08 02:38:24 +00:00
|
|
|
std::shared_ptr<::streamfx::obs::gs::rendertarget> _rendertarget2;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
gaussian();
|
2019-04-19 07:42:15 +00:00
|
|
|
virtual ~gaussian() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
virtual void set_input(std::shared_ptr<::streamfx::obs::gs::texture> texture) override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
virtual double_t get_size() override;
|
|
|
|
|
|
|
|
virtual void set_size(double_t width) override;
|
|
|
|
|
|
|
|
virtual void set_step_scale(double_t x, double_t y) override;
|
|
|
|
|
|
|
|
virtual void get_step_scale(double_t& x, double_t& y) override;
|
|
|
|
|
|
|
|
virtual double_t get_step_scale_x() override;
|
|
|
|
|
|
|
|
virtual double_t get_step_scale_y() override;
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> get() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
};
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
class gaussian_directional : public ::streamfx::gfx::blur::gaussian, public ::streamfx::gfx::blur::base_angle {
|
2019-04-02 00:56:15 +00:00
|
|
|
double_t m_angle;
|
|
|
|
|
|
|
|
public:
|
|
|
|
gaussian_directional();
|
2019-04-19 07:42:15 +00:00
|
|
|
virtual ~gaussian_directional() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
virtual double_t get_angle() override;
|
|
|
|
virtual void set_angle(double_t angle) override;
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
};
|
|
|
|
|
2023-05-13 12:35:46 +00:00
|
|
|
class gaussian_rotational : public ::streamfx::gfx::blur::gaussian, public ::streamfx::gfx::blur::base_angle, public ::streamfx::gfx::blur::base_center {
|
2019-04-02 00:56:15 +00:00
|
|
|
std::pair<double_t, double_t> m_center;
|
|
|
|
double_t m_angle;
|
|
|
|
|
|
|
|
public:
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
virtual void set_center(double_t x, double_t y) override;
|
|
|
|
virtual void get_center(double_t& x, double_t& y) override;
|
|
|
|
|
|
|
|
virtual double_t get_angle() override;
|
|
|
|
virtual void set_angle(double_t angle) override;
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
};
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
class gaussian_zoom : public ::streamfx::gfx::blur::gaussian, public ::streamfx::gfx::blur::base_center {
|
2019-04-02 00:56:15 +00:00
|
|
|
std::pair<double_t, double_t> m_center;
|
|
|
|
|
|
|
|
public:
|
2021-06-08 02:47:04 +00:00
|
|
|
virtual ::streamfx::gfx::blur::type get_type() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
|
|
|
|
virtual void set_center(double_t x, double_t y) override;
|
|
|
|
virtual void get_center(double_t& x, double_t& y) override;
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
virtual std::shared_ptr<::streamfx::obs::gs::texture> render() override;
|
2019-04-02 00:56:15 +00:00
|
|
|
};
|
|
|
|
} // namespace blur
|
2021-06-08 02:47:04 +00:00
|
|
|
} // namespace streamfx::gfx
|