[SVG] Fix precision loss in non-scaling-stroke with large coordinate translations #55856
+12
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When SVG paths use vector-effect="non-scaling-stroke" with large
viewBox coordinate translations (e.g. viewBox="2137678 0 96 50"),
vertical lines would disappear due to floating-point precision loss
in the transform calculations.
The issue occurred because
ComputeNonScalingStrokeTransform()waszeroing out translation components (SetE(0), SetF(0)) under the
assumption that "stroke width is independent of translation."
While this is true for stroke width calculation, removing
translation can lead to large coordinate values, increasing the
risk of precision loss as seen in the bug.
In this CL, we preserve translation components in the
non-scaling-stroke transform. This mitigates the precision loss
caused by large offset but we only preserve this translation for
non-scaling-stroke-path and not in general.
Bug: 40718465
Change-Id: Id92acf5c5798eab264df33d8a4af4759376483f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7106499
Reviewed-by: Fredrik Söderquist <[email protected]>
Reviewed-by: Vinay Singh <[email protected]>
Commit-Queue: Divyansh Mangal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1540470}