This reverts commit d2eb581ebc.
Reason for revert: broke Google3 MSAN run of dm
Original change's description:
> offset angle check edge in common
>
> When curves cross, their intersection points may be nearby, but not exactly the same.
> Sort the angles formed by the crossing curves when all angles don't have the same
> origin.
>
> This sets up the framework to solve test case that currently fail (e.g., joel6) but
> does not fix all related test cases (e.g., joel9).
>
> All older existing test cases, including extended tests, pass.
>
> Rework the test framework to better report when tests expected to produce failing
> results now pass.
>
> Add new point and vector operations to support offset angles.
>
> TBR=reed@google.com
> BUG=skia:6041
>
> Change-Id: I67c651ded0a25e99ad93d55d6a35109b3ee3698e
> Reviewed-on: https://skia-review.googlesource.com/6624
> Commit-Queue: Cary Clark <caryclark@google.com>
> Reviewed-by: Cary Clark <caryclark@google.com>
>
TBR=caryclark@google.com,reviews@skia.org
# Not skipping CQ checks because original CL landed > 1 day ago.
BUG=skia:6041
Change-Id: I43db0808522ac44aceeb4f70e296167ea84a3663
Reviewed-on: https://skia-review.googlesource.com/7373
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
When curves cross, their intersection points may be nearby, but not exactly the same.
Sort the angles formed by the crossing curves when all angles don't have the same
origin.
This sets up the framework to solve test case that currently fail (e.g., joel6) but
does not fix all related test cases (e.g., joel9).
All older existing test cases, including extended tests, pass.
Rework the test framework to better report when tests expected to produce failing
results now pass.
Add new point and vector operations to support offset angles.
TBR=reed@google.com
BUG=skia:6041
Change-Id: I67c651ded0a25e99ad93d55d6a35109b3ee3698e
Reviewed-on: https://skia-review.googlesource.com/6624
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Pathops is very well exercised with winding paths,
but less so with xor (even odd) paths.
Rewrite the xor main loop to look like the winding
one to take advantage of the latter's bug fixes.
TBR=reed@google.com
BUG=skia:6041
Change-Id: Ied8d522254a327b1817b54f0abbf4414f5fab7da
Reviewed-on: https://skia-review.googlesource.com/6228
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
SkOpAngle::alignmentSameSide()
Shifting an edge to align it for angle sorting may move a compared edge to the opposite side.
For lines that are shifted, check to see if this is so.
class SkOpContourBuilder
If the path contains a pair of lines that cancel, skip them as early as possible.
While not strictly necessary, this optimization is cheap and makes debugging much easier.
SkOpEdgeBuilder::walk()
case SkPath::kCubic_Verb:
If max curvature or inflections break a cubic into pieces, make sure that the pieces are
large enough to process. If not, add the broken piece back to a neighbor.
Correct debugging that had gone stale.
Add active span debugging cache so only changes are shown.
TBR=reed@google.com
BUG=skia:6401
Change-Id: I766f77e4fb9b76537cf5464961addb103114f5db
Reviewed-on: https://skia-review.googlesource.com/5764
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
The path contains a cubic with a very tight curve.
Split the cubic into pieces so that the individual
curves are better behaved.
Use both inflections and max curvature to
potentially split cubics. Since this may require
a bit of work, preflight to ignore cubics that
monotonically change in x and y.
Only one of the three tests referred to by the bug
below repro'd. Use path.dumpHex() instead of
path.dump() to capture the crashing data.
TBR=reed@google.com
BUG=skia:6041
Change-Id: I29a264f87242cacc7c421e7685b90aca81621c74
Reviewed-on: https://skia-review.googlesource.com/5702
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
This test has nearly coincident lines that are missorted.
The underlying bug is caused when a pair of curves
are coincident when reduced to line segments, but the
end points aren't detected.
The error was generated by running nanobench over all svg
sample data with the distance field patch installed.
TBR=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2440043003
Review-Url: https://codereview.chromium.org/2440043003
If a quad a conic intersect only where the end of one
is contained by the convex hull of the other, and the
curve contained by the hull is nearly a straight line,
treating it as a line may move the end point to the
other side of the curve.
Detect this by checking to see if the end point is in
the hull, and if so, continue to subdivide the curve
rather than treating it as a line.
This fixes several existing tests that were disabled
earlier this year.
A typo in SkDCurve::nearPoint() prevented detecting when
the end of a line was nearly touching a curve.
Also fixed concidence a bit to get the second half of
tiger further along.
All existing tests, including extended testing in
Release and the first half of tiger, work.
TBR=reed@google.com
BUG=skia:5131
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2338323002
Review-Url: https://codereview.chromium.org/2338323002
during curve intersection if their
ends are nearly the same.
Loosen conic/line intersection point
check.
Detect when coincident points are
unordered. This means that points
a/b/c on one curve may appear in
b/c/a order on the opposite curve.
Restructure addMissing to return
success and return if a coincidence
was added as a parameter.
With this, tiger part a works.
Tiger part b exposes bugs around
tight quads that are nearly coincident
with themselves, and are coincident
with something else.
The greedy coicident matcher
may cause the point order to be
out of sync.
Still working out what to do in
this case.
TBR=reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2321773002
Review-Url: https://codereview.chromium.org/2321773002
This is working towards fixing all bugs around simplifying the tiger.
This installment simplifies the point-t intersection list as it is built rather than doing the analysis once the intersections are complete. This avoids getting the list in an inconsistent state and makes coincident checks faster and more stable.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2237223002TBR=reed@google.com
BUG=skia:5131
Review-Url: https://codereview.chromium.org/2237223002
Most changes stem from working on an examples bracketed
by #if DEBUG_UNDER_DEVELOPMENT // tiger
These exposed many problems with coincident curves,
as well as errors throughout the code.
Fixing these errors also fixed a number of fuzzer-inspired
bug reports.
* Line/Curve Intersections
Check to see if the end of the line nearly intersects
the curve. This was a FIXME in the old code.
* Performance
Use a central chunk allocator.
Plumb the allocator into the global variable state
so that it can be shared. (Note that 'SkGlobalState'
is allocated on the stack and is visible to children
functions but not other threads.)
* Refactor
Let SkOpAngle grow up from a structure to a class.
Let SkCoincidentSpans grow up from a structure to a class.
Rename enum Alias to AliasMatch.
* Coincidence Rewrite
Add more debugging to coincidence detection.
Parallel debugging routines have read-only logic to report
the current coincidence state so that steps through the
logic can expose whether things got better or worse.
More functions can error-out and cause the pathops
engine to non-destructively exit.
* Accuracy
Remove code that adjusted point locations. Instead,
offset the curve part so that sorted curves all use
the same origin.
Reduce the size (and influence) of magic numbers.
* Testing
The debug suite with verify and the full release suite
./out/Debug/pathops_unittest -v -V
./out/Release/pathops_unittest -v -V -x
expose one error. That error is captured as cubics_d3.
This error exists in the checked in code as well.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2128633003
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2128633003
Review-Url: https://codereview.chromium.org/2128633003
This fix is a tradeoff. It changes intersection to
treat a case where one coincident run is intersected at one point
and the other edge is not as continuing to be a span.
The old code tried to treat this as a single point.
The old code is probably right, but this change alone
made the data structures inconsistent. Later, extending
the coincident runs would fail by incorrectly discarding
the single point intersection.
As a result, this fixes the security test and one other, but
makes a different test fail. Isolating the failure uncovered
a reduced case that fails with and without the change, so
there are more serious problems here. Those problems are
addressed in a separate CL.
Many of the test edits below remove ill-thought out debugging
messaging that fire off global state, which isn't usable
in a multi-threaded test environment.
In the end, with this fix, all existing tests (modulo one
new failure and one new non-failure) pass in debug and
in the extended release test suites.
TBR=reed@google.com
BUG=614248
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2018513003
Review-Url: https://codereview.chromium.org/2018513003
The utility SubsetPath removes parts of a potentially very large path to isolate a minimal test case. SubsetPath is very useful for debugging path ops, but is not path ops specific.
PathOpsBuilderConicTest compares the output of the Path Ops Builder, sequential calls to Simplify, and SkRegions for some number of rotated ovals.
Some tests caused path ops to hang. It was caught adding a loop of curves because the head was not found by the tail. Even though the root cause has been fixed, SkSegment::addCurveTo callers now abort the path op if the same curve was added twice.
The subdivided conic weight was been computed anew. Fortunately, it's a simpler computation that the one it replaces.
Some Simplify() subroutines returned false to signal that the results needed assembling. Change these to abort the current operation instead.
Coincident curve intersection triggered two small bugs; one where no perpendicular could be found for coincident curves, and one where no coincident curves remain after looping.
The SixtyOvals test can be run through multiple processes instead of multiple threads. This strategy allows a 48 core machine to saturate all cores at 100%.
The DEBUG_VISUALIZE_CONICS code in PathOpsConicIntersectionTest acknowleges that it is easier to visualize conics with Skia than with script and html canvas. This test also verifies that path ops subdivision matches geometry chopping.
TBR=reed@google.com
Review URL: https://codereview.chromium.org/1405383004
Reason for revert:
suppressions have landed in chrome
Original issue's description:
> Revert of path ops: fix conic weight and partial coincidence (patchset #5 id:80001 of https://codereview.chromium.org/1413763002/ )
>
> Reason for revert:
> path ops change breaks svg clipping layout tests -- conic is now more accurate, changing edge of circle in clip
>
> These need to be rebaselined
>
> svg/clip-path/clip-path-child-clipped.svg
> svg/clip-path/clip-path-nonzero.svg
> svg/clip-path/clip-path-evenodd-nonzero.svg
> svg/clip-path/clip-path-nonzero-evenodd.svg
>
> Original issue's description:
> > The remaining 1m skp bugs are asserts that can be harmlessly
> > suppressed and bugs around conics.
> >
> > The conic calculation for a subdivided w was just wrong.
> >
> > Also added debugging to template intersection to initialize
> > reused structures and dump additional data.
> >
> > TBR=reed@google.com
> >
> > Committed: https://skia.googlesource.com/skia/+/ef33b1e739b23a1201100ff17a572da85b03d9af
>
> TBR=
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/f428df1be3e96d3f8970d0f7f415b862f7da5404
TBR=
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1407003016
Reason for revert:
path ops change breaks svg clipping layout tests -- conic is now more accurate, changing edge of circle in clip
These need to be rebaselined
svg/clip-path/clip-path-child-clipped.svg
svg/clip-path/clip-path-nonzero.svg
svg/clip-path/clip-path-evenodd-nonzero.svg
svg/clip-path/clip-path-nonzero-evenodd.svg
Original issue's description:
> The remaining 1m skp bugs are asserts that can be harmlessly
> suppressed and bugs around conics.
>
> The conic calculation for a subdivided w was just wrong.
>
> Also added debugging to template intersection to initialize
> reused structures and dump additional data.
>
> TBR=reed@google.com
>
> Committed: https://skia.googlesource.com/skia/+/ef33b1e739b23a1201100ff17a572da85b03d9af
TBR=
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1408923003
suppressed and bugs around conics.
The conic calculation for a subdivided w was just wrong.
Also added debugging to template intersection to initialize
reused structures and dump additional data.
TBR=reed@google.com
Review URL: https://codereview.chromium.org/1413763002
Iterating through the 903K skps that represent the
imagable 1M top web pages triggers a number of
bugs, some of which are addressed here.
Some web pages trigger intersecting cubic
representations of arc with their conic
counterparts. This exposed a flaw in coincident
detection that caused an infinite loop. The loop
alternatively extended the coincident section and,
determining the that the bounds of the curve pairs
did not overlap, deleted the extension.
Track the number of times the coincident detection
is called, and if it exceeds an empirically found
limit, assume that the curves are coincident and
force it to be so.
The loop count limit can be determined by enabling
DEBUG_T_SECT_LOOP_COUNT and running all tests. The
largest count is reported on completion.
Another class of bugs was caused by concident
detection duplicating nearly identical points that
had been merged earlier. To track these bugs, the
'handle coincidence' code was duplicated as a
const debug variety that reported if one of a
dozen or so irregularities are present; then it is
easier to see when a block of code that fixes one
irregularity regresses another.
Creating the debug const code version exposed some
non-debug code that could be const, and some that
was experimental and could be removed. Set
DEBUG_COINCIDENCE to track coincidence health and
handling.
For running on Chrome, DEBUG_VERIFY checks the
result of pathops against the same operation
using SkRegion to verify that the results are
nearly the same.
When visualizing the pathops work using
tools/pathops_visualizer.htm, set
DEBUG_DUMP_ALIGNMENT to see the curves after
they've been aligned for coincidence.
Other bugs fixed include detecting when a
section of a pair of curves have devolved into
lines and are coincident.
TBR=reed@google.com
Review URL: https://codereview.chromium.org/1394503003
to compute the overlapping ranges and combine the winding
into a single destination.
This computes coincidence more rigorously, fixing the
edge cases exposed by this bug.
Also, add the ability to debug and dump pathop structures
from the coincident context.
TBR=reed@google.com
BUG=skia:3651
Review URL: https://codereview.chromium.org/1182493015
Improve line/curve coincident detection and resolution. This fixed the remaining simple failures.
When an edge is unsortable, use the ray intersection to determine the angles' winding.
Deal with degenerate segments.
TBR=reed@google.com
BUG=skia:3588,skia:3762
Review URL: https://codereview.chromium.org/1140813002
This replacement shoots axis-aligned rays through all intersecting edges to find the outermost one either horizontally or vertically. The resulting code is smaller and twice as fast.
To support this, most of the horizontal / vertical intersection code was rewritten and standardized, and old code supporting the top-directed winding was deleted.
Contours were pointed to by an SkTDArray. Instead, put them in a linked list, and designate the list head with its own class to ensure that methods that take lists of contours start at the top. This change removed a large percentage of memory allocations used by path ops.
TBR=reed@google.com
BUG=skia:3588
Review URL: https://codereview.chromium.org/1111333002
All but 17 extended tests work.
A helper function is privately added to SkPath.h to permit a test to modify a given point in a path.
BUG=skia:3588
Review URL: https://codereview.chromium.org/1107353004
Extended tests (150M+) run to completion in release in about 6 minutes; the standard test suite exceeds 100K and finishes in a few seconds on desktops.
TBR=reed
BUG=skia:3588
Review URL: https://codereview.chromium.org/1037953004
Replace the implicit curve intersection with a geometric curve intersection. The implicit intersection proved mathematically unstable and took a long time to zero in on an answer.
Use pointers instead of indices to refer to parts of curves. Indices required awkward renumbering.
Unify t and point values so that small intervals can be eliminated in one pass.
Break cubics up front to eliminate loops and cusps.
Make the Simplify and Op code more regular and eliminate arbitrary differences.
Add a builder that takes an array of paths and operators.
Delete unused code.
BUG=skia:3588
R=reed@google.com
Review URL: https://codereview.chromium.org/1037573004
The fixes include
- detect when finding the active top loops between two possible answers
- preflight chasing winding to ensure answer is consistent
- binary search more often when quadratic intersection fails
- add more failure paths when an intersect is missed
While this fixes the chrome bug, reenabling path ops in svg should be deferred until additional fixes are landed.
TBR=
BUG=421132
Committed: https://skia.googlesource.com/skia/+/6f726addf3178b01949bb389ef83cf14a1d7b6b2
Review URL: https://codereview.chromium.org/633393002
Reason for revert:
Compile errors on bots
Original issue's description:
> These tests stress pathops by describing the union of circle-like paths that have tiny line segments embedded and double back to create near-coincident conditions.
>
> The fixes include
> - detect when finding the active top loops between two possible answers
> - preflight chasing winding to ensure answer is consistent
> - binary search more often when quadratic intersection fails
> - add more failure paths when an intersect is missed
>
> While this fixes the chrome bug, reenabling path ops in svg should be deferred until additional fixes are landed.
>
> TBR=
> BUG=421132
>
> Committed: https://skia.googlesource.com/skia/+/6f726addf3178b01949bb389ef83cf14a1d7b6b2TBR=caryclark@google.com
NOTREECHECKS=true
NOTRY=true
BUG=421132
Review URL: https://codereview.chromium.org/686843002
The fixes include
- detect when finding the active top loops between two possible answers
- preflight chasing winding to ensure answer is consistent
- binary search more often when quadratic intersection fails
- add more failure paths when an intersect is missed
While this fixes the chrome bug, reenabling path ops in svg should be deferred until additional fixes are landed.
TBR=
BUG=421132
Review URL: https://codereview.chromium.org/633393002
Extreme implicit quartic equations solve to roots that are different
enough that they appear to have failed. In this case, fall back on
binary searching to find an intersection.
Relax the condition when this happens; don't give up just because the
computed implicit root points aren't remotely the same.
TBR=reed
BUG=skia:2808
Author: caryclark@google.com
Review URL: https://codereview.chromium.org/456383003
This fixes the last bug discovered by iterating through the 800K
skp corpus representing the top 1M websites. For every clip on the
stack, the paths are replaced with the pathop intersection. The
resulting draw is compared with the original draw for pixel errors.
At least two prominent bugs remain. In one, the winding value is
confused by a cubic with an inflection. In the other, a quad/cubic
pair, nearly coincident, fails to find an intersection.
These minor changes include ignoring very tiny self-intersections
of cubics, and processing degenerate edges that don't connect to
anything else.
R=reed@android.com
TBR=reed
Author: caryclark@google.com
Review URL: https://codereview.chromium.org/340103002
This fixes all but one of those failures.
Major changes include:
- Replace angle indices with angle pointers. This was motivated by the need to add angles later but not renumber existing angles.
- Aggressive segment chase. When the winding is known on a segment, more aggressively passing that winding to adjacent segments allows fragmented data sets to succeed.
- Line segments with ends nearly the same are treated as coincident first.
- Transfer partial coincidence by observing that if segment A is partially coincident to B and C then B and C may be partially coincident.
TBR=reed
Author: caryclark@google.com
Review URL: https://codereview.chromium.org/272153002