Use std::min and std::max everywhere.
SkTPin still exists. We can't use std::clamp yet, and even when
we can, it has undefined behavior with NaN. SkTPin is written
to ensure that we return a value in the [lo, hi] range.
Change-Id: I506852a36e024ae405358d5078a872e2c77fa71e
Docs-Preview: https://skia.org/?cl=269357
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269357
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Current strategy: everything from the top
Things to look at first are the manual changes:
- added tools/rewrite_includes.py
- removed -Idirectives from BUILD.gn
- various compile.sh simplifications
- tweak tools/embed_resources.py
- update gn/find_headers.py to write paths from the top
- update gn/gn_to_bp.py SkUserConfig.h layout
so that #include "include/config/SkUserConfig.h" always
gets the header we want.
No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
(fixing msan/asan/ubsan failure)
Pathops used templates for curve intersection.
Since only one template is required if curves share
an abstract base, remove the template altogether.
This makes the code easier to read, and incidentally
makes it slightly smaller and much faster.
This also removes debugging code specific to templates,
and removes Simplify code which isn't covered by tests
or fuzz.
This shaves the execution time of
pathops_unittest -V -x from 6m to 3m23s.
R=kjlubick@google.com
Bug: skia:
Change-Id: I3392df98244083d0327ce9c787dfe24d326ef4ed
Reviewed-on: https://skia-review.googlesource.com/c/162742
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
This reverts commit 521f1ed0b6.
Reason for revert: msan ubsan errors
Original change's description:
> remove pathop template
>
> Pathops used templates for curve intersection.
> Since only one template is required if curves share
> an abstract base, remove the template altogether.
>
> This makes the code easier to read, and incidentally
> makes it slightly smaller and much faster.
>
> This also removes debugging code specific to templates,
> and removes Simplify code which isn't covered by tests
> or fuzz.
>
> This shaves the execution time of
> pathops_unittest -V -x from 6m to 3m23s.
>
> R=kjlubick@google.com
>
> Bug: skia:
> Change-Id: I00c08210e47efed83295276ae89ad64e7ec07ade
> Reviewed-on: https://skia-review.googlesource.com/c/162021
> Commit-Queue: Cary Clark <caryclark@google.com>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Cary Clark <caryclark@google.com>
TBR=kjlubick@google.com,caryclark@google.com,caryclark@skia.org
Change-Id: Ic5828f7affb7df96ed4ca79f037cdbcfaea24384
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/162643
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
Pathops used templates for curve intersection.
Since only one template is required if curves share
an abstract base, remove the template altogether.
This makes the code easier to read, and incidentally
makes it slightly smaller and much faster.
This also removes debugging code specific to templates,
and removes Simplify code which isn't covered by tests
or fuzz.
This shaves the execution time of
pathops_unittest -V -x from 6m to 3m23s.
R=kjlubick@google.com
Bug: skia:
Change-Id: I00c08210e47efed83295276ae89ad64e7ec07ade
Reviewed-on: https://skia-review.googlesource.com/c/162021
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Pathops uses a template to intersect a pair of curves.
This generates six copies: quad/quad, quad/conic, quad/cubic,
conic/conic, conic/cubic, cubic/cubic.
This CL rewrites the template to generate a single copy,
and leverages a new abstract class, SkTCurve, to dispatch
to one of SkTQuad, SkTConic, or SkTCubic. These classes
are thin wrappers on the existing double curves classes
SkDQuad, SkDConic, and SkDCubic, which do work.
Kevin's BuildStats bot says this saves around 180K on the
release build. Running pathops_unittest shows no significant
performance difference, and the smaller version may be
slightly faster.
Bug: skia:
Change-Id: I17f94fd57a317035bc105cd43a06be6da9541cb6
Reviewed-on: https://skia-review.googlesource.com/c/161146
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
Dump as hex instead of SVG to more accurately
capture pathops tests.
Use SkBits2Float to reconstruct SkScalar data.
Exclude tests with conics since, for the moment,
pathkit maps conics to quads.
R=kjlubick@google.com
Bug: skia:
Change-Id: Iba2836bde8f737f42c8da31cc26e83ce55de924a
Reviewed-on: https://skia-review.googlesource.com/146165
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Cary Clark <caryclark@skia.org>
pathops_unittest -J dump.json
now generates both Op() and Simplify() tests and results.
Also, make json names unique. While this may not be necessary,
duplicate names may make debugging failing tests more difficult.
R=kjlubick@google.com
Bug: skia:
Change-Id: I2eed5a8141764a0ad993fb9a09c23b7d90d65048
Reviewed-on: https://skia-review.googlesource.com/146100
Commit-Queue: Cary Clark <caryclark@skia.org>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
./out/skia/pathops_unittest -J dump.json
will write all Op tests to a JSON file. Since this
will run single threaded, this can take a while,
and generates a 500M file.
A reasonable subset is
./out/skia/pathops_unittest -J dump.json -m PathOpsOp$
around 275K.
This is in service of pathkit.
R=kjlubick@google.com
Bug: skia:
Change-Id: I7e0771639e29755c00036f335a531403044d9d30
Reviewed-on: https://skia-review.googlesource.com/145737
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
If an edge is unsortable, its winding value is untrustworthy;
it cannot be added to the output on that alone. If one end
adjoins a trusted edge, and that edge is added to the output,
the untrusted edge can be added as well.
Also add in msvs debugging for angles.
With this change, all extended tests pass.
TBR=reed@google.com
Bug: skia:8125
Change-Id: I049c6efa2fa83edd7b49cdd598ec94c356481b0f
Reviewed-on: https://skia-review.googlesource.com/140562
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
En route to fixing fuzzer bugs, I discovered that most
debugging in pathops was broken. Pathops has extensive
runtime functions that trace links and connections between
data structures that are invaluable to debugging. The
only practical way to use these functions is to call them
from the debugger in immediate mode.
Some time, some where, the MSVS Immediate Window ceased
to be able to call functions that are members of structs
or classes, and functions that take templated parameters.
I can find no mention of this on the web, so I assume
that something about our setup is triggering this, but
I've had no luck finding the culprit.
In the meantime, I've added global functions wrapped in
a namespace to sneak calls to these functions without
MSVS being any the wiser. While this works, it is likely
to bitrot by tomorrow or next Tuesday so I will continue
to try to find and fix the root cause.
This also fixes the fuzzer bugs; generally one-line edits
that change asserts to fails. All pathops tests succeed
with this. To run all tests, do:
./out/debug/pathops_unittest -V -x
./out/release/pathops_unittest -V -x
TBR=caryclark@google.com
Bug: skia:
Change-Id: I956ae3d8df6d25e155e62bd6dede64519c7fbdb1
Reviewed-on: https://skia-review.googlesource.com/114321
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
Newer clang compiler produces the diagnostic
../../tests/PathOpsDebug.cpp:1349:44:
error: comparison of unsigned enum expression >= 0 is always true
[-Werror,-Wtautological-unsigned-enum-zero-compare]
if (!firstOp && c->operand() && op >= 0) {
The check seems to be defending against bad values of SkPathOp, but
this now seems unnecessary. This also adds 'rdiff' to kPathOpStr for
future debugging.
Change-Id: I08e5ba77c56e519ce4d9ae89491f7ccd5eb7f944
Reviewed-on: https://skia-review.googlesource.com/57104
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
The path writer takes constructs the output path out of
curves that satisfy the pathop operation.
Curves contain lists of t/point pairs that may not be
comparable to each other. To match up curve ends in the
output path, look for adjacent curves to have a shared
membership rather than comparing point values.
Use path utilities to connect partial curve lists into
closed contours.
Share the angle code that determines if a curve has become
a degenerate line with the path writer.
Clean up some code on the way, and delete some unused
functions.
TBR=reed@google.com
BUG=5188
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2321973005
Review-Url: https://codereview.chromium.org/2321973005
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
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
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
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
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
Mike K: please sanity check Test.cpp and skia_test.cpp
Feel free to look at the rest, but I don't expect any in depth review of path ops innards.
Path Ops first iteration used QuickSort to order segments radiating from an intersection to compute the winding rule.
This revision uses a circular sort instead. Breaking out the circular sort into its own long-lived structure (SkOpAngle) allows doing less work and provides a home for caching additional sorting data.
The circle sort is more stable than the former sort, has a robust ordering and fewer exceptions. It finds unsortable ordering less often. It is less reliant on the initial curve tangent, using convex hulls instead whenever it can.
Additional debug validation makes sure that the computed structures are self-consistent. A new visualization tool helps verify that the angle ordering is correct.
The 70+M tests pass with this change on Windows, Mac, Linux 32 and Linux 64 in debug and release.
R=mtklein@google.com, reed@google.com
Author: caryclark@google.com
Review URL: https://codereview.chromium.org/131103009
git-svn-id: http://skia.googlecode.com/svn/trunk@14183 2bbb7eff-a529-9590-31e7-b0007b416f81