16 using PipelineBuilderCallback =
32 return std::make_unique<UberSDFContents>(
Type::kRect, bounding_box, color,
33 stroke_width, stroke_join, stroked,
34 geometry, aa_padding);
44 radius * 2, radius * 2);
60 bounding_box_(bounding_box),
62 stroke_width_(stroke_width),
63 stroke_join_(stroke_join),
66 aa_padding_(aa_padding) {}
75 VS::FrameInfo frame_info;
76 FS::FragInfo frag_info;
78 frag_info.center = bounding_box_.
GetCenter();
81 frag_info.stroke_width = stroke_width_;
82 switch (stroke_join_) {
84 frag_info.stroke_join = 0.0f;
87 frag_info.stroke_join = 1.0f;
90 frag_info.stroke_join = 2.0f;
93 frag_info.aa_pixels = aa_padding_;
94 frag_info.stroked = stroked_ ? 1.0f : 0.0f;
97 auto geometry_result =
105 return ColorSourceContents::DrawGeometry<VS>(
106 this,
GetGeometry(), renderer, entity, pass, pipeline_callback,
109 [&frag_info, &data_host_buffer](
RenderPass& pass) {
110 FS::BindFragInfo(pass, data_host_buffer.EmplaceUniform(frag_info));
116 [geometry_result = std::move(geometry_result)](
119 const Geometry* geometry) {
return geometry_result; });
136 color_ = color_filter_proc(color_);
Scalar GetAntialiasPadding() const
Scalar GetStrokeWidth() const
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
std::function< PipelineRef(ContentContextOptions)> PipelineBuilderCallback
PipelineRef GetUberSDFPipeline(ContentContextOptions opts) const
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
std::function< Color(Color)> ColorFilterProc
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
const Rect & GetRect() const
virtual GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
virtual std::optional< Rect > GetCoverage(const Matrix &transform) 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.
VertexShader_ VertexShader
FragmentShader_ FragmentShader
static std::unique_ptr< UberSDFContents > MakeRect(Color color, Scalar stroke_width, Join stroke_join, bool stroked, const FillRectGeometry *geometry)
UberSDFContents(Type type, Rect rect, Color color, Scalar stroke_width, Join stroke_join, bool stroked, const Geometry *geometry, Scalar aa_padding)
~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 > MakeCircle(Color color, bool stroked, const CircleGeometry *geometry)
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
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
LinePipeline::VertexShader VS
constexpr Color WithAlpha(Scalar new_alpha) const
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
constexpr Point GetCenter() const
Get the center point as a |Point|.