22 return padding_pixels_;
31 Scalar padding = max_basis == 0 ? 0 : padding_pixels_ / max_basis;
38 data_host_buffer.Emplace(expanded_rect.
GetPoints().data(),
39 8 *
sizeof(
float),
alignof(
float)),
51 Scalar padding = max_basis == 0 ? 0 : padding_pixels_ / max_basis;
56 const Rect& rect)
const {
57 if (!
transform.IsTranslationScaleOnly()) {
71 stroke_width_(stroke.width),
72 stroke_join_(AdjustStrokeJoin(stroke)) {}
80 if (stroke_width_ < 0.0) {
89 Scalar stroke_width = std::max(stroke_width_, min_size);
90 Scalar half_stroke_width = stroke_width * 0.5f;
93 const Rect& rect = rect_;
94 bool interior_filled = (stroke_width >= rect.
GetSize().MinDimension());
96 switch (stroke_join_) {
102 FML_DCHECK(trigs.
size() >= 2u);
104 auto vertex_count = trigs.
size() * 4;
105 if (!interior_filled) {
116 .vertex_buffer = data_host_buffer.Emplace(
118 [hsw = half_stroke_width, &rect, vertex_count, &trigs,
119 interior_filled](uint8_t* buffer) {
125 auto vertices =
reinterpret_cast<Point*
>(buffer);
127 auto vertices_end = vertices + vertex_count;
132 for (
auto trig : trigs) {
135 *vertices++ =
Point(left - trig.sin * hsw,
136 top - trig.cos * hsw);
137 *vertices++ =
Point(right + trig.sin * hsw,
138 top - trig.cos * hsw);
145 if (interior_filled) {
156 *vertices++ =
Point(left - hsw, top + hsw);
157 *vertices++ =
Point(right + hsw, top + hsw);
169 *vertices++ =
Point(right - hsw, top + hsw);
170 *vertices++ =
Point(right + hsw, bottom - hsw);
171 *vertices++ =
Point(right - hsw, bottom - hsw);
177 *vertices++ =
Point(right - hsw, bottom - hsw);
178 *vertices++ =
Point(left + hsw, top + hsw);
184 *vertices++ =
Point(left + hsw, top + hsw);
185 *vertices++ =
Point(left - hsw, top + hsw);
186 *vertices++ =
Point(left + hsw, bottom - hsw);
187 *vertices++ =
Point(left - hsw, bottom - hsw);
200 *vertices++ =
Point(right + hsw, bottom - hsw);
207 for (
auto trig : trigs) {
210 *vertices++ =
Point(left - trig.cos * hsw,
211 bottom + trig.sin * hsw);
212 *vertices++ =
Point(right + trig.cos * hsw,
213 bottom + trig.sin * hsw);
217 FML_DCHECK(vertices == vertices_end);
219 .vertex_count = vertex_count,
228 if (interior_filled) {
233 .vertex_buffer = data_host_buffer.Emplace(
235 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
240 auto vertices =
reinterpret_cast<Point*
>(buffer);
241 vertices[0] =
Point(left, top - hsw);
242 vertices[1] =
Point(right, top - hsw);
243 vertices[2] =
Point(left - hsw, top);
244 vertices[3] =
Point(right + hsw, top);
245 vertices[4] =
Point(left - hsw, bottom);
246 vertices[5] =
Point(right + hsw, bottom);
247 vertices[6] =
Point(left, bottom + hsw);
248 vertices[7] =
Point(right, bottom + hsw);
261 .vertex_buffer = data_host_buffer.Emplace(
263 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
268 auto vertices =
reinterpret_cast<Point*
>(buffer);
269 vertices[0] =
Point(left - hsw, top);
270 vertices[1] =
Point(left + hsw, top + hsw);
271 vertices[2] =
Point(left, top - hsw);
272 vertices[3] =
Point(right - hsw, top + hsw);
273 vertices[4] =
Point(right, top - hsw);
274 vertices[5] =
Point(right - hsw, top + hsw);
275 vertices[6] =
Point(right + hsw, top);
276 vertices[7] =
Point(right - hsw, bottom - hsw);
277 vertices[8] =
Point(right + hsw, bottom);
278 vertices[9] =
Point(right - hsw, bottom - hsw);
279 vertices[10] =
Point(right, bottom + hsw);
280 vertices[11] =
Point(left + hsw, bottom - hsw);
281 vertices[12] =
Point(left, bottom + hsw);
282 vertices[13] =
Point(left + hsw, bottom - hsw);
283 vertices[14] =
Point(left - hsw, bottom);
284 vertices[15] =
Point(left + hsw, top + hsw);
285 vertices[16] =
Point(left - hsw, top);
296 if (interior_filled) {
301 .vertex_buffer = data_host_buffer.Emplace(
303 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
308 auto vertices =
reinterpret_cast<Point*
>(buffer);
310 vertices[0] =
Point(left - hsw, top - hsw);
311 vertices[1] =
Point(right + hsw, top - hsw);
312 vertices[2] =
Point(left - hsw, bottom + hsw);
313 vertices[3] =
Point(right + hsw, bottom + hsw);
326 .vertex_buffer = data_host_buffer.Emplace(
328 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
333 auto vertices =
reinterpret_cast<Point*
>(buffer);
334 vertices[0] =
Point(left - hsw, top - hsw);
335 vertices[1] =
Point(left + hsw, top + hsw);
336 vertices[2] =
Point(right + hsw, top - hsw);
337 vertices[3] =
Point(right - hsw, top + hsw);
338 vertices[4] =
Point(right + hsw, bottom + hsw);
339 vertices[5] =
Point(right - hsw, bottom - hsw);
340 vertices[6] =
Point(left - hsw, bottom + hsw);
341 vertices[7] =
Point(left + hsw, bottom - hsw);
342 vertices[8] =
Point(left - hsw, top - hsw);
343 vertices[9] =
Point(left + hsw, top + hsw);
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
Tessellator & GetTessellator() const
Matrix GetShaderTransform(const RenderPass &pass) const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Scalar GetAntialiasPadding() const
void SetAntialiasPadding(Scalar padding)
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...
const Rect & GetRect() const
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)
Vector2 padding
The halo padding in source space.
Join
An enum that describes ways to join two segments of a path.
@ kNone
Does not use the index buffer.
static constexpr Scalar kMinStrokeSize
@ kNormal
The geometry has no overlapping triangles.
A 4x4 matrix using column-major storage.
Scalar GetMaxBasisLengthXY() const
Return the maximum scale applied specifically to either the X axis or Y axis unit vectors (the bases)...
A structure to store all of the parameters related to stroking a path or basic geometry object.
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
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 TSize< Type > GetSize() const
Returns the size of the rectangle which may be negative in either width or height and may have been c...
constexpr auto GetRight() const
constexpr TRect TransformAndClipBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle, clipped against the near clippin...