17using PipelineBuilderCallback =
20using VS = UberSDFPipeline::VertexShader;
21using FS = UberSDFPipeline::FragmentShader;
53 std::unique_ptr<Geometry> geometry) {
54 return std::unique_ptr<UberSDFContents>(
59 std::unique_ptr<Geometry> geometry)
60 : params_(
params), geometry_(
std::move(geometry)) {}
69 VS::FrameInfo frame_info;
70 FS::FragInfo frag_info;
74 frag_info.center = params_.
center;
75 frag_info.size = params_.
size;
79 frag_info.radii_right =
82 frag_info.stroked = params_.
stroke ? 1.0f : 0.0f;
83 frag_info.stroke_width = params_.
stroke ? params_.
stroke->width : 0.0f;
84 frag_info.stroke_join =
85 params_.
stroke ? ToShaderStrokeJoin(params_.
stroke->join) : 0.0f;
95 auto geometry_result =
103 return ColorSourceContents::DrawGeometry<VS>(
104 this,
GetGeometry(), renderer, entity, pass, pipeline_callback,
107 [&frag_info, &data_host_buffer](
RenderPass& pass) {
108 FS::BindFragInfo(pass, data_host_buffer.EmplaceUniform(frag_info));
114 [geometry_result = std::move(geometry_result)](
117 const Geometry* geometry) {
return geometry_result; });
125 return geometry_.get();
129 return params_.
color;
134 params_.
color = color_filter_proc(params_.
color);
140 ISize target_size)
const {
145 if (geometry ==
nullptr) {
151 : std::optional<Color>();
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
std::function< PipelineRef(ContentContextOptions)> PipelineBuilderCallback
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
PipelineRef GetUberSDFPipeline(ContentContextOptions opts) const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
virtual std::optional< Rect > GetCoverage(const Matrix &transform) const =0
The coverage rectangle of this geometry, transformed by the transform argument.
virtual bool CoversArea(const Matrix &transform, const IRect &rect) const
Determines if this geometry, transformed by the given transform, will completely cover all of the pix...
virtual GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
Render passes encode render commands directed as one specific render target into an underlying comman...
virtual void SetCommandLabel(std::string_view label)
The debugging label to use for the command.
~UberSDFContents() override
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
bool ApplyColorFilter(const ColorFilterProc &color_filter_proc) override
If possible, applies a color filter to this contents inputs on the CPU.
static std::unique_ptr< UberSDFContents > Make(const UberSDFParameters ¶ms, std::unique_ptr< Geometry > geometry)
std::optional< Color > AsBackgroundColor(const Entity &entity, ISize target_size) const override
Returns a color if this Contents will flood the given target_size with a color. This output color is ...
const Geometry * GetGeometry() const override
Get the geometry that this contents will use to render.
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
const EmbeddedViewParams * params
Join
An enum that describes ways to join two segments of a path.
raw_ptr< Pipeline< PipelineDescriptor > > PipelineRef
A raw ptr to a pipeline object.
LinePipeline::FragmentShader FS
std::function< Color(Color)> ColorFilterProc
LinePipeline::VertexShader VS
constexpr ArchiveShaderType ToShaderType(fb::Stage stage)
impeller::ShaderType type
constexpr Color WithAlpha(Scalar new_alpha) const
static constexpr TRect MakeSize(const TSize< U > &size)
Parameters for rendering shapes using the UberSDF shader.
Point superellipse_a
The semi-axes of the top (.x) and right (.y) superellipse segments.
Color color
The color used for filling or stroking the shape.
Point corner_circle_center_right
The center of the right circular arc in a RoundSuperellipse.
Point superellipse_degree
The degrees of the top (.x) and right (.y) octants of a RoundSuperellipse.
Type type
The type of shape to render.
Point center
The center point of the shape in local coordinates.
Type
The type of primitive shape.
Point corner_angle_span
The spans of the top (.x) and right (.y) circular arcs.
static constexpr Scalar kAntialiasPixels
Point superellipse_scale
The scale of the superellipse.
std::optional< StrokeParameters > stroke
The stroke parameters. If std::nullopt, the shape is filled.
Point corner_circle_center_top
The center of the top circular arc in a RoundSuperellipse.
Scalar superellipse_c
The offset of the octants in a RoundSuperellipse.