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;
76 frag_info.stroked = params_.
stroke ? 1.0f : 0.0f;
77 frag_info.stroke_width = params_.
stroke ? params_.
stroke->width : 0.0f;
78 frag_info.stroke_join =
79 params_.
stroke ? ToShaderStrokeJoin(params_.
stroke->join) : 0.0f;
88 frag_info.radii = params_.
radii;
90 auto geometry_result =
98 return ColorSourceContents::DrawGeometry<VS>(
99 this,
GetGeometry(), renderer, entity, pass, pipeline_callback,
102 [&frag_info, &data_host_buffer](
RenderPass& pass) {
103 FS::BindFragInfo(pass, data_host_buffer.EmplaceUniform(frag_info));
109 [geometry_result = std::move(geometry_result)](
112 const Geometry* geometry) {
return geometry_result; });
120 return geometry_.get();
124 return params_.
color;
129 params_.
color = color_filter_proc(params_.
color);
135 ISize target_size)
const {
140 if (geometry ==
nullptr) {
146 : 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.
Color color
The color used for filling or stroking the shape.
float octant_offset_c
The geometric offset 'c' used to connect the two octants of each quadrant.
Point superellipse_degree
The degree (n) of the superellipse curve for the top and right octants.
Point angle_span
The angular span of the circular cap for the top and right octants.
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.
@ kRoundedSuperellipseSymmetric
Point circle_center_right
Point superellipse_semi_axis
static constexpr Scalar kAntialiasPixels
std::optional< StrokeParameters > stroke
The stroke parameters. If std::nullopt, the shape is filled.