Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Issue 233063003: Improve the reliability and accuracy of SVG getTotalLength (Closed)

Created:
6 years, 8 months ago by Stephen Chennney
Modified:
6 years, 8 months ago
Reviewers:
pdr., f(malita), fs
CC:
blink-reviews, jamesr, krit, dsinclair, jbroman, danakj, Rik, Stephen Chennney, pdr., rwlbuis
Visibility:
Public.

Description

Improve the reliability and accuracy of SVG getTotalLength The existing code for SVG path.getTotalLength had two problems when subdividing curves to estimate length. The subdivision terminated when the straight-line vs curved length was within a fixed limit, regardless of the scale of the curve. The termination condition for infinite loops also failed to stop on infinite loops. This patch fixes both issues. The subdivision threshold now accounts for the magnitude of the values, so that we give more resolution on very small curves and less on very large curves. This is consistent with the actual precision we have in floating point numbers. The infinite loop termination tracks and examines the total number of subdivisions thus far, terminating after 20 (which is more than enough - most curves do no more than 10 subdivisions). We also remove two unused variables and a FIXME that makes little sense and that we won't ever fix. R=fmalita@chromium.org, pdr@chromium.org, fs@opera.com BUG=349873 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=172519

Patch Set 1 #

Total comments: 10

Patch Set 2 : Improved #

Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -34 lines) Patch
M LayoutTests/svg/custom/path-getTotalLength.svg View 1 2 chunks +10 lines, -9 lines 0 comments Download
M LayoutTests/svg/custom/path-getTotalLength-expected.txt View 1 1 chunk +6 lines, -4 lines 0 comments Download
M Source/platform/graphics/PathTraversalState.h View 1 1 chunk +0 lines, -2 lines 0 comments Download
M Source/platform/graphics/PathTraversalState.cpp View 1 9 chunks +29 lines, -19 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
f(malita)
I can buy an argument for adjusting the precision dynamically based on magnitude, but I'm ...
6 years, 8 months ago (2014-04-10 20:09:06 UTC) #1
fs
The >30k entries in the measurements Florin did has me kind of worried... https://codereview.chromium.org/233063003/diff/1/Source/platform/graphics/PathTraversalState.cpp File ...
6 years, 8 months ago (2014-04-11 10:29:17 UTC) #2
f(malita)
On 2014/04/11 10:29:17, fs wrote: > https://codereview.chromium.org/233063003/diff/1/Source/platform/graphics/PathTraversalState.cpp#newcode147 > Source/platform/graphics/PathTraversalState.cpp:147: if ((lengthDiscrepancy * > lengthDiscrepancy) / ...
6 years, 8 months ago (2014-04-11 13:22:48 UTC) #3
Stephen Chennney
Also, regarding the extra iterations. It is probably a combination of the extra precision and ...
6 years, 8 months ago (2014-04-11 13:48:02 UTC) #4
fs
https://codereview.chromium.org/233063003/diff/1/Source/platform/graphics/PathTraversalState.cpp File Source/platform/graphics/PathTraversalState.cpp (right): https://codereview.chromium.org/233063003/diff/1/Source/platform/graphics/PathTraversalState.cpp#newcode147 Source/platform/graphics/PathTraversalState.cpp:147: if ((lengthDiscrepancy * lengthDiscrepancy) / curveScaleForToleranceSquared > pathSegmentLengthToleranceSquared && ...
6 years, 8 months ago (2014-04-11 14:49:11 UTC) #5
fs
On 2014/04/11 13:22:48, Florin Malita wrote: > On 2014/04/11 10:29:17, fs wrote: > > > ...
6 years, 8 months ago (2014-04-11 14:53:00 UTC) #6
Stephen Chennney
OK, this version resolves the complaints, I think. I reduced the tolerance to 10e-16, which ...
6 years, 8 months ago (2014-04-11 15:28:02 UTC) #7
Stephen Chennney
Bump.
6 years, 8 months ago (2014-04-16 14:48:43 UTC) #8
f(malita)
lgtm
6 years, 8 months ago (2014-04-24 15:45:42 UTC) #9
Stephen Chennney
The CQ bit was checked by schenney@chromium.org
6 years, 8 months ago (2014-04-24 15:49:28 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/schenney@chromium.org/233063003/20001
6 years, 8 months ago (2014-04-24 15:49:46 UTC) #11
commit-bot: I haz the power
6 years, 8 months ago (2014-04-24 16:51:10 UTC) #12
Message was sent while issue was closed.
Change committed as 172519

Powered by Google App Engine
This is Rietveld 408576698