40 std::shared_ptr<const canvas::Canvas::ShaderDataTexture>
data;
63 chart_sksl_ = std::move(sksl);
64 chart_reach_ = reach > 0.0f ? reach : 0.0f;
72 shader_uniforms_ = std::move(uniforms);
74 const std::vector<canvas::Canvas::NamedUniform>&
shader_uniforms()
const {
return shader_uniforms_; }
76 shader_value_bindings_ = std::move(bindings);
79 return shader_value_bindings_;
83 return std::any_of(shader_value_bindings_.begin(), shader_value_bindings_.end(),
84 [&](
const auto& binding) { return binding.uniform_name == name; });
87 shader_scope_binding_ = std::move(binding);
90 return shader_scope_binding_;
94 for (
auto&
uniform : shader_uniforms_) {
105 shader_uniforms_.push_back(std::move(
uniform));
111 shader_geometry_ = std::move(geometry);
114 return shader_geometry_;
117 shader_geometry_spec_ = std::move(spec);
118 shader_geometry_topology_hash_ = topology_hash;
144 std::string custom_sksl_;
145 std::string chart_sksl_;
146 float chart_reach_ = 0.0f;
147 bool shader_uses_time_ =
false;
148 bool shader_draw_failure_logged_ =
false;
149 std::vector<canvas::Canvas::NamedUniform> shader_uniforms_;
150 std::vector<ShaderValueBinding> shader_value_bindings_;
151 std::optional<ShaderScopeBinding> shader_scope_binding_;
152 float shader_reach_ = 0.0f;
153 std::optional<canvas::Canvas::ShaderGeometry> shader_geometry_;
154 std::string shader_geometry_spec_;
155 std::uint64_t shader_geometry_topology_hash_ = 0;
Mixin for widgets whose body can be painted by a custom SkSL shader.
Definition custom_shader_host.hpp:27
void clear_custom_shader()
Remove the shader and restore the default C++ paint path.
const std::string & shader_geometry_spec() const
Definition custom_shader_host.hpp:120
std::uint64_t shader_geometry_topology_hash() const
Definition custom_shader_host.hpp:121
virtual ~CustomShaderHost()=default
bool shader_uses_time() const
True when the shader actually declares a time uniform, and therefore needs a continuous repaint to an...
Definition custom_shader_host.hpp:132
const std::vector< canvas::Canvas::NamedUniform > & shader_uniforms() const
Definition custom_shader_host.hpp:74
void set_shader_value_bindings(std::vector< ShaderValueBinding > bindings)
Definition custom_shader_host.hpp:75
bool set_shader_uniform_value(const std::string &name, float value)
Definition custom_shader_host.hpp:93
const std::optional< canvas::Canvas::ShaderGeometry > & shader_geometry() const
Definition custom_shader_host.hpp:113
const std::optional< ShaderScopeBinding > & shader_scope_binding() const
Definition custom_shader_host.hpp:89
void set_shader_reach(float reach)
Definition custom_shader_host.hpp:108
bool shader_uniform_bound(const std::string &name) const
Definition custom_shader_host.hpp:82
float shader_reach() const
Definition custom_shader_host.hpp:109
const std::string & custom_shader() const
Definition custom_shader_host.hpp:57
void set_chart_shader(std::string sksl, float reach=0.0f)
Install a chart shader with the extra reach its own source needs (a glow preset's halo).
Definition custom_shader_host.hpp:62
const std::vector< ShaderValueBinding > & shader_value_bindings() const
Definition custom_shader_host.hpp:78
void set_shader_scope_binding(std::optional< ShaderScopeBinding > binding)
Definition custom_shader_host.hpp:86
void set_shader_geometry_spec(std::string spec, std::uint64_t topology_hash)
Definition custom_shader_host.hpp:116
void mark_shader_draw_failure_logged()
Definition custom_shader_host.hpp:141
void set_custom_shader(std::string sksl)
Install an SkSL body shader.
void set_shader_geometry(std::optional< canvas::Canvas::ShaderGeometry > geometry)
Definition custom_shader_host.hpp:110
std::vector< ShaderValueBinding > & shader_value_bindings()
Definition custom_shader_host.hpp:81
bool has_custom_shader() const
Definition custom_shader_host.hpp:56
std::optional< ShaderScopeBinding > & shader_scope_binding()
Definition custom_shader_host.hpp:92
const std::string & chart_shader() const
Definition custom_shader_host.hpp:66
bool shader_draw_failure_logged() const
One-shot latch for "the body shader failed to draw and we logged it".
Definition custom_shader_host.hpp:140
float chart_reach() const
Definition custom_shader_host.hpp:67
void set_shader_uniforms(std::vector< canvas::Canvas::NamedUniform > uniforms)
Definition custom_shader_host.hpp:71
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ value
the widget's primary value (Knob, Fader, RangeSlider, Toggle, ProgressBar)
Definition binding_diagnostics.hpp:19
@ uniform
a custom shader uniform
Definition binding_diagnostics.hpp:22
Definition custom_shader_host.hpp:38
std::shared_ptr< const canvas::Canvas::ShaderDataTexture > data
Definition custom_shader_host.hpp:40
std::uint32_t last_publish_seq
Definition custom_shader_host.hpp:41
float neutral
Definition custom_shader_host.hpp:43
std::chrono::steady_clock::time_point last_publish_at
Definition custom_shader_host.hpp:42
std::string channel_name
Definition custom_shader_host.hpp:39
Definition custom_shader_host.hpp:29
std::chrono::steady_clock::time_point last_publish_at
Definition custom_shader_host.hpp:34
std::string param_name
Definition custom_shader_host.hpp:32
bool managed_by_param_binding
Definition custom_shader_host.hpp:36
float neutral
Definition custom_shader_host.hpp:35
std::string uniform_name
Definition custom_shader_host.hpp:30
std::string channel_name
Definition custom_shader_host.hpp:31
std::uint32_t last_publish_seq
Definition custom_shader_host.hpp:33