22 .vertex_buffer = host_buffer.Emplace(
23 rect_.
GetPoints().data(), 8 *
sizeof(
float),
alignof(
float)),
37 const Rect& rect)
const {
38 if (!
transform.IsTranslationScaleOnly()) {
52 stroke_width_(stroke.width),
53 stroke_join_(AdjustStrokeJoin(stroke)) {}
61 if (stroke_width_ < 0.0) {
70 Scalar half_stroke_width = std::max(stroke_width_, min_size) * 0.5f;
73 const Rect& rect = rect_;
75 switch (stroke_join_) {
81 FML_DCHECK(trigs.
size() >= 2u);
84 auto vertex_count = trigs.
size() - 1;
86 vertex_count = vertex_count + (vertex_count >> 1);
90 vertex_count = vertex_count * 4;
98 .vertex_buffer = host_buffer.Emplace(
100 [hsw = half_stroke_width, &rect, vertex_count,
101 &trigs](uint8_t* buffer) {
102 auto vertices =
reinterpret_cast<Point*
>(buffer);
104 auto vertices_end = vertices + vertex_count;
107 AppendRoundCornerJoin(vertices, rect.
GetLeftTop(),
110 AppendRoundCornerJoin(vertices, rect.
GetRightTop(),
112 vertices = AppendRoundCornerJoin(
115 vertices = AppendRoundCornerJoin(
125 FML_DCHECK(vertices == vertices_end);
127 .vertex_count = vertex_count,
139 .vertex_buffer = host_buffer.Emplace(
141 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
146 auto vertices =
reinterpret_cast<Point*
>(buffer);
147 vertices[0] =
Point(left, top - hsw);
148 vertices[1] =
Point(left, top + hsw);
149 vertices[2] =
Point(right, top - hsw);
150 vertices[3] =
Point(right, top + hsw);
151 vertices[4] =
Point(right + hsw, top);
152 vertices[5] =
Point(right - hsw, top);
153 vertices[6] =
Point(right + hsw, bottom);
154 vertices[7] =
Point(right - hsw, bottom);
155 vertices[8] =
Point(right, bottom + hsw);
156 vertices[9] =
Point(right, bottom - hsw);
157 vertices[10] =
Point(left, bottom + hsw);
158 vertices[11] =
Point(left, bottom - hsw);
159 vertices[12] =
Point(left - hsw, bottom);
160 vertices[13] =
Point(left + hsw, bottom);
161 vertices[14] =
Point(left - hsw, top);
162 vertices[15] =
Point(left + hsw, top);
163 vertices[16] =
Point(left, top - hsw);
177 .vertex_buffer = host_buffer.Emplace(
179 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
184 auto vertices =
reinterpret_cast<Point*
>(buffer);
185 vertices[0] =
Point(left - hsw, top - hsw);
186 vertices[1] =
Point(left + hsw, top + hsw);
187 vertices[2] =
Point(right + hsw, top - hsw);
188 vertices[3] =
Point(right - hsw, top + hsw);
189 vertices[4] =
Point(right + hsw, bottom + hsw);
190 vertices[5] =
Point(right - hsw, bottom - hsw);
191 vertices[6] =
Point(left - hsw, bottom + hsw);
192 vertices[7] =
Point(left + hsw, bottom - hsw);
193 vertices[8] =
Point(left - hsw, top - hsw);
194 vertices[9] =
Point(left + hsw, top + hsw);
216 Point* StrokeRectGeometry::AppendRoundCornerJoin(
220 const Tessellator::Trigs& trigs) {
223 *buffer++ = corner + offset;
224 *buffer++ = corner - offset;
225 bool do_center =
false;
226 auto trig = trigs.begin();
227 auto end = trigs.end();
228 while (++trig <
end) {
232 do_center = !do_center;
233 *buffer++ = corner + *trig * offset;
237 *buffer++ = corner -
end[-1] * offset;
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
Tessellator & GetTessellator() const
Matrix GetShaderTransform(const RenderPass &pass) const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
FillRectGeometry(Rect rect)
std::optional< Rect > GetCoverage(const Matrix &transform) const override
bool CoversArea(const Matrix &transform, const Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
bool IsAxisAlignedRect() const override
GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
~FillRectGeometry() override
Render passes encode render commands directed as one specific render target into an underlying comman...
std::optional< Rect > GetCoverage(const Matrix &transform) const override
StrokeRectGeometry(const Rect &rect, const StrokeParameters &stroke)
~StrokeRectGeometry() override
GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Trigs GetTrigsForDeviceRadius(Scalar pixel_radius)
@ kNone
Does not use the index buffer.
Join
An enum that describes ways to join two segments of a path.
static constexpr Scalar kMinStrokeSize
A 4x4 matrix using column-major storage.
Scalar GetMaxBasisLengthXY() const
A structure to store all of the parameters related to stroking a path or basic geometry object.
constexpr auto GetBottom() const
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
constexpr auto GetTop() const
constexpr bool Contains(const TPoint< Type > &p) const
Returns true iff the provided point |p| is inside the half-open interior of this rectangle.
constexpr std::array< TPoint< T >, 4 > GetPoints() const
Get the points that represent the 4 corners of this rectangle in a Z order that is compatible with tr...
constexpr auto GetLeft() const
constexpr auto GetRight() const
constexpr TPoint< T > GetLeftBottom() const
constexpr TPoint< T > GetRightTop() const
constexpr TPoint< T > GetRightBottom() const
constexpr TPoint< T > GetLeftTop() const