80 if (stroke_width_ < 0.0) {
83 Scalar max_basis = entity.GetTransform().GetMaxBasisLengthXY();
89 Scalar stroke_width = std::max(stroke_width_, min_size);
90 Scalar half_stroke_width = stroke_width * 0.5f;
92 auto& data_host_buffer = renderer.GetTransientsDataBuffer();
93 const Rect& rect = rect_;
94 bool interior_filled = (stroke_width >= rect.GetSize().MinDimension());
96 switch (stroke_join_) {
98 Tessellator::Trigs trigs =
99 renderer.GetTessellator().GetTrigsForDeviceRadius(half_stroke_width *
102 FML_DCHECK(trigs.size() >= 2u);
104 auto vertex_count = trigs.size() * 4;
105 if (!interior_filled) {
112 return GeometryResult{
116 .vertex_buffer = data_host_buffer.Emplace(
118 [hsw = half_stroke_width, &rect, vertex_count, &trigs,
119 interior_filled](uint8_t* buffer) {
120 Scalar left = rect.GetLeft();
121 Scalar top = rect.GetTop();
122 Scalar right = rect.GetRight();
123 Scalar bottom = rect.GetBottom();
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,
222 .transform = entity.GetShaderTransform(pass),
228 if (interior_filled) {
229 return GeometryResult{
233 .vertex_buffer = data_host_buffer.Emplace(
235 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
236 Scalar left = rect.GetLeft();
237 Scalar top = rect.GetTop();
238 Scalar right = rect.GetRight();
239 Scalar bottom = rect.GetBottom();
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);
253 .transform = entity.GetShaderTransform(pass),
257 return GeometryResult{
261 .vertex_buffer = data_host_buffer.Emplace(
263 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
264 Scalar left = rect.GetLeft();
265 Scalar top = rect.GetTop();
266 Scalar right = rect.GetRight();
267 Scalar bottom = rect.GetBottom();
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);
290 .transform = entity.GetShaderTransform(pass),
296 if (interior_filled) {
297 return GeometryResult{
301 .vertex_buffer = data_host_buffer.Emplace(
303 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
304 Scalar left = rect.GetLeft();
305 Scalar top = rect.GetTop();
306 Scalar right = rect.GetRight();
307 Scalar bottom = rect.GetBottom();
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);
318 .transform = entity.GetShaderTransform(pass),
322 return GeometryResult{
326 .vertex_buffer = data_host_buffer.Emplace(
328 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
329 Scalar left = rect.GetLeft();
330 Scalar top = rect.GetTop();
331 Scalar right = rect.GetRight();
332 Scalar bottom = rect.GetBottom();
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);
348 .transform = entity.GetShaderTransform(pass),
@ kNone
Does not use the index buffer.
static constexpr Scalar kMinStrokeSize
@ kNormal
The geometry has no overlapping triangles.