61 if (stroke_width_ < 0.0) {
64 Scalar max_basis = entity.GetTransform().GetMaxBasisLengthXY();
70 Scalar half_stroke_width = std::max(stroke_width_, min_size) * 0.5f;
72 auto& host_buffer = renderer.GetTransientsBuffer();
73 const Rect& rect = rect_;
75 switch (stroke_join_) {
77 Tessellator::Trigs trigs =
78 renderer.GetTessellator().GetTrigsForDeviceRadius(half_stroke_width *
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;
94 return GeometryResult{
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(
113 vertices, rect.GetRightBottom(),
Vector2(hsw, 0),
115 vertices = AppendRoundCornerJoin(
116 vertices, rect.GetLeftBottom(),
Vector2(0, hsw),
121 *vertices++ = rect.GetLeftTop() -
Vector2(hsw, 0);
122 *vertices++ = rect.GetLeftTop() +
Vector2(hsw, 0);
125 FML_DCHECK(vertices == vertices_end);
127 .vertex_count = vertex_count,
130 .transform = entity.GetShaderTransform(pass),
135 return GeometryResult{
139 .vertex_buffer = host_buffer.Emplace(
141 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
142 Scalar left = rect.GetLeft();
143 Scalar top = rect.GetTop();
144 Scalar right = rect.GetRight();
145 Scalar bottom = rect.GetBottom();
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);
168 .transform = entity.GetShaderTransform(pass),
173 return GeometryResult{
177 .vertex_buffer = host_buffer.Emplace(
179 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
180 Scalar left = rect.GetLeft();
181 Scalar top = rect.GetTop();
182 Scalar right = rect.GetRight();
183 Scalar bottom = rect.GetBottom();
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);
199 .transform = entity.GetShaderTransform(pass),
@ kNone
Does not use the index buffer.
static constexpr Scalar kMinStrokeSize