aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGeometry.h
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-06-08 13:12:02 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-09 17:13:54 +0000
commitfebbffad1c24136f041d7fc2d5ffcd50e47a047f (patch)
tree860970fa626aa0901fadce958e755c107f7c97ca /src/core/SkGeometry.h
parent01b2b83aba10bc3767d660cd619c1da58b5eb0b5 (diff)
Improve cubic KLM accuracy
Moves cubic root finding logic out of GrPathUtils and PathOpsCubicIntersectionTest, and unifies it in SkGeometry. "Normalizes" the homogeneous parameter values of the roots, rather than the cubic inflection function. Does this normalization by twiddling the exponents instead of division (which causes a loss of precision). Abandons the built-in derivatives in GrCubicEffect. These don't have high enough precision on many mobile gpus. Instead we pass the KLM matrix to the vertex shader via uniform, where we can use it to set up new linear functionals from which the fragment shader can calculate the gradient of the implicit function. Bug: skia:4410 Change-Id: Ibd64e999520adc8cdef7803a492d3699995aef5a Reviewed-on: https://skia-review.googlesource.com/19017 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.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/core/SkGeometry.h b/src/core/SkGeometry.h
index 91b4d2d895..ef789a3bf3 100644
--- a/src/core/SkGeometry.h
+++ b/src/core/SkGeometry.h
@@ -161,23 +161,29 @@ bool SkChopMonoCubicAtY(SkPoint src[4], SkScalar x, SkPoint dst[7]);
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.
+ kLocalCusp, // Cusp at a non-infinite parameter value with an inflection at t=infinity.
+ kCuspAtInfinity, // Cusp with a cusp at t=infinity and a local inflection.
kQuadratic,
kLineOrPoint
};
/** 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.
+ t[],s[] are set to the two homogeneous parameter values at which points the lines L & M
+ intersect with K, sorted from smallest to largest and oriented so positive values of the
+ implicit are on the "left" side. For a serpentine curve they are the inflection points. For a
+ loop they are the double point. For a local cusp, they are both equal and denote the cusp point.
+ For a cusp at an infinite parameter value, one will be the local inflection point and the other
+ +inf (t,s = 1,0). If the curve is degenerate (i.e. quadratic or linear) they are both set to a
+ parameter value of +inf (t,s = 1,0).
+
+ d[] is filled with the cubic inflection function coefficients. See "Resolution Independent
+ Curve Rendering using Programmable Graphics Hardware", 4.2 Curve Categorization:
- 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 d[4]);
+SkCubicType SkClassifyCubic(const SkPoint p[4], SkScalar t[2] = nullptr, SkScalar s[2] = nullptr,
+ SkScalar d[4] = nullptr);
///////////////////////////////////////////////////////////////////////////////