Commit Graph

336 Commits

Author SHA1 Message Date
Brian Salomon
71fe945da3 Prevent unbounded listener growth on SkPixelRefs.
Use SkIDChangeListener and update GrBitmapTextureMaker to add listener
to key to deregister if texture is purged before genID changes.

Add a common listener list implementation and replace existing lists.

Change-Id: Ib0c78241eaf59b59b892d8b004b2bb095140bc6d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274549
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-03-02 22:32:09 +00:00
Brian Salomon
99a813ca29 Avoid unbounded listener growth on SkImage_Lazy when textures are purged
Generalizes the system used on SkPathRef where a GrTexture's key
destructor signals that a listener on the image can be removed via
the unique key custom data.

Removes texturesAreCacheable() from SkImageGenerator. This was used to
prevent unbounded growth in a narrow situation related to
GrBackendTextureImageGenerator.


Change-Id: I3c605da099acfac94751e793331e356a0979d359
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274038
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-03-02 18:38:09 +00:00
Ian Prest
05676f7bc2 Reland: Ensure arcTo (SVG) ends at the targeted point
Floating-point errors in the calculations in arcTo can cause the final
point to differ significantly enough from the supplied target point that
a subsequent 'close' operation inserts a lineTo to close the curve. This
can result in bad miters on curves with thick outlines.

The fix is to ensure that the final point used is *exactly* the point
that was supplied.

The fix is now staged behind a flag so that we can fix Chromium test
failures before turning it on.

Bug: chromium:1001768
Change-Id: I82d872f2ae39b5486f7d810a61ba00eeda1b3a62
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270503
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-02-14 23:17:35 +00:00
Mike Reed
125d3820d6 Revert "Ensure arcTo (SVG) ends at the targeted point"
This reverts commit 31143100ee.

Reason for revert: need to guard this, to stage changes to test images

Original change's description:
> Ensure arcTo (SVG) ends at the targeted point
> 
> Floating-point errors in the calculations in arcTo can cause the final
> point to differ significantly enough from the supplied target point that
> a subsequent 'close' operation inserts a lineTo to close the curve. This
> can result in bad miters on curves with thick outlines.
> 
> The fix is to ensure that the final point used is *exactly* the point
> that was supplied.
> 
> Bug: chromium:1001768
> Change-Id: I75c740ab25fb05153bc852a204be957977674cd2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270000
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=reed@google.com,iapres@microsoft.com

Change-Id: If331924a4db83294769b28501bba875238a521bd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1001768
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270356
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-02-12 14:08:03 +00:00
Ian Prest
31143100ee Ensure arcTo (SVG) ends at the targeted point
Floating-point errors in the calculations in arcTo can cause the final
point to differ significantly enough from the supplied target point that
a subsequent 'close' operation inserts a lineTo to close the curve. This
can result in bad miters on curves with thick outlines.

The fix is to ensure that the final point used is *exactly* the point
that was supplied.

Bug: chromium:1001768
Change-Id: I75c740ab25fb05153bc852a204be957977674cd2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270000
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-02-11 22:13:08 +00:00
Brian Osman
116b33e8ab Remove SkMaxScalar and SkMinScalar
Use std::max and std::min instead

Change-Id: Icf3796609e5cb511687fb50bd31229ae4b6b9b39
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268841
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-06 15:43:22 +00:00
Mike Reed
cf0e3c63fd remove dead code around old SkPath enums
Change-Id: I8dc06da48e881d3a9c40b47c799afe27bdcce819
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257689
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-12-14 01:58:10 +00:00
Mike Reed
bb59dfa9e3 perform perspective clip by default
- this adds new (default) parameter to control clipping when transforming
  rects and paths

Bug: skia:9698
Change-Id: I4cfb36b60bd6bbfcdac0226e374dbc27d5284952
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259431
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-12-12 20:19:59 +00:00
Mike Reed
7d34dc7747 Revert "Revert "switch to new filltype for SkPath""
This reverts commit 3e7af41224.

Change-Id: Id4f66b3956f4bdbe690db20fc478b7365ee89717
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256676
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2019-11-26 17:43:14 +00:00
Mike Reed
3e7af41224 Revert "switch to new filltype for SkPath"
This reverts commit 3a50981a83.

Reason for revert: chrome win build found compile-problem in xpsdevice

Original change's description:
> switch to new filltype for SkPath
> 
> Change-Id: I7793324a9acf4afb0eb38c1e20fbb38eac25d636
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256102
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=fmalita@chromium.org,reed@google.com

Change-Id: Iacb3566da61c2512b9bd6b7e42b592febc85e031
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256530
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-11-26 03:34:30 +00:00
Mike Reed
3a50981a83 switch to new filltype for SkPath
Change-Id: I7793324a9acf4afb0eb38c1e20fbb38eac25d636
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256102
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2019-11-25 22:31:46 +00:00
Mike Reed
30bc527fd6 Revert "Reland "Revert "Use flat version of path-direction enum"""
This reverts commit 7cda6f3743.

Reason for revert: legacy convexity code removed -- google3 should be ok

Original change's description:
> Reland "Revert "Use flat version of path-direction enum""
>
> This reverts commit 1792b19485.
>
> Reason for revert: need to update legacy_convexity, still used by google3
>
> Original change's description:
> > Revert "Revert "Use flat version of path-direction enum""
> >
> > This reverts commit 0dacc6b7d3.
> >
> > Change-Id: Ie103e9f36b07e4ee256a3688a4decf3a6dd74314
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255832
> > Auto-Submit: Mike Reed <reed@google.com>
> > Reviewed-by: Mike Reed <reed@google.com>
> > Commit-Queue: Mike Reed <reed@google.com>
>
> TBR=reed@google.com
>
> Change-Id: I0ecea0eb8a237298c6b908cc4bfd1cacdfc5b900
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255976
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=reed@google.com

Change-Id: I3529139bb391c4f62ce5cd0744cdf38a13b71d78
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255984
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2019-11-22 19:09:54 +00:00
Mike Reed
8ee77d8f42 remove LEGACY_CONVEXITY code -- no more clients
Change-Id: Ifd33831b6a83a56685435ce8e4fbb218a147b34e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255981
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-11-22 18:31:44 +00:00
Mike Reed
7cda6f3743 Reland "Revert "Use flat version of path-direction enum""
This reverts commit 1792b19485.

Reason for revert: need to update legacy_convexity, still used by google3

Original change's description:
> Revert "Revert "Use flat version of path-direction enum""
> 
> This reverts commit 0dacc6b7d3.
> 
> Change-Id: Ie103e9f36b07e4ee256a3688a4decf3a6dd74314
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255832
> Auto-Submit: Mike Reed <reed@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=reed@google.com

Change-Id: I0ecea0eb8a237298c6b908cc4bfd1cacdfc5b900
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255976
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-11-22 11:03:34 +00:00
Mike Reed
1792b19485 Revert "Revert "Use flat version of path-direction enum""
This reverts commit 0dacc6b7d3.

Change-Id: Ie103e9f36b07e4ee256a3688a4decf3a6dd74314
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255832
Auto-Submit: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-11-22 00:51:22 +00:00
Mike Reed
0dacc6b7d3 Revert "Use flat version of path-direction enum"
This reverts commit e0fbe94351.

Reason for revert: need to add guard flag to flutter

Original change's description:
> Use flat version of path-direction enum
> 
> Bug: skia:9663
> Change-Id: I00077d9f2b14b3e983e6a46ef6f560cabdb1678d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242557
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>

TBR=fmalita@chromium.org,reed@google.com

Change-Id: If47173d9b203b2d3a175af290a15d986accb4703
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9663
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255831
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-11-21 22:10:32 +00:00
Mike Reed
e0fbe94351 Use flat version of path-direction enum
Bug: skia:9663
Change-Id: I00077d9f2b14b3e983e6a46ef6f560cabdb1678d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242557
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-11-21 21:45:20 +00:00
Mike Reed
4241f5e0a8 Revert "add guard to switch to SkPathTypes"
This reverts commit e1af44498b.

Reason for revert: breaking google3?

Original change's description:
> add guard to switch to SkPathTypes
> 
> Change-Id: I44d8b5ae8a5172d11a6d4cd9d994373dd3816d6f
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241278
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=robertphillips@google.com,kjlubick@google.com,fmalita@chromium.org,reed@google.com

Change-Id: If1fffb6310921ee6f213af000da793afcf62ab0b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241560
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-09-14 19:13:44 +00:00
Mike Reed
e1af44498b add guard to switch to SkPathTypes
Change-Id: I44d8b5ae8a5172d11a6d4cd9d994373dd3816d6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241278
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2019-09-14 01:26:38 +00:00
Mike Reed
430470d519 make rectcontour and nestedrects private
Change-Id: I37b81f3cd96acc310ce78244d427eeb9c7999061
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/241078
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2019-09-13 00:17:49 +00:00
Mike Reed
8fda88ed6d reverse/restore order of verbs in path to be forward (normal)
As part of this (clean up), also removed support for serialized-paths
older than version-4, which was introduced Feb 2018.

Change-Id: I2dc74a52bb8bdd7ea0cb2d8a78b644ca783eb31f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239102
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-09-05 21:14:08 +00:00
Mike Reed
92b33354dd more rect api simplifications
set --> setLTRB
set(pts, count) --> setBounds

Bug: skia:9328
Change-Id: I807c0598a8b23b2f721db118ec41c1607114205a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237038
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2019-08-25 10:12:57 +00:00
Brian Osman
4be31e2605 Conservatively consider any path with tiny edges to be concave
These are numerically unstable. We've had various complex solutions in
the past (fall back to doubles, additional checks like this one), but
this solution is safer and simpler.

Change-Id: Ibe57a155a2aa604e20960f415b9dc3546ae859a9
Bug: chromium:993330
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235861
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-08-21 14:47:37 +00:00
Mike Reed
5f152f0745 add path-edger; lightweight Iter for edges
4.07  	pathiter_edge	nonrendering
      6.74  	pathiter_raw	nonrendering
      9.16  	pathiter_iter	nonrendering

Change-Id: Id711b342fbac6b4efd62ce918cf440b04973545c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235476
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-08-19 21:58:37 +00:00
Mike Reed
ba7e9a6365 never check for degenerates in path::iter
This does not appear to be used externally, and only internally in 3
sites in GPU, which we can handle explicitly.

For now you can still pass bools to Iter::next() but they are ignored.
After this lands, I will update the callers to remove those.

FWIW: none of our other tests or gms seem to notice this change...

Bug: skia:9339
Change-Id: If40077b1ebb3d47cfce0ec43996ff272318e4a62
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235104
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2019-08-16 20:39:05 +00:00
Ben Wagner
2e9f772ef0 Move bigconic gm to be a test.
This gm doesn't seem to have ever drawn anything onto the actual canvas,
just leaving a white background. The content is derived from a fuzzer
generated path which caused an assert in the software rasterization of
the path. Since the point is to ensure that this path does not cause an
assertion when drawn, move to the path tests.

Change-Id: Ibff77763d8079386a9b4bfe9a437ffa16856b53b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/234663
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-08-14 21:07:03 +00:00
Ben Wagner
51e15a69ce Use SkTextEncoding enum instead of macros.
Change-Id: I4b6259590fa0693ee0522b4999a1c0fe250b173d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212504
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-05-07 20:54:16 +00:00
Mike Klein
c0bd9f9fe5 rewrite includes to not need so much -Ifoo
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>
2019-04-24 16:27:11 +00:00
Brian Osman
cf4ec506ec Convexity checker: Wait for significant x-product when walking edges
This effectively re-applies the logic from
https://codereview.chromium.org/298973004

The change to the unit test for 389050 is interesting.
The last convexity rewrite "fixed" that case by allowing
it to be detected as convex. In the process, it actually
broke the original bug, so that rendering of the HTML
failed. This CL causes us to give up and decide that the
path is concave, but we return to rendering correctly, so
that's a win.

The bug that initiated this (950508) is effectively the
exact same bug as 2235, which is why I haven't added a new
test case. The existing test case is much more concise than
the 100K data file needed for the new one.

Bugs: skia:2235 chromium:389050 chromium:950508
Change-Id: I0de65db8644f37e335c47e9d41c676b8e8b020fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209164
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-04-19 18:01:54 +00:00
Brian Osman
309de7904d Remove SK_TREAT_COLINEAR_DIAGONAL_POINTS_AS_CONCAVE
This was rebaselined and removed from Chrome long ago.
Planning to fix more bugs in the Convexicator, but want
to get this out of the way first.

Change-Id: I4f299d56a81be509a861d1e9c9f0e48a47170096
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209322
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-04-19 14:11:49 +00:00
Brian Osman
14ac42b280 Remove the axis-aligned vector special case to convexity checker
There are bugs in the other code path that will require more state,
and maintaining this special case in parallel is going to be tricky.

Change-Id: I0083b0aa2af16391504f0993e765faa0f5522502
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209163
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-04-18 17:50:37 +00:00
Brian Osman
dbfcd92d5f Fix two SkPathRef bugs
- Transforming a path in place wasn't updating the gen ID of the path
- Transforming a path into another (uniquely held) path wasn't calling
  gen ID change listeners.

Bug: skia:
Change-Id: I9e244725d9bd5776d203ce6b12698cee09d0b714
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/199003
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2019-03-07 22:59:28 +00:00
Kevin Lubick
13486cbf56 more extra semis
Hopefully with better grepping.

Bug: skia:
Change-Id: I434f2b1fedc2eff2d62cf80b13ebb1bd71a1c8a1
Reviewed-on: https://skia-review.googlesource.com/c/181166
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
Auto-Submit: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2019-01-04 15:35:14 +00:00
Mike Reed
df3d225e80 use SkFont for measuring and paths
Bug: skia:
Change-Id: I1810edfef6e04be0380bac0eeab5450fe302e078
Reviewed-on: https://skia-review.googlesource.com/c/179728
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2018-12-20 22:43:05 +00:00
Mike Reed
fb5f43b09f add regression test for stale fLastMoveToIndex
This test used to assert/fail under ASAN because copyPath's
fLastMoveToIndex was garbage after the internal copy (in SkPath::transform).
Now the code sets it to the src's value.

Bug:883596
Change-Id: I3cba82fb63398bf4aa0abc9d3f2a0067d8ad9006
Reviewed-on: https://skia-review.googlesource.com/c/178931
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2018-12-18 17:45:12 +00:00
Cary Clark
21a7be0741 fix roll
Remove SkPathPriv::IsConvex() if SK_LEGACY_PATH_CONVEXITY
is defined to fix the Google3 roll.

TBR=ethannicholas@google.com

Bug: skia:
Change-Id: I2d2177213ec43dd048f15685d0afe49fb07656fe
Reviewed-on: https://skia-review.googlesource.com/c/177680
Commit-Queue: Cary Clark <caryclark@google.com>
Auto-Submit: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
2018-12-13 21:11:39 +00:00
Cary Clark
3d6b438b99 remove legacy pathref validation
Chrome added a public method to validate SkPathRef,
but always called it when validating SkPath. We did too.

Remove the SkPathRef entry point, validate SkPathRef
when validating SkPath, and remove Skia's callers.
(Chrome has already been fixed.)

TBR=reed@google.com
R=fmalita@chromium.org

Bug:913930
Change-Id: I0828b00b42cc1f031b4216ddeace50f80aa21e62
Reviewed-on: https://skia-review.googlesource.com/c/177065
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-12-13 14:29:09 +00:00
Cary Clark
c9b7c720dd two pass convexity
This separates the existing convexity logic into
two passes. The first pass detects concavity by
counting the changes in direction.
The second pass computes the cross product to
see that all angles bend in the same direction, and
computes the dot product to see if the angle
doubles back on itself.

The second pass treats axis-aligned vectors
separately, and computes the dot and cross products
by comparing point values; it does not use arithmetic
to determine convexity, so it works with all finite
values.

A compile time switch enables returning concave
for co-linear diagonal points:
If successive points are not axis-aligned, and
those points are co-linear along a diagonal;
the path is treated as concave. This is conservative
but avoids paths that change convexity when the
are translated or scaled, since transforming the
path may cause the midpoint to shift to either
side of a line formed by the endpoints.

The compile time switch is set so that co-linear
diagonal points do not affect convexity. Note that
this permits shapes formerly considered concave, such
as stroked lines with round caps, to become convex;
this accounts for many of the GM differences.

A path may double back on itself and be convex;
for instance, a path containing a single line.

Path may have multiple initial moveTo verbs, or
trailing moveTo verbs, and still evaluate as convex.

A separate entry point, SkPathPriv::IsConvex()
allows passing an array of points instead of a path.

A legacy define has been checked into Chrome to
use the old code until layout tests have been
rebaselined.

R=reed@google.com,bsalomon@google.com
Bug:899689
Change-Id: I392bbe04836ffb19666ad92ab2a2404c56543019
Reviewed-on: https://skia-review.googlesource.com/c/173427
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
2018-12-13 13:04:44 +00:00
Cary Clark
aa3b291717 bracket SkPath pathRefIsValid with define
Add defines around the places calls
SkPath::pathRefIsValid()

R=fmalita@chromium.org

Bug:913930
Change-Id: Iffaa85cecf127cf8cb405dffe76666f9184de76e
Reviewed-on: https://skia-review.googlesource.com/c/176583
Commit-Queue: Cary Clark <caryclark@skia.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-12-11 17:10:09 +00:00
Mike Reed
497b3680a9 remove guard for complexity change
Bug: skia:
Change-Id: I11ff57dca2c48519bc3a23e36da01bf40d1b329c
Reviewed-on: https://skia-review.googlesource.com/c/174221
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2018-12-04 15:48:13 +00:00
Mike Reed
07105bbcbe don't trust convexity after a transform
In theory, a convex shape is still convex if transformed by an affine
matrix. However, SkPath segments are specified using floats, and attributes
like collinearity can break under some transforms due to finite precision.

Computing convexity is non-trivial, so there is value in SkPath caching this
calculation. Convexity is useful, as both the CPU and GPU backends can draw
convex shapes faster than non-convex.

To balance these two (fragile float math and value of caching convexity),
this CL invalidates this cached state if the transform could change convexity.
In the general case, it is assumed that convexity could change. Special cases
where it is safe to keep the cached state after transform are:
- identity transform
- scale/translate transform if the path is known to be axis-aligned
All other combinations invalidate the cached state, forcing it to be
recomputed.

"axis-aligned" means the segments in the path are all axis-aligned, horizontal
or vertical (e.g. a rect or rrect)

Bug: 899689
Change-Id: I1381273eaff61d6b7134ae94b4f251c69991081a
Reviewed-on: https://skia-review.googlesource.com/c/173226
Commit-Queue: Ravi Mistry <rmistry@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
2018-12-01 21:17:34 +00:00
Mike Reed
d437c79ed0 Revert "don't trust convexity with affine transforms"
This reverts commit 26d8d77aae.

Reason for revert: speculative, in case this is blocking the chrome roll

Original change's description:
> don't trust convexity with affine transforms
> 
> In theory, a convex shape transformed by an affine matrix should still
> be convex. However, due to numerical nastiness of floats, when we try
> to determine if something is convex, we can get different answers pre
> and post a transformation (think of two line segments nearly colinear).
> 
> Convex paths take a faster scan converter, but it is only well behaved
> if the path is, in fact, convex. Thus we have to be conservative about
> which paths we mark as convex.
> 
> This bug found a case where a "convex" path, after going through a transform,
> became (according to our measure) non-convex. The bug was that we *thought*
> that once convex always convex, but in reality it was not. The fix (hack) is
> to notice when we transform by an affine matrix (we're still assuming/hoping
> that scaling and translate keep things convex (1)...) and mark the convexity
> as "unknown", forcing us to re-compute it.
> 
> This will slow down these paths, since it costs something to compute convexity.
> Hopefully non-scale-translate transforms are rare, so we won't notice the
> speed loss too much.
> 
> (1) This is not proven. If we find scaling/translation to break our notion of
> convexity, we'll need to get more aggressive/clever to find a fix.
> 
> 
> Bug: 899689
> Change-Id: I5921eca247428bf89380bc2395fe373fa70deb1d
> Reviewed-on: https://skia-review.googlesource.com/c/173080
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Cary Clark <caryclark@google.com>
> Reviewed-by: Jim Van Verth <jvanverth@google.com>

TBR=mtklein@google.com,jvanverth@google.com,caryclark@google.com,reed@google.com,caryclark@skia.org

Change-Id: I5d846798f2c34c6576591a3c3125cfdc3c72dbdc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 899689
Reviewed-on: https://skia-review.googlesource.com/c/173162
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2018-11-28 13:13:43 +00:00
Mike Reed
26d8d77aae don't trust convexity with affine transforms
In theory, a convex shape transformed by an affine matrix should still
be convex. However, due to numerical nastiness of floats, when we try
to determine if something is convex, we can get different answers pre
and post a transformation (think of two line segments nearly colinear).

Convex paths take a faster scan converter, but it is only well behaved
if the path is, in fact, convex. Thus we have to be conservative about
which paths we mark as convex.

This bug found a case where a "convex" path, after going through a transform,
became (according to our measure) non-convex. The bug was that we *thought*
that once convex always convex, but in reality it was not. The fix (hack) is
to notice when we transform by an affine matrix (we're still assuming/hoping
that scaling and translate keep things convex (1)...) and mark the convexity
as "unknown", forcing us to re-compute it.

This will slow down these paths, since it costs something to compute convexity.
Hopefully non-scale-translate transforms are rare, so we won't notice the
speed loss too much.

(1) This is not proven. If we find scaling/translation to break our notion of
convexity, we'll need to get more aggressive/clever to find a fix.


Bug: 899689
Change-Id: I5921eca247428bf89380bc2395fe373fa70deb1d
Reviewed-on: https://skia-review.googlesource.com/c/173080
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2018-11-27 19:36:36 +00:00
Mike Reed
6a388006f5 be consistent about int for incReserve
Bug: 883666
Change-Id: I4070c958ef9ac5891ea75a8ef349e3d362c97f54
Reviewed-on: https://skia-review.googlesource.com/c/162620
Auto-Submit: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2018-10-16 20:39:28 +00:00
Mike Reed
98acec5bf1 remove some dead flags
SK_SUPPORT_LEGACY_PAINT_TEXTDECORATION
SK_SUPPORT_LEGACY_DASH_CULL_PATH
SK_SUPPORT_LEGACY_DELTA_AA

Bug: skia:
Change-Id: Id4e2c04936ec8c6887b55d3058e90c4e0508b8a1
Reviewed-on: https://skia-review.googlesource.com/c/159242
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2018-10-03 19:44:58 +00:00
Mike Reed
ce96e1e94f removed dead flag check
Missed this earlier. Should have been part of https://skia-review.googlesource.com/c/skia/+/158600

Bug: skia:
Change-Id: Id70dda3aa1e869aee3e6f10c042c84b4bfc5c211
Reviewed-on: https://skia-review.googlesource.com/158740
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-10-02 15:53:57 +00:00
Mike Klein
9de721655c add test that setLastPt() invalidates path bounds
Spoiler alert... it doesn't.

Bug: oss-fuzz:10488
Change-Id: Ifafd92f40aed55ff14a5198ea7d79a20751e40aa
Reviewed-on: https://skia-review.googlesource.com/156661
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2018-09-27 14:48:34 +00:00
Mike Reed
c3d8a48f1b allow path.add(path) safely
Bug: 882423
Change-Id: Ied2ad2d5dfdf00af8f3ba722b522e9602fea5557
Reviewed-on: https://skia-review.googlesource.com/153260
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2018-09-12 14:29:18 +00:00
Florin Malita
0e0f1a71da SkPath::shrinkToFit docs
Add header and .bmh docs for shrinkToFit().

Also remove SkPath::debugging_private_getFreeSpace() and refactor tests
to use (friended) helper classes.

Docs-Preview: https://skia.org/?cl=153668
Change-Id: I3f93f9561b25025ce04a81d5e2f0271295b3daad
Reviewed-on: https://skia-review.googlesource.com/153668
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-09-11 20:43:22 +00:00
Florin Malita
3d413c5761 Reland: add SkPath::shrinkToFit
Original CL: https://skia-review.googlesource.com/c/skia/+/150967

  * expanded tests
  * fixed shared pathref copying

Change-Id: I4bfe89f597485aa2db68f58d99112188615faceb
Reviewed-on: https://skia-review.googlesource.com/153553
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Auto-Submit: Florin Malita <fmalita@chromium.org>
2018-09-11 18:33:00 +00:00