aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPathUtils.cpp
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-08-28 10:24:22 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-28 16:53:27 +0000
commit419a94da028b33425a0feeb44d0d022a5d3d3704 (patch)
tree2a61554a992ae19c2f7620697c2baa026a237011 /src/gpu/GrPathUtils.cpp
parent7dda8dfb9d90f633af9a457b1c430f7cbf5536c5 (diff)
Add a GrCCPRGeometry file
Enough ccpr-specific geometry code is in flight that it feels like it should have its own file. Bug: skia: Change-Id: I99ef620a7dc35178cf774b3a4ec6159d46f401c7 Reviewed-on: https://skia-review.googlesource.com/39162 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrPathUtils.cpp')
-rw-r--r--src/gpu/GrPathUtils.cpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index 0089fc1703..a8abf81a63 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -567,66 +567,6 @@ void GrPathUtils::convertCubicToQuadsConstrainToTangents(const SkPoint p[4],
}
}
-static inline Sk2f normalize(const Sk2f& n) {
- Sk2f nn = n*n;
- return n * (nn + SkNx_shuffle<1,0>(nn)).rsqrt();
-}
-
-bool GrPathUtils::chopMonotonicQuads(const SkPoint p[3], SkPoint dst[5]) {
- GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT);
- GR_STATIC_ASSERT(2 * sizeof(float) == sizeof(SkPoint));
- GR_STATIC_ASSERT(0 == offsetof(SkPoint, fX));
-
- Sk2f p0 = Sk2f::Load(&p[0]);
- Sk2f p1 = Sk2f::Load(&p[1]);
- Sk2f p2 = Sk2f::Load(&p[2]);
-
- Sk2f tan0 = p1 - p0;
- Sk2f tan1 = p2 - p1;
- Sk2f v = p2 - p0;
-
- // Check if the curve is already monotonic (i.e. (tan0 dot v) >= 0 and (tan1 dot v) >= 0).
- // This should almost always be this case for well-behaved curves in the real world.
- float dot0[2], dot1[2];
- (tan0 * v).store(dot0);
- (tan1 * v).store(dot1);
- if (dot0[0] + dot0[1] >= 0 && dot1[0] + dot1[1] >= 0) {
- return false;
- }
-
- // Chop the curve into two segments with equal curvature. To do this we find the T value whose
- // tangent is perpendicular to the vector that bisects tan0 and -tan1.
- Sk2f n = normalize(tan0) - normalize(tan1);
-
- // This tangent can be found where (dQ(t) dot n) = 0:
- //
- // 0 = (dQ(t) dot n) = | 2*t 1 | * | p0 - 2*p1 + p2 | * | n |
- // | -2*p0 + 2*p1 | | . |
- //
- // = | 2*t 1 | * | tan1 - tan0 | * | n |
- // | 2*tan0 | | . |
- //
- // = 2*t * ((tan1 - tan0) dot n) + (2*tan0 dot n)
- //
- // t = (tan0 dot n) / ((tan0 - tan1) dot n)
- Sk2f dQ1n = (tan0 - tan1) * n;
- Sk2f dQ0n = tan0 * n;
- Sk2f t = (dQ0n + SkNx_shuffle<1,0>(dQ0n)) / (dQ1n + SkNx_shuffle<1,0>(dQ1n));
- t = Sk2f::Min(Sk2f::Max(t, 0), 1); // Clamp for FP error.
-
- Sk2f p01 = SkNx_fma(t, tan0, p0);
- Sk2f p12 = SkNx_fma(t, tan1, p1);
- Sk2f p012 = SkNx_fma(t, p12 - p01, p01);
-
- p0.store(&dst[0]);
- p01.store(&dst[1]);
- p012.store(&dst[2]);
- p12.store(&dst[3]);
- p2.store(&dst[4]);
-
- return true;
-}
-
////////////////////////////////////////////////////////////////////////////////
/**