62 if (stroke_width_ < 0.0) {
65 Scalar max_basis = entity.GetTransform().GetMaxBasisLengthXY();
71 Scalar stroke_width = std::max(stroke_width_, min_size);
72 Scalar half_stroke_width = stroke_width * 0.5f;
74 auto& data_host_buffer = renderer.GetTransientsDataBuffer();
75 const Rect& rect = rect_;
76 bool interior_filled = (stroke_width >= rect.GetSize().MinDimension());
78 switch (stroke_join_) {
80 Tessellator::Trigs trigs =
81 renderer.GetTessellator().GetTrigsForDeviceRadius(half_stroke_width *
84 FML_DCHECK(trigs.size() >= 2u);
86 auto vertex_count = trigs.size() * 4;
87 if (!interior_filled) {
94 return GeometryResult{
98 .vertex_buffer = data_host_buffer.Emplace(
100 [hsw = half_stroke_width, &rect, vertex_count, &trigs,
101 interior_filled](uint8_t* buffer) {
102 Scalar left = rect.GetLeft();
103 Scalar top = rect.GetTop();
104 Scalar right = rect.GetRight();
105 Scalar bottom = rect.GetBottom();
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,
204 .transform = entity.GetShaderTransform(pass),
210 if (interior_filled) {
211 return GeometryResult{
215 .vertex_buffer = data_host_buffer.Emplace(
217 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
218 Scalar left = rect.GetLeft();
219 Scalar top = rect.GetTop();
220 Scalar right = rect.GetRight();
221 Scalar bottom = rect.GetBottom();
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);
235 .transform = entity.GetShaderTransform(pass),
239 return GeometryResult{
243 .vertex_buffer = data_host_buffer.Emplace(
245 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
246 Scalar left = rect.GetLeft();
247 Scalar top = rect.GetTop();
248 Scalar right = rect.GetRight();
249 Scalar bottom = rect.GetBottom();
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);
272 .transform = entity.GetShaderTransform(pass),
278 if (interior_filled) {
279 return GeometryResult{
283 .vertex_buffer = data_host_buffer.Emplace(
285 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
286 Scalar left = rect.GetLeft();
287 Scalar top = rect.GetTop();
288 Scalar right = rect.GetRight();
289 Scalar bottom = rect.GetBottom();
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);
300 .transform = entity.GetShaderTransform(pass),
304 return GeometryResult{
308 .vertex_buffer = data_host_buffer.Emplace(
310 [hsw = half_stroke_width, &rect](uint8_t* buffer) {
311 Scalar left = rect.GetLeft();
312 Scalar top = rect.GetTop();
313 Scalar right = rect.GetRight();
314 Scalar bottom = rect.GetBottom();
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);
330 .transform = entity.GetShaderTransform(pass),
@ kNone
Does not use the index buffer.
static constexpr Scalar kMinStrokeSize
@ kNormal
The geometry has no overlapping triangles.