Index: include/effects/SkLightingImageFilter.h |
diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h |
index 07f713b0af44272f830319475c5312b339ab72f2..9c90cd949bc2f94718befdadf6d945f37dbc7c30 100644 |
--- a/include/effects/SkLightingImageFilter.h |
+++ b/include/effects/SkLightingImageFilter.h |
@@ -26,7 +26,8 @@ public: |
return fX > fY ? (fX > fZ ? fX : fZ) : (fY > fZ ? fY : fZ); |
} |
void normalize() { |
- SkScalar scale = SkScalarInvert(SkScalarSqrt(dot(*this))); |
+ // Small epsilon is added to prevent division by 0. |
+ SkScalar scale = SkScalarInvert(SkScalarSqrt(dot(*this)) + SK_ScalarNearlyZero); |
fX = SkScalarMul(fX, scale); |
fY = SkScalarMul(fY, scale); |
fZ = SkScalarMul(fZ, scale); |