aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2017-04-10 11:58:17 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-12 19:36:40 +0000
commit0f47a25cac5ceaa172f4db1cc50c36868527ff84 (patch)
treefe0fe7e4e9e0da1209a357f9ff6b2e43e08bb8e6 /src
parent5bc818173add1bd1998e4a87a58dca80a654757a (diff)
Fix cubic KLM solving
Fixes calc_inverse_transpose_power_basis_matrix() to look for the determinant with the largest ABSOLUTE VALUE. BUG=skia: Change-Id: I70e26cc7ab9955d2e094fb7581f0ec9f5e0ae2d9 Reviewed-on: https://skia-review.googlesource.com/13081 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrPathUtils.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index 6dbac62fc1..536f3c3acb 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -617,15 +617,16 @@ static int calc_inverse_transpose_power_basis_matrix(const SkPoint pts[4], SkMat
}
// The matrix is 3x4. In order to invert it, we first need to make it square by throwing out one
- // of the top three rows. We toss the row that leaves us with the largest determinant. Since the
- // right column will be [0 0 1], the determinant reduces to x0*y1 - y0*x1.
- SkScalar det[4];
- SkScalar4 DETX1 = SkNx_shuffle<1,0,0,3>(X), DETY1 = SkNx_shuffle<1,0,0,3>(Y);
- SkScalar4 DETX2 = SkNx_shuffle<2,2,1,3>(X), DETY2 = SkNx_shuffle<2,2,1,3>(Y);
- (DETX1 * DETY2 - DETY1 * DETX2).store(det);
- const int skipRow = det[0] > det[2] ? (det[0] > det[1] ? 0 : 1)
- : (det[1] > det[2] ? 1 : 2);
- const SkScalar rdet = 1 / det[skipRow];
+ // of the top three rows. We toss the row that leaves us with the largest absolute determinant.
+ // Since the right column will be [0 0 1], the determinant reduces to x0*y1 - y0*x1.
+ SkScalar absDet[4];
+ const SkScalar4 DETX1 = SkNx_shuffle<1,0,0,3>(X), DETY1 = SkNx_shuffle<1,0,0,3>(Y);
+ const SkScalar4 DETX2 = SkNx_shuffle<2,2,1,3>(X), DETY2 = SkNx_shuffle<2,2,1,3>(Y);
+ const SkScalar4 DET = DETX1 * DETY2 - DETY1 * DETX2;
+ DET.abs().store(absDet);
+ const int skipRow = absDet[0] > absDet[2] ? (absDet[0] > absDet[1] ? 0 : 1)
+ : (absDet[1] > absDet[2] ? 1 : 2);
+ const SkScalar rdet = 1 / DET[skipRow];
const int row0 = (0 != skipRow) ? 0 : 1;
const int row1 = (2 == skipRow) ? 1 : 2;