From: reed@google.com Date: Thu, 23 Jun 2011 15:07:04 +0000 (+0000) Subject: detect when our quadratic is really linear for 2-point radial, and don't X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~18187 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8871a84935d3606aad2bb490f2704c388fcfed90;p=platform%2Fupstream%2FlibSkiaSharp.git detect when our quadratic is really linear for 2-point radial, and don't divide by zero, but rather just return -c/b git-svn-id: http://skia.googlecode.com/svn/trunk@1684 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/src/effects/SkGradientShader.cpp b/src/effects/SkGradientShader.cpp index cfe444e..89b9d34 100644 --- a/src/effects/SkGradientShader.cpp +++ b/src/effects/SkGradientShader.cpp @@ -1476,6 +1476,9 @@ private: #ifdef SK_USE_SLOW_2POINT_RADIAL_GRADIENT static inline SkFixed two_point_radial(SkFixed b, SkFixed fx, SkFixed fy, SkFixed sr2d2, SkFixed foura, SkFixed oneOverTwoA, bool posRoot) { SkFixed c = SkFixedSquare(fx) + SkFixedSquare(fy) - sr2d2; + if (0 == foura) { + return SkFixedDiv(-c, b); + } SkFixed discrim = SkFixedSquare(b) - SkFixedMul(foura, c); if (discrim < 0) { discrim = -discrim; @@ -1492,6 +1495,10 @@ static inline SkFixed two_point_radial(SkScalar b, SkScalar fx, SkScalar fy, SkScalar sr2d2, SkScalar foura, SkScalar oneOverTwoA, bool posRoot) { SkScalar c = SkScalarSquare(fx) + SkScalarSquare(fy) - sr2d2; + if (0 == foura) { + return SkScalarToFixed(SkScalarDiv(-c, b)); + } + SkScalar discrim = SkScalarSquare(b) - SkScalarMul(foura, c); if (discrim < 0) { discrim = -discrim;