diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-04-13 14:26:00 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-14 15:14:11 +0000 |
commit | 4343654bc4a93812cba168a665deef0de2ebcfdd (patch) | |
tree | bee82de71d4671febf21ba1c13c2f312cbd2f8de /src/core/SkGeometry.h | |
parent | 028c3d77ea0e49982e92c6c9614cf59d687f4370 (diff) |
Improve accuracy of cubic classification
- Updates the logic to reflect the Loop-Blinn paper instead of the GPU
gems website.
- Removes the threshold for detecting local cusps. The serpentine
codepath works for these cusps anyway, so what we really want to know
is whether the discriminant is negative.
- Makes sure to not scale the inflection function by 1/0.
- Shifts the inflection function coefficients in d[] so they match the
paper.
- Stores the cubic discriminant in d[0].
Bug: skia:
Change-Id: I909a522a0fd27c9c8dfbc27d968bc43eeb7a416f
Reviewed-on: https://skia-review.googlesource.com/13304
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/core/SkGeometry.h')
-rw-r--r-- | src/core/SkGeometry.h | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/core/SkGeometry.h b/src/core/SkGeometry.h index 55d763b967..91b4d2d895 100644 --- a/src/core/SkGeometry.h +++ b/src/core/SkGeometry.h @@ -158,19 +158,26 @@ int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], bool SkChopMonoCubicAtX(SkPoint src[4], SkScalar y, SkPoint dst[7]); bool SkChopMonoCubicAtY(SkPoint src[4], SkScalar x, SkPoint dst[7]); -enum SkCubicType { - kSerpentine_SkCubicType, - kCusp_SkCubicType, - kLoop_SkCubicType, - kQuadratic_SkCubicType, - kLine_SkCubicType, - kPoint_SkCubicType +enum class SkCubicType { + kSerpentine, + kLoop, + kLocalCusp, // Cusp at a non-infinite parameter value with an inflection at t=infinity. + kInfiniteCusp, // Cusp with a cusp at t=infinity and a local inflection. + kQuadratic, + kLineOrPoint }; -/** Returns the cubic classification. Pass scratch storage for computing inflection data, - which can be used with additional work to find the loop intersections and so on. +/** Returns the cubic classification. + + d[] is filled with the cubic inflection function coefficients. Furthermore, since d0 is always + zero for integral curves, if the cubic type is kSerpentine, kLoop, or kLocalCusp then d[0] will + instead contain the cubic discriminant: 3*d2^2 - 4*d1*d3. + + See "Resolution Independent Curve Rendering using Programmable Graphics Hardware", + 4.2 Curve Categorization + https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf */ -SkCubicType SkClassifyCubic(const SkPoint p[4], SkScalar inflection[3]); +SkCubicType SkClassifyCubic(const SkPoint p[4], SkScalar d[4]); /////////////////////////////////////////////////////////////////////////////// |