diff options
author | joshualitt <joshualitt@chromium.org> | 2014-09-22 10:29:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-22 10:29:30 -0700 |
commit | 0125847c165d59c0efcbf9ab81e6b51715829afd (patch) | |
tree | fb8f7c0c923236cf3de0e3db4956f10be7bb0e1c | |
parent | 4401a1f7d6d4fad6315b8b8647d9bb7d1ae90141 (diff) |
Proposed fix for small bug in gpu conical gradients
BUG=skia:
R=bsalomon@google.com, egdaniel@google.com, senorblanco@chromium.org
Author: joshualitt@chromium.org
Review URL: https://codereview.chromium.org/593443002
-rw-r--r-- | src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp index 720dc6345d..c02e71eb9a 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp @@ -98,9 +98,12 @@ private: fDiffRadius(shader.getDiffRadius()){ // We should only be calling this shader if we are degenerate case with touching circles // 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)); + // start radius was close to zero, otherwise we scaled by the start radius. In addition + // Our test for the edge case in set_matrix_circle_conical has a higher tolerance so we + // need the sqrt value below + SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - fCenterX1) < + (fRadius0 < kErrorTol ? shader.getEndRadius() * kEdgeErrorTol : + fRadius0 * sqrt(kEdgeErrorTol))); // We pass the linear part of the quadratic as a varying. // float b = -2.0 * (fCenterX1 * x + fRadius0 * fDiffRadius * z) @@ -173,6 +176,9 @@ const GrBackendEffectFactory& Edge2PtConicalEffect::getFactory() const { GR_DEFINE_EFFECT_TEST(Edge2PtConicalEffect); +/* + * All Two point conical gradient test create functions may occasionally create edge case shaders + */ GrEffect* Edge2PtConicalEffect::TestCreate(SkRandom* random, GrContext* context, const GrDrawTargetCaps&, @@ -452,6 +458,9 @@ const GrBackendEffectFactory& FocalOutside2PtConicalEffect::getFactory() const { GR_DEFINE_EFFECT_TEST(FocalOutside2PtConicalEffect); +/* + * All Two point conical gradient test create functions may occasionally create edge case shaders + */ GrEffect* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random, GrContext* context, const GrDrawTargetCaps&, @@ -656,6 +665,9 @@ const GrBackendEffectFactory& FocalInside2PtConicalEffect::getFactory() const { GR_DEFINE_EFFECT_TEST(FocalInside2PtConicalEffect); +/* + * All Two point conical gradient test create functions may occasionally create edge case shaders + */ GrEffect* FocalInside2PtConicalEffect::TestCreate(SkRandom* random, GrContext* context, const GrDrawTargetCaps&, @@ -903,6 +915,9 @@ const GrBackendEffectFactory& CircleInside2PtConicalEffect::getFactory() const { GR_DEFINE_EFFECT_TEST(CircleInside2PtConicalEffect); +/* + * All Two point conical gradient test create functions may occasionally create edge case shaders + */ GrEffect* CircleInside2PtConicalEffect::TestCreate(SkRandom* random, GrContext* context, const GrDrawTargetCaps&, @@ -1135,6 +1150,9 @@ const GrBackendEffectFactory& CircleOutside2PtConicalEffect::getFactory() const GR_DEFINE_EFFECT_TEST(CircleOutside2PtConicalEffect); +/* + * All Two point conical gradient test create functions may occasionally create edge case shaders + */ GrEffect* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random, GrContext* context, const GrDrawTargetCaps&, @@ -1148,11 +1166,11 @@ GrEffect* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random, center2.set(random->nextUScalar1(), random->nextUScalar1()); // If the circles share a center than we can't be in the outside case } while (center1 == center2); - SkPoint diff = center2 - center1; - diffLen = diff.length(); - // Below makes sure that circle one is not contained within circle two - // and have radius2 >= radius to match sorting on cpu side - radius2 = radius1 + random->nextRangeF(0.f, diffLen); + SkPoint diff = center2 - center1; + diffLen = diff.length(); + // Below makes sure that circle one is not contained within circle two + // and have radius2 >= radius to match sorting on cpu side + radius2 = radius1 + random->nextRangeF(0.f, diffLen); SkColor colors[kMaxRandomGradientColors]; SkScalar stopsArray[kMaxRandomGradientColors]; |