22 .vertex_buffer = data_host_buffer.Emplace(
23 rect_.
GetPoints().data(), 8 *
sizeof(
float),
alignof(
float)),
38 const Rect& rect)
const {
39 if (!
transform.IsTranslationScaleOnly()) {
53 stroke_width_(stroke.width),
54 stroke_join_(AdjustStrokeJoin(stroke)) {}
62 if (stroke_width_ < 0.0) {
71 Scalar stroke_width = std::max(stroke_width_, min_size);
72 Scalar half_stroke_width = stroke_width * 0.5f;
75 const Rect& rect = rect_;
76 bool interior_filled = (stroke_width >= rect.
GetSize().MinDimension());
78 switch (stroke_join_) {
84 FML_DCHECK(trigs.
size() >= 2u);
86 auto vertex_count = trigs.
size() * 4;
87 if (!interior_filled) {
98 .vertex_buffer = data_host_buffer.Emplace(
100 [hsw = half_stroke_width, &rect, vertex_count, &trigs,
101 interior_filled](uint8_t* buffer) {
107 auto vertices =
reinterpret_cast<Point*
>(buffer);
109 auto vertices_end = vertices + vertex_count;
114 for (
auto trig : trigs) {
117 *vertices++ =
Point(left - trig.sin * hsw,
118 top - trig.cos * hsw);
119 *vertices++ =
Point(right + trig.sin * hsw,
120 top - trig.cos * hsw);
127 if (interior_filled) {
138 *vertices++ =
Point(left - hsw, top + hsw);
139 *vertices++ =
Point(right + hsw, top + hsw);
151 *vertices++ =
Point(right - hsw, top + hsw);
152 *vertices++ =
Point(right + hsw, bottom - hsw);
153 *vertices++ =
Point(right - hsw, bottom - hsw);
159 *vertices++ =
Point(right - hsw, bottom - hsw);
160 *vertices++ =
Point(left + hsw, top + hsw);
166 *vertices++ =
Point(left + hsw, top + hsw);
167 *vertices++ =
Point(left - hsw, top + hsw);
168 *vertices++ =
Point(left + hsw, bottom - hsw);
169 *vertices++ =
Point(left - hsw, bottom - hsw);
182 *vertices++ =
Point(right + hsw, bottom - hsw);
189 for (
auto trig : trigs) {
192 *vertices++ =
Point(left - trig.cos * hsw,
193 bottom + trig.sin * hsw);
194 *vertices++ =
Point(right + trig.cos * hsw,
195 bottom + trig.sin * hsw);
199 FML_DCHECK(vertices == vertices_end);
201 .vertex_count = vertex_count,
210 if (interior_filled) {
215 .vertex_buffer = data_host_buffer.Emplace(
217 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
222 auto vertices =
reinterpret_cast<Point*
>(buffer);
223 vertices[0] =
Point(left, top - hsw);
224 vertices[1] =
Point(right, top - hsw);
225 vertices[2] =
Point(left - hsw, top);
226 vertices[3] =
Point(right + hsw, top);
227 vertices[4] =
Point(left - hsw, bottom);
228 vertices[5] =
Point(right + hsw, bottom);
229 vertices[6] =
Point(left, bottom + hsw);
230 vertices[7] =
Point(right, bottom + hsw);
243 .vertex_buffer = data_host_buffer.Emplace(
245 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
250 auto vertices =
reinterpret_cast<Point*
>(buffer);
251 vertices[0] =
Point(left - hsw, top);
252 vertices[1] =
Point(left + hsw, top + hsw);
253 vertices[2] =
Point(left, top - hsw);
254 vertices[3] =
Point(right - hsw, top + hsw);
255 vertices[4] =
Point(right, top - hsw);
256 vertices[5] =
Point(right - hsw, top + hsw);
257 vertices[6] =
Point(right + hsw, top);
258 vertices[7] =
Point(right - hsw, bottom - hsw);
259 vertices[8] =
Point(right + hsw, bottom);
260 vertices[9] =
Point(right - hsw, bottom - hsw);
261 vertices[10] =
Point(right, bottom + hsw);
262 vertices[11] =
Point(left + hsw, bottom - hsw);
263 vertices[12] =
Point(left, bottom + hsw);
264 vertices[13] =
Point(left + hsw, bottom - hsw);
265 vertices[14] =
Point(left - hsw, bottom);
266 vertices[15] =
Point(left + hsw, top + hsw);
267 vertices[16] =
Point(left - hsw, top);
278 if (interior_filled) {
283 .vertex_buffer = data_host_buffer.Emplace(
285 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
290 auto vertices =
reinterpret_cast<Point*
>(buffer);
292 vertices[0] =
Point(left - hsw, top - hsw);
293 vertices[1] =
Point(right + hsw, top - hsw);
294 vertices[2] =
Point(left - hsw, bottom + hsw);
295 vertices[3] =
Point(right + hsw, bottom + hsw);
308 .vertex_buffer = data_host_buffer.Emplace(
310 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
315 auto vertices =
reinterpret_cast<Point*
>(buffer);
316 vertices[0] =
Point(left - hsw, top - hsw);
317 vertices[1] =
Point(left + hsw, top + hsw);
318 vertices[2] =
Point(right + hsw, top - hsw);
319 vertices[3] =
Point(right - hsw, top + hsw);
320 vertices[4] =
Point(right + hsw, bottom + hsw);
321 vertices[5] =
Point(right - hsw, bottom - hsw);
322 vertices[6] =
Point(left - hsw, bottom + hsw);
323 vertices[7] =
Point(left + hsw, bottom - hsw);
324 vertices[8] =
Point(left - hsw, top - hsw);
325 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.
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)
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 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