aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-06-09 11:57:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-09 11:57:28 -0700
commit8405ef9854858b2527bf03b7e7abb1c0da59411d (patch)
treed5d14d40953a9d7352ad1ff6b2ef084a01995d2a /src/effects
parent511923443facc611b3735b4688342c12071feaa0 (diff)
Fix Assert for gpu ConicalTwoPointGradient edgecase to be correct bounds.
BUG=skia: R=bsalomon@google.com Author: egdaniel@google.com Review URL: https://codereview.chromium.org/311373003
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index 23fee850f5..37c524db89 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -16,6 +16,7 @@
typedef GrGLUniformManager::UniformHandle UniformHandle;
static const SkScalar kErrorTol = 0.00001f;
+static const SkScalar kEdgeErrorTol = 5.f * kErrorTol;
/**
* We have three general cases for 2pt conical gradients. First we always assume that
@@ -96,7 +97,10 @@ private:
fRadius0(shader.getStartRadius()),
fDiffRadius(shader.getDiffRadius()){
// We should only be calling this shader if we are degenerate case with touching circles
- SkASSERT(SkScalarAbs(fDiffRadius) - SkScalarAbs(fCenterX1) < kErrorTol) ;
+ // When deciding if we are in edge case, we scaled by the end radius for cases when the
+ // start radius was close to zero, otherwise we scaled by the start radius
+ SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - SkScalarAbs(fCenterX1)) <
+ kEdgeErrorTol * (fRadius0 < kErrorTol ? shader.getEndRadius() : fRadius0));
// We pass the linear part of the quadratic as a varying.
// float b = -2.0 * (fCenterX1 * x + fRadius0 * fDiffRadius * z)
@@ -328,9 +332,9 @@ static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
// If the focal point is touching the edge of the circle it will
// cause a degenerate case that must be handled separately
- // 5 * kErrorTol was picked after manual testing the stability trade off
- // versus the linear approx used in the Edge Shader
- if (SkScalarAbs(1.f - (*focalX)) < 5 * kErrorTol) {
+ // kEdgeErrorTol = 5 * kErrorTol was picked after manual testing the
+ // stability trade off versus the linear approx used in the Edge Shader
+ if (SkScalarAbs(1.f - (*focalX)) < kEdgeErrorTol) {
return kEdge_ConicalType;
}
@@ -771,9 +775,10 @@ static ConicalType set_matrix_circle_conical(const SkTwoPointConicalGradient& sh
// Check to see if start circle is inside end circle with edges touching.
// If touching we return that it is of kEdge_ConicalType, and leave the matrix setting
- // to the edge shader. 5 * kErrorTol was picked after manual testing so that C = 1 / A
- // is stable, and the linear approximation used in the Edge shader is still accurate.
- if (SkScalarAbs(A) < 5 * kErrorTol) {
+ // to the edge shader. kEdgeErrorTol = 5 * kErrorTol was picked after manual testing
+ // so that C = 1 / A is stable, and the linear approximation used in the Edge shader is
+ // still accurate.
+ if (SkScalarAbs(A) < kEdgeErrorTol) {
return kEdge_ConicalType;
}