mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Fix stroke curves. (flutter/engine#52978)
Resolves https://github.com/flutter/flutter/issues/147139. Added an explanation inline for why we need to use different direction values depending on whether or not we're capping off the last component of the contour. Before: <img width="640" alt="Screenshot 2024-05-21 at 11 18 51â¯PM" src="https://github.com/flutter/engine/assets/919017/22d9fee7-834f-4cb4-8ed4-578a7c17f7a2"> <img width="121" alt="Screenshot 2024-05-21 at 11 19 35â¯PM" src="https://github.com/flutter/engine/assets/919017/419029b1-9a5f-4a30-bbb0-83dafc79f7df"> After: <img width="640" alt="Screenshot 2024-05-21 at 11 17 25â¯PM" src="https://github.com/flutter/engine/assets/919017/629e30a5-d0c5-4b7a-a3e2-bf715aa4ba78"> <img width="115" alt="Screenshot 2024-05-21 at 11 16 38â¯PM" src="https://github.com/flutter/engine/assets/919017/12e51892-6009-47d0-a4e5-1f1b017c99e8">
This commit is contained in:
parent
9a392e9e07
commit
5b84b2c85b
@ -232,9 +232,17 @@ class StrokeGenerator {
|
||||
// For curve components, the polyline is detailed enough such that
|
||||
// it can avoid worrying about joins altogether.
|
||||
if (is_end_of_component) {
|
||||
vtx.position = polyline.GetPoint(point_i + 1) + offset;
|
||||
// Append two additional vertices to close off the component. If we're
|
||||
// on the _last_ component of the contour then we need to use the
|
||||
// contour's end direction.
|
||||
// `ComputeOffset` returns the contour's end direction when attempting
|
||||
// to grab offsets past `contour_end_point_i`, so just use `offset` when
|
||||
// we're on the last component.
|
||||
Point last_component_offset =
|
||||
is_last_component ? offset : previous_offset;
|
||||
vtx.position = polyline.GetPoint(point_i + 1) + last_component_offset;
|
||||
vtx_builder.AppendVertex(vtx.position);
|
||||
vtx.position = polyline.GetPoint(point_i + 1) - offset;
|
||||
vtx.position = polyline.GetPoint(point_i + 1) - last_component_offset;
|
||||
vtx_builder.AppendVertex(vtx.position);
|
||||
// Generate join from the current line to the next line.
|
||||
if (!is_last_component) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user