27 tile_mode_ = tile_mode;
31 colors_ = std::move(
colors);
35 stops_ = std::move(stops);
49 focus_radius_ = radius;
55 if (
renderer.GetDeviceCapabilities().SupportsSSBO()) {
56 return RenderSSBO(
renderer, entity, pass);
58 return RenderTexture(
renderer, entity, pass);
67 VS::FrameInfo frame_info;
74 return ColorSourceContents::DrawGeometry<VS>(
75 renderer, entity, pass, pipeline_callback, frame_info,
76 [
this, &
renderer, &entity](RenderPass& pass) {
77 FS::FragInfo frag_info;
78 frag_info.center = center_;
79 frag_info.radius = radius_;
80 frag_info.tile_mode =
static_cast<Scalar>(tile_mode_);
81 frag_info.decal_border_color = decal_border_color_;
85 frag_info.focus = focus_.value();
86 frag_info.focus_radius = focus_radius_;
88 frag_info.focus = center_;
89 frag_info.focus_radius = 0.0;
92 auto& host_buffer =
renderer.GetTransientsBuffer();
95 frag_info.colors_length =
colors.size();
97 host_buffer.Emplace(
colors.data(),
colors.size() *
sizeof(StopData),
101 pass,
renderer.GetTransientsBuffer().EmplaceUniform(frag_info));
102 FS::BindColorData(pass, color_buffer);
104 pass.SetCommandLabel(
"ConicalGradientSSBOFill");
109bool ConicalGradientContents::RenderTexture(
const ContentContext&
renderer,
110 const Entity& entity,
111 RenderPass& pass)
const {
116 auto gradient_texture =
118 if (gradient_texture ==
nullptr) {
122 VS::FrameInfo frame_info;
129 return ColorSourceContents::DrawGeometry<VS>(
130 renderer, entity, pass, pipeline_callback, frame_info,
131 [
this, &
renderer, &gradient_texture, &entity](RenderPass& pass) {
132 FS::FragInfo frag_info;
133 frag_info.center = center_;
134 frag_info.radius = radius_;
135 frag_info.tile_mode =
static_cast<Scalar>(tile_mode_);
136 frag_info.decal_border_color = decal_border_color_;
137 frag_info.texture_sampler_y_coord_scale =
138 gradient_texture->GetYCoordScale();
141 frag_info.half_texel =
142 Vector2(0.5 / gradient_texture->GetSize().width,
143 0.5 / gradient_texture->GetSize().height);
145 frag_info.focus = focus_.value();
146 frag_info.focus_radius = focus_radius_;
148 frag_info.focus = center_;
149 frag_info.focus_radius = 0.0;
152 pass.SetCommandLabel(
"ConicalGradientFill");
155 pass,
renderer.GetTransientsBuffer().EmplaceUniform(frag_info));
156 SamplerDescriptor sampler_desc;
159 FS::BindTextureSampler(
160 pass, gradient_texture,
161 renderer.GetContext()->GetSamplerLibrary()->GetSampler(
173 decal_border_color_ = color_filter_proc(decal_border_color_);
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
std::function< std::shared_ptr< Pipeline< PipelineDescriptor > >(ContentContextOptions)> PipelineBuilderCallback
const Matrix & GetInverseEffectTransform() const
Set the inverted effect transform for this color source.
const std::shared_ptr< Geometry > & GetGeometry() const
Get the geometry that this contents will use to render.
void SetFocus(std::optional< Point > focus, Scalar radius)
bool ApplyColorFilter(const ColorFilterProc &color_filter_proc) override
If possible, applies a color filter to this contents inputs on the CPU.
void SetStops(std::vector< Scalar > stops)
void SetCenterAndRadius(Point center, Scalar radius)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
const std::vector< Scalar > & GetStops() const
ConicalGradientContents()
void SetTileMode(Entity::TileMode tile_mode)
const std::vector< Color > & GetColors() const
~ConicalGradientContents() override
void SetColors(std::vector< Color > colors)
std::function< Color(Color)> ColorFilterProc
Render passes encode render commands directed as one specific render target into an underlying comman...
VertexShader_ VertexShader
FragmentShader_ FragmentShader
PODArray< SkColor > colors
std::vector< StopData > CreateGradientColors(const std::vector< Color > &colors, const std::vector< Scalar > &stops)
Populate a vector with the color and stop data for a gradient.
std::shared_ptr< Texture > CreateGradientTexture(const GradientData &gradient_data, const std::shared_ptr< impeller::Context > &context)
Create a host visible texture that contains the gradient defined by the provided gradient data.
GradientData CreateGradientBuffer(const std::vector< Color > &colors, const std::vector< Scalar > &stops)
Populate a vector with the interpolated color bytes for the linear gradient described by colors and s...
constexpr size_t DefaultUniformAlignment()