aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTessellator.cpp
Commit message (Collapse)AuthorAge
* GrTessellator: fix for collinear edge merging.Gravatar Stephen White2018-07-26
| | | | | | | | | | | | | | | | In some cases, two edges can be collinear when tested on one side (e.g., left top vs right edge), but non-collinear when tested on the other (e.g., right top vs left edge). We were actually merging based on one criterion, but assserting based on the other. The safest fix is to merge if either condition is true, and then assert that both conditions are false. Bug: 866319 Change-Id: Ia1be330caf62f6d7961746752f73993ca098d0a3 Reviewed-on: https://skia-review.googlesource.com/143501 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix overlap outer boundary winding.Gravatar Stephen White2018-07-18
| | | | | | | | | | | | | | | | When two outer boundary edges are collinear, they are part of an overlap region. As of 77169c8fd6d, we (correctly) leave these edges connected, but we must also adjust the winding to magnitude 1 to keep the winding rules correct. Note: this adds a new test case to the concavepaths GM, affecting all platforms. Bug: 863389 Change-Id: I7e3a06df537cd189101e7ad39a4815a78be8fbdd Reviewed-on: https://skia-review.googlesource.com/141952 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: collinear edges during sanitize.Gravatar Stephen White2018-07-16
| | | | | | | | | | | | When three collinear edges occur during the sanitize_contours() pass, their vertices may not yet have been discovered to be coincident. So we must do the vertex comparison by point, rather than by pointer. Bug: 860655 Change-Id: I89dc7526905bb5473206661348fee431371731a0 Reviewed-on: https://skia-review.googlesource.com/141523 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: missing intersection rewind fix.Gravatar Stephen White2018-07-13
| | | | | | | | | | | | | | | Some "missing" intersections (see https://skia.googlesource.com/skia/+/89042d5f13a56d6b663657aa58f17593123a344e) cause the active edge list to go out of order. In that case, we need to rewind the active list, just as we do before edge splitting for regular intersections. BUG=860453 Change-Id: I1f7b32157a73b427a4fd94c14c1eb440f26c0743 Reviewed-on: https://skia-review.googlesource.com/141038 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: handle three consecutive collinear edges.Gravatar Stephen White2018-07-02
| | | | | | | | | | | | | | | In some cases, splitting may produce three consecutive edges which are collinear. The first one was being merged out, causing the third one to be missed. The fix is to switch the arguments to merge_edges_*, ensuring that the second parameter (the destination edge) is never merged out. Bug: 851409 Change-Id: I65be2e8222846c99f7bc8d17ea61ddead617cc31 Reviewed-on: https://skia-review.googlesource.com/138700 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* Revert "GrTessellator: handle three consecutive collinear edges."Gravatar Mike Klein2018-06-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 26bb0e66f28c41cb1e8e39f00d848997fd33d97c. Reason for revert: segfaulty Here's a log with a stacktrace: https://chromium-swarm.appspot.com/task?id=3e658f7aa40dbb10&refresh=10 Original change's description: > GrTessellator: handle three consecutive collinear edges. > > In some cases, splitting may produce three consecutive edges which > are collinear. The first one was being merged out, causing the third > one to be missed. > > The fix is to switch the arguments to merge_edges_*, ensuring that the > second parameter (the destination edge) is never merged out. > > Bug: 851409. > Change-Id: I70fbbc506e97a26b259c1443b6d1787adec0f9b0 > Reviewed-on: https://skia-review.googlesource.com/138561 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Stephen White <senorblanco@chromium.org> TBR=robertphillips@google.com,senorblanco@chromium.org Change-Id: I6ecfb4c487d6f96e9fae7b8b40d74162354ed57c No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 851409. Reviewed-on: https://skia-review.googlesource.com/138640 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
* GrTessellator: handle three consecutive collinear edges.Gravatar Stephen White2018-06-29
| | | | | | | | | | | | | | | In some cases, splitting may produce three consecutive edges which are collinear. The first one was being merged out, causing the third one to be missed. The fix is to switch the arguments to merge_edges_*, ensuring that the second parameter (the destination edge) is never merged out. Bug: 851409. Change-Id: I70fbbc506e97a26b259c1443b6d1787adec0f9b0 Reviewed-on: https://skia-review.googlesource.com/138561 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: handle collinear final vertex.Gravatar Stephen White2018-06-28
| | | | | | | | | | | | If the last vertex in a contour is collinear with its neighbours, remove it (this edge case was missing). Otherwise, the simplify step may try to split it indefinitely. Bug: 851409 Change-Id: I7efa4e616cdc1508a73c7a9f3de9d3f571569af8 Reviewed-on: https://skia-review.googlesource.com/138106 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: avoid split with zero primary and out-of-range secondary.Gravatar Stephen White2018-06-22
| | | | | | | | | | | | | | Sometimes the intersector will return an intersection which is on the same primary sort criterion (eg., Y coordinate), but out-of-range on the secondary. We shouldn't do splits in this case. The only case we really care about is if it's less than one epsilon and greater than zero, and thus numerically unsplittable. Bug: 851914 Change-Id: Ia772763b6a66a14ca159cf409a832835244e83bc Reviewed-on: https://skia-review.googlesource.com/136803 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* Stop using SkTSwap.Gravatar Ben Wagner2018-06-19
| | | | | | | | | | | | | Use std::swap instead. It does not appear that any external user specializes SkTSwap, but some may still use it. This removes all use in Skia so that SkTSwap can later be removed in a smaller CL. After that the <utility> include can be removed from SkTypes.h. Change-Id: If03d4ee07dbecda961aa9f0dc34d171ef5168753 Reviewed-on: https://skia-review.googlesource.com/135578 Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
* GrTessellator: rename intersection check args.Gravatar Stephen White2018-06-14
| | | | | | | | | | | Now that there's a required ordering of the arguments to check_for_intersection(), rename the parameters to match. Cosmetic change only. Change-Id: I68f6ae0b6e5f89a3344048cf73fedabded9ed138 Reviewed-on: https://skia-review.googlesource.com/134823 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: catch missing intersections.Gravatar Stephen White2018-06-08
| | | | | | | | | | | | | | | Sometimes the intersection check will miss an intersection (because floating point). This can leave the active edge list in an invalid state, where an edge pair is incorrectly ordered. The fix is to test for edge crossings after testing for intersections, and split the edges manually. This extra check may result in a performance hit, so we'll have to watch the perf bots carefully. Bug: 843135 Change-Id: If50320413026be503cdb2d33e6c97f620e4d51a9 Reviewed-on: https://skia-review.googlesource.com/133400 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* Add checks to make sure we don't overflow 32 bit int in GPU path renderers.Gravatar Greg Daniel2018-06-07
| | | | | | | | Bug: chromium:848716 Change-Id: I5b8fe036c666a1f379c4125115b2cec0295711b3 Reviewed-on: https://skia-review.googlesource.com/132268 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
* GrTessellator: yet another out-of-range splitting fix.Gravatar Stephen White2018-06-06
| | | | | | | | | | | | It's actually possible for an intersection to be out-of-range on both the intersected edges (e.g., below both bottom points), because floating point. So we need to clamp against both edges. Bug: 846014 Change-Id: I9fe25a1fcd3b5242af7b1ee36b17f1e968aeb836 Reviewed-on: https://skia-review.googlesource.com/132323 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for overlapping outer boundary edges in AA case.Gravatar Stephen White2018-06-05
| | | | | | | | | | | | | When inflating outer path boundaries for edge AA, two outer boundary edges may be collinear. In this case, they form part of the overlap region, but they must not be removed on collapse, since they form part of the outer boundary of the shape. Bug: 846655 Change-Id: I4808b570cc4f82d6202862f7a8ecf0f8add771ef Reviewed-on: https://skia-review.googlesource.com/132084 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix winding merged to zero on split edge.Gravatar Stephen White2018-06-01
| | | | | | | | | | | | | | | | Occasionally, the top edge of a split edge can be merged out of existence (if it can't be mathematically distinguished from one of its adjacent edges). In this case, we need to save its winding count before it's merged so that the other half of the split doesn't also get zero winding. NOTE: this adds a new test case to the concavepaths GM. Bug: skia:7785 Change-Id: Iff8b0a2ed3065e57b737ff915ff436146987caf6 Reviewed-on: https://skia-review.googlesource.com/131223 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for ping-pong split fuzzer hang.Gravatar Stephen White2018-05-31
| | | | | | | | | | | | | | | | | | When support for out-of-range intersections was added in 3b5a3fa8b1c11d4bd4499b040311f4c3553ebf8c, it was intended to support splitting edges that are almost flat, where merging with the top or bottom vertex would cause visual artifacts. However, it triggers too often for other, non-nearly-flat cases, causing simplify() to loop infinitely. The fix is to support out-of-range intersections only if they differ by 1/2 machine epsilon. This also generalizes the out_of_range_and_collinear() check, so it was removed. Bug: 838978 Change-Id: I238f2b90e4b7ad647ecf072427ee38726e549581 Reviewed-on: https://skia-review.googlesource.com/130458 Reviewed-by: Stephen White <senorblanco@chromium.org>
* Revert "GrTessellator: fix for ping-pong split fuzzer hang."Gravatar Ravi Mistry2018-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit bfb2a05af105f452a0f369e39dae05f9224dfa19. Reason for revert: Seems to cause failures in chromeos and chromecast test bots. eg: https://chromium-swarm.appspot.com/task?id=3dc5be8269e3b410&refresh=10 https://chromium-swarm.appspot.com/task?id=3dc5d62dfdc99010&refresh=10 Original change's description: > GrTessellator: fix for ping-pong split fuzzer hang. > > Change 3b5a3fa8b1c11d4bd4499b040311f4c3553ebf8c introduced support for > splitting on out-of-range intersections. However, this is only necessary > for correctness when the edge is nearly-flat (the top and bottom > points only differ by 1/2 machine epsilon in the primary sort criterion). > In other cases, it can cause repeated splitting and re-merging of edges, > as the intersection code (being approximate and not exact) may produce a > ping-pong set of intersections. > > The fix is to support out-of-range intersections only if they differ by > 1/2 machine epsilon. This also generalizes the > out_of_range_and_collinear() check, so it was removed. > > Bug: 838978 > Change-Id: I134f7eff3f15707e0d68de11c55f7fadce4ff8e7 > Reviewed-on: https://skia-review.googlesource.com/130448 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Stephen White <senorblanco@chromium.org> TBR=robertphillips@google.com,senorblanco@chromium.org Change-Id: I3fa62423d3875665397adcecb94b467b9b6611cc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 838978 Reviewed-on: https://skia-review.googlesource.com/130522 Reviewed-by: Ravi Mistry <rmistry@google.com> Commit-Queue: Ravi Mistry <rmistry@google.com>
* GrTessellator: fix for ping-pong split fuzzer hang.Gravatar Stephen White2018-05-29
| | | | | | | | | | | | | | | | | | | | Change 3b5a3fa8b1c11d4bd4499b040311f4c3553ebf8c introduced support for splitting on out-of-range intersections. However, this is only necessary for correctness when the edge is nearly-flat (the top and bottom points only differ by 1/2 machine epsilon in the primary sort criterion). In other cases, it can cause repeated splitting and re-merging of edges, as the intersection code (being approximate and not exact) may produce a ping-pong set of intersections. The fix is to support out-of-range intersections only if they differ by 1/2 machine epsilon. This also generalizes the out_of_range_and_collinear() check, so it was removed. Bug: 838978 Change-Id: I134f7eff3f15707e0d68de11c55f7fadce4ff8e7 Reviewed-on: https://skia-review.googlesource.com/130448 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: remove collinear vertices.Gravatar Stephen White2018-05-25
| | | | | | | | | | | During sanitize_contours(), remove any points which are collinear with their previous and next points. Bug: skia:8503 Change-Id: Iba1df73b15a92047302bc26f01cb79f4de118760 Reviewed-on: https://skia-review.googlesource.com/130206 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix crash on merging a dead edge.Gravatar Stephen White2018-05-22
| | | | | | | | | | | | | | | | | | When merging coincident vertices, sometimes merging an edge will cause the next edge in the list to die. But since merge_vertices() retrieves the next edge before merging the current one, we then try to merge its lifeless corpse, bringing it back as a zombie. The fix is to leave dead edges, dead. This was revealed by ec79c39a770205910f0abd762de7e19a96c986ca, but was likely a real bug that was being mishandled before that. Bug: 844873 Bug: skia:7982 Change-Id: I752c45f7551df4278fa4cb4587e7ead48cd16a21 Reviewed-on: https://skia-review.googlesource.com/129524 Commit-Queue: Stephen White <senorblanco@chromium.org> Reviewed-by: Robert Phillips <robertphillips@google.com>
* GrTessellator: remove 64K vertex limit.Gravatar Stephen White2018-05-22
| | | | | | | | | | | | | This is some code I cargo-culted in from an another path renderer and is not necessary since we don't used indexed geometry. I tested locally up to 64M points in a path, and it seems fine (up to my patience). Bug: skia:7952 Change-Id: Id7745cd1ffe905bdd8a7a505174ba083f8ea91ee Reviewed-on: https://skia-review.googlesource.com/129246 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for zombie edge fuzzer crash.Gravatar Stephen White2018-05-18
| | | | | | | | | | | | | | | | While splitting one edge, merge_collinear_edges() may in rare cases merge the other edge of the intersection out of existence. split_edge() then brings these dead edges partially back to life, leaving the mesh in an inconsistent state. The fix is to null out the top and bottom pointers of dead edges to mark them as dead, and only split living edges. Bug: skia:7911 Change-Id: I1c0b59581acfcd0b8191f2d129b33f7d0d1a2516 Reviewed-on: https://skia-review.googlesource.com/129181 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* Remove GR_TESSELLATOR_LEGACY_INVERSION_HANDLING (unused).Gravatar Stephen White2018-05-04
| | | | | | | | | | No user-visible change. Bug: skia: Change-Id: Ib665e79c96f8fbbc4891595a95359ab085039950 Reviewed-on: https://skia-review.googlesource.com/126200 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for points that become infinite on stroking.Gravatar Stephen White2018-04-03
| | | | | | | | | | | stroke -> Inf -> NaN -> assert. BUG=skia:7775 Change-Id: I086883bce90d1d473cff87f67e954718ea3181f6 Reviewed-on: https://skia-review.googlesource.com/118145 Commit-Queue: Stephen White <senorblanco@chromium.org> Reviewed-by: Robert Phillips <robertphillips@google.com>
* Reland "GrTessellator: hang fix."Gravatar Stephen White2018-03-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a reland of 050c86768a2c24c62655f53ef9b685d40477eccb Original change's description: > GrTessellator: hang fix. > > Some edges are not coincident with their own endpoints (because floating > point). If this happens for an edge which is a right-enclosing-edge > during the Bentley-Ottman simplify() pass, we end up an infinite loop > attempting to split the edge, since the edge is never to the right of its > endpoint. > > The easiest fix is to simply remove the right-enclosing-edge splitting > code. This code was originally added before we had proper > active-edge-list rewinding, and should no longer be necessary. > > BUG=802896 > > Change-Id: Id9f2942b73f01152af8c0088e8c6b1389891d827 > Reviewed-on: https://skia-review.googlesource.com/116920 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Stephen White <senorblanco@chromium.org> Bug: 802896 Change-Id: I3e48346a8a358ae7d481299a586003e817a519ca Reviewed-on: https://skia-review.googlesource.com/117121 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Revert "GrTessellator: hang fix."Gravatar Mike Klein2018-03-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 050c86768a2c24c62655f53ef9b685d40477eccb. Reason for revert: layout test diff in Chrome roll? Original change's description: > GrTessellator: hang fix. > > Some edges are not coincident with their own endpoints (because floating > point). If this happens for an edge which is a right-enclosing-edge > during the Bentley-Ottman simplify() pass, we end up an infinite loop > attempting to split the edge, since the edge is never to the right of its > endpoint. > > The easiest fix is to simply remove the right-enclosing-edge splitting > code. This code was originally added before we had proper > active-edge-list rewinding, and should no longer be necessary. > > BUG=802896 > > Change-Id: Id9f2942b73f01152af8c0088e8c6b1389891d827 > Reviewed-on: https://skia-review.googlesource.com/116920 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Stephen White <senorblanco@chromium.org> TBR=robertphillips@google.com,senorblanco@chromium.org Change-Id: Icb928db6c052a21c6d327da9492cb991f769186f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 802896 Reviewed-on: https://skia-review.googlesource.com/117120 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* GrTessellator: hang fix.Gravatar Stephen White2018-03-28
| | | | | | | | | | | | | | | | | | | Some edges are not coincident with their own endpoints (because floating point). If this happens for an edge which is a right-enclosing-edge during the Bentley-Ottman simplify() pass, we end up an infinite loop attempting to split the edge, since the edge is never to the right of its endpoint. The easiest fix is to simply remove the right-enclosing-edge splitting code. This code was originally added before we had proper active-edge-list rewinding, and should no longer be necessary. BUG=802896 Change-Id: Id9f2942b73f01152af8c0088e8c6b1389891d827 Reviewed-on: https://skia-review.googlesource.com/116920 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* ccpr: Tessellate fans for very large and/or simple pathsGravatar Chris Dalton2018-02-14
| | | | | | | | | | | | This increases CPU work, but reduces overdraw on the GPU as compared to Redbook fanning. TBR=bsalomon@google.com Change-Id: I396b887075d4422531908c2361ee1e26f076d5c3 Reviewed-on: https://skia-review.googlesource.com/107141 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
* Revert "ccpr: Tessellate fans for very large and/or simple paths"Gravatar Cary Clark2018-02-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 4138c972effe4eb0227fbb96571df290f3d1979b. Reason for revert: broke android flutter build Original change's description: > ccpr: Tessellate fans for very large and/or simple paths > > This increases CPU work, but reduces overdraw on the GPU as compared to > Redbook fanning. > > Bug: skia: > Change-Id: I47239c964261e0014a94266a71223eab0597bfb8 > Reviewed-on: https://skia-review.googlesource.com/105203 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Chris Dalton <csmartdalton@google.com> TBR=bsalomon@google.com,csmartdalton@google.com Change-Id: I98b5c10b97c3fa603de5122d9bb47ca07659242c No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/106620 Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org>
* ccpr: Tessellate fans for very large and/or simple pathsGravatar Chris Dalton2018-02-12
| | | | | | | | | | | This increases CPU work, but reduces overdraw on the GPU as compared to Redbook fanning. Bug: skia: Change-Id: I47239c964261e0014a94266a71223eab0597bfb8 Reviewed-on: https://skia-review.googlesource.com/105203 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
* GrTessellator: eliminate some redundant computation.Gravatar Stephen White2018-01-12
| | | | | | | | | No need to recompute the bisector when mitering. Change-Id: If7b99244d530d4b2241b7b45611f9401b2f02d69 Reviewed-on: https://skia-review.googlesource.com/93673 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: set a cap on quadratic linearization.Gravatar Stephen White2018-01-09
| | | | | | | | | | | | | | | Some pathological cases don't converge to a reasonable number of points when using uniform linearization of quadratic points. Cap them to the maximum which GrPathUtils supports. Add reduced test case from crbug-762369. BUG=762369 Change-Id: Icc744018e5c01a0e0fe2ec00613bdb25e49614e9 Reviewed-on: https://skia-review.googlesource.com/92721 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for assert on bevelling.Gravatar Stephen White2018-01-05
| | | | | | | | | | | | With some large values, intersection for bevelling will fail. These should just skip the point, not assert. BUG=798912 Change-Id: Ie5c8cc3c9387055e1e31480321a231f0e6ff153b Reviewed-on: https://skia-review.googlesource.com/91141 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for points which become non-finite on AA stroking.Gravatar Stephen White2018-01-04
| | | | | | | | | | | | | If input points are near-infinite, they may become inf or NaN when stroked. Before converting the results of intersection from double to float, clamp them to the [-FLT_MAX/FLT_MAX] range. BUG=798679 Change-Id: I7d61130dd26147a9b7cfd38aa96567e3867b5c3e Reviewed-on: https://skia-review.googlesource.com/90983 Commit-Queue: Stephen White <senorblanco@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
* GrTessellator: implement straight skeleton, phase 2.Gravatar Stephen White2017-12-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL implements two major changes to the AA tessellating path renderer: 1) Fix inverted edges after stroke and simplify. Instead of detecting and fixing edges which invert on stroking during the stroking pass, we run the full simplify pass on both inner and outer contours, then create edge collapse events for the overlap regions. We then process the edge events in a priority queue and process them in order of decreasing alpha (this is the "edge event" part of the straight skeleton algorithm). By doing it after simplification, we ensure that there's a full-alpha intersection vertex to join the collapse edge to (which may have <1 alpha), so no spurious gradients appear in the rendered path. 2) "Pointy" vertices (defined as those which meet at an acute angle less than 14 degrees) are now properly bevelled off during stroking. This removes antialiasing artifacts which extend beyond the path boundary. Some ancillary changes: The extracted boundaries which are input to stroking have their line equations pre-normalized, and multiplied by winding. This simplifies a lot of code which was performing this computation on the fly. The workaround for the "intruding vertex" problem was removed, since the straight skeleton now moves the intruding vertex before it can cause problems. Bug: 756823 Change-Id: I271ed32be6847da55273b387e8c04bbf9b512b70 Reviewed-on: https://skia-review.googlesource.com/87341 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: refactor, cleanup, add logging.Gravatar Stephen White2017-12-18
| | | | | | | | | | No user-visible effect. Bug: skia: Change-Id: Ibdc31027f51e5fff6b1a22de8de9441d7bd80b90 Reviewed-on: https://skia-review.googlesource.com/86561 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* move parts of SkPoint to SkPointPrivGravatar Cary Clark2017-11-08
| | | | | | | | | | | | Move specialized SkPoint methods to SkPointPriv. Use constexpr and inline initialization where possible. R=reed@google.com,bsalomon@google.com Bug: skia: 6898 Change-Id: I01ec5186f010f2dc80c068c70d9cc352f3221338 Reviewed-on: https://skia-review.googlesource.com/68700 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Ravi Mistry <rmistry@google.com>
* GrTessellator: when sanitizing contours, remove non-finite points.Gravatar Stephen White2017-08-23
| | | | | | | | | | | | NaNs can't be correctly sorted. Don't run the unit test on VK backend, since it requires large (>64K bytes) vertex buffer uploads. Bug: 757650 Change-Id: I667693f135a090a5d9076bb7a2ec6879fc06d645 Reviewed-on: https://skia-review.googlesource.com/37484 Commit-Queue: Stephen White <senorblanco@chromium.org> Reviewed-by: Greg Daniel <egdaniel@google.com>
* Fix artifacts on tiny stroked paths scaled up a lot.Gravatar Stephen White2017-08-23
| | | | | | | | | | | | | | | Set doConsumeDegenerates to false when calling SkPath::Iter::next() for all paths which are not in screen space. These lines are not degenerate for world space paths. Note: this change fixes only GrTessellatingPathRenderer and GrDefaultPathRenderer. GrMSAAPathRenderer still exhibits the bug. Bug: skia:6987 Change-Id: Ie3d494703211925c77052c68513948484e341486 Reviewed-on: https://skia-review.googlesource.com/37522 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* Revert "GrTessellator: when sanitizing contours, remove non-finite points."Gravatar Robert Phillips2017-08-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 620cc248517a509040d3f94f29710edf3a151c5b. Reason for revert: Breaking the Vulkan bots Original change's description: > GrTessellator: when sanitizing contours, remove non-finite points. > > NaNs can't be correctly sorted. > > Bug: 757650 > Change-Id: Id1ca2fe1d1de7884da2a64ceef9491b1da7e8e77 > Reviewed-on: https://skia-review.googlesource.com/37220 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Stephen White <senorblanco@chromium.org> TBR=bsalomon@google.com,senorblanco@chromium.org Change-Id: I64d5c35801f844b31745a9c7ff60812d96af5e55 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 757650 Reviewed-on: https://skia-review.googlesource.com/37540 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* Revert "Fix artifacts on tiny stroked paths scaled up a lot."Gravatar Robert Phillips2017-08-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 267641a90cb18a430b0a84910f651e2181744fd3. Reason for revert: Seems to be turning the bots red Original change's description: > Fix artifacts on tiny stroked paths scaled up a lot. > > Set doConsumeDegenerates to false when calling SkPath::Iter::next() for > all paths which are not in screen space. These lines are not degenerate > for world space paths. > > Bug: skia:6987 > Change-Id: I411faf594bf8a15891bfff08691e86679b7741ac > Reviewed-on: https://skia-review.googlesource.com/36881 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Stephen White <senorblanco@chromium.org> TBR=bsalomon@google.com,senorblanco@chromium.org Change-Id: I0d5a14670126ab3e0d99083a500ec8d3d0ef9961 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:6987 Reviewed-on: https://skia-review.googlesource.com/37440 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* Fix artifacts on tiny stroked paths scaled up a lot.Gravatar Stephen White2017-08-22
| | | | | | | | | | | | Set doConsumeDegenerates to false when calling SkPath::Iter::next() for all paths which are not in screen space. These lines are not degenerate for world space paths. Bug: skia:6987 Change-Id: I411faf594bf8a15891bfff08691e86679b7741ac Reviewed-on: https://skia-review.googlesource.com/36881 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: when sanitizing contours, remove non-finite points.Gravatar Stephen White2017-08-22
| | | | | | | | | | NaNs can't be correctly sorted. Bug: 757650 Change-Id: Id1ca2fe1d1de7884da2a64ceef9491b1da7e8e77 Reviewed-on: https://skia-review.googlesource.com/37220 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for collinear out-of-range intersections.Gravatar Stephen White2017-08-16
| | | | | | | | | | | | | | | | | | | | | | | | Change 3b5a3fa8b1c11d4bd4499b040311f4c3553ebf8c introduced support for out-of-range intersections, which is necessary when the top and bottom vertices of an edge differ by only one ULP in the primary sort order and can't be split in-order. However, some out-of-range intersections produce edges which cancel each other out on splitting, in particular when the intersection is collinear with the newly-computed edge. This undoes the effect of the split. The tessellator then rewinds, re-detects the intersection, resplits, an infinite loop. The fix is to check for out-of-range intersections which are also collinear, and ignore them. This is ok, because these are not the cases we care about it change 3b5a3f above, which are never collinear. Bug: 753867 Change-Id: I590231e0e6f19c98f1ccf46cb7acc8a63ba35a9d Reviewed-on: https://skia-review.googlesource.com/34925 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix two NaN issues.Gravatar Stephen White2017-06-12
| | | | | | | | | | | | | | | If a point in the path rounds to +inf/-inf, the intersection code can produce NaN, which is unsortable. Fix: ignore non-finite intersections. Quadratic interpolation can sometimes produce NaN, which will never satisfy the flatness criterion. Abort if any of the interpolated points are non-finite. Bug:732023 Change-Id: If5881796e589c75b8f74459f42d00918619713a2 Reviewed-on: https://skia-review.googlesource.com/19467 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix logging; fix test comment.Gravatar Stephen White2017-06-09
| | | | | | | Change-Id: Iaded9025a1518d8c69dbe366deb1035e0bd4295b Reviewed-on: https://skia-review.googlesource.com/19289 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix intersection above the first vertex.Gravatar Stephen White2017-06-08
| | | | | | | | | | | | | | | | | | | | Handle the case where the an intersection falls not only above both edge endpoints, but above the first vertex in the mesh. This requires passing the mesh into check_for_intersection(), in order to modify the head. We also need to rewind the mesh after insertion, since we need to rewind to the newly-inserted vertex. This also cleans up vertex ID computation a little (for logging), so that vertices before the first vertex or after the last have a reasonable ID. It also cleans up the intersection-on-endpoint special cases by refactoring the calls to split_edge(). BUG=730687 Change-Id: Idea736eca7b7c3c5d8a470b1373a16ad8e649e80 Reviewed-on: https://skia-review.googlesource.com/19069 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: implement out-of-range splitting and AEL rewinding.Gravatar Stephen White2017-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to floating point inaccuracy, when intersecting edges, the intersection point may fall above one of the edges' top vertices or below one of the bottom vertices. In these cases, we were simply splitting one edge on the relevant endpoint of the other edge. This is incorrect if the intersection is far from the endpoint (e.g., the test case in the linked bug, where one of the intersected edges is near-horizontal but the intersection falls below both of its endpoints, in the middle of the edge.) The correct solution is to split both edges as normal, and take care to produce edges with the correct ordering where the intersection is above or below an edge. However, since the new vertex may be above the current vertex, simply restarting intersection checks at the current vertex won't work. We need to process the intersection vertex before the current one. This introduces another problem: unlike all other splitting modes (which always shorten edges), splitting an edge above the top or below the bottom can lengthen it, causing it to violate the AEL with an adjacent edge which then shortens it back to the original point (in cleanup_active_edges()). Since the splitting and merging code can't agree, we loop forever. Instead of simply fusing neighboring edges in cleanup_active_edges(), the proper fix to this problem is to detect the AEL violation and rewind all processing to the vertex above it. For performance, we only rewind when we detect that a split edge is no longer ordered within the mesh (merge_enclosing_edges()) or within the the AEL (rewind_if_necessary()). We also store the enclosing edges of each vertex, which allows us to rewind quickly, since we know exactly which edges need to be added/removed from the AEL. cleanup_active_edges(), fix_active_state() and Vertex::fProcessed have been removed. In their place are rewind_active_edges() and rewind_if_necessary(), which uses the same logic as cleanup_active_edges() but uses it to know when to rewind. Bug: skia:5026 Change-Id: I3638a429f5428498d6df6bb7b98c67374dc291aa Reviewed-on: https://skia-review.googlesource.com/18900 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
* GrTessellator: fix for three edges becoming collinear after splitting.Gravatar Stephen White2017-05-25
| | | | | | | | | | | | | In rare cases, a single edge can become collinear with two adjacent neighbour edges after it's split. The solution is to continue to merge until no collinear edges are found. BUG=722000 Change-Id: Ia5dd212b7acfb40ed1d6c74ebfa9e4a4746fe40a Reviewed-on: https://skia-review.googlesource.com/17963 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>