From: Brian Salomon Date: Mon, 6 Feb 2017 19:23:53 +0000 (-0500) Subject: ShadowUtils: Fix umbra inset calculation when determining if umbra is fully occluded. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~55^2~479 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67386d44c77a1bef1cd9a896d779bd92ea03a558;p=platform%2Fupstream%2FlibSkiaSharp.git ShadowUtils: Fix umbra inset calculation when determining if umbra is fully occluded. Change-Id: Id0db49ad45b341d39abf7ee532ecc0799a832192 Reviewed-on: https://skia-review.googlesource.com/8079 Commit-Queue: Stan Iliev Reviewed-by: Jim Van Verth --- diff --git a/src/utils/SkShadowUtils.cpp b/src/utils/SkShadowUtils.cpp index ba4decc..c4b4e3d 100755 --- a/src/utils/SkShadowUtils.cpp +++ b/src/utils/SkShadowUtils.cpp @@ -499,6 +499,10 @@ void SkShadowUtils::DrawShadow(SkCanvas* canvas, const SkPath& path, SkScalar oc SkScalar hh = h / 2.f; SkScalar umbraInsetX = s * hw + factory.fRadius; SkScalar umbraInsetY = s * hh + factory.fRadius; + // The umbra is inset by radius along the diagonal, so adjust for that. + SkScalar d = 1.f / SkScalarSqrt(hw * hw + hh * hh); + umbraInsetX *= hw * d; + umbraInsetY *= hh * d; if (umbraInsetX > hw || umbraInsetY > hh) { // There is no umbra to occlude. factory.fOccluderType = SpotVerticesFactory::OccluderType::kTransparent;