aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDrawShadowInfo.h
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2018-06-19 14:39:12 -0400
committerGravatar Kevin Lubick <kjlubick@google.com>2018-06-19 19:36:25 +0000
commit99ca453634e66c570c8b28fa188bb427edda848b (patch)
treef2db098d07dbf903436ad7f1fc49086edf9e63a7 /src/core/SkDrawShadowInfo.h
parentbceddbcb72605343aca01638f64d7a8e8cb9792d (diff)
Clamp ambient blur radius
Bug: skia:8078 Change-Id: I8a45ce49b236ae0ad4c2176be71011c372c316ce Reviewed-on: https://skia-review.googlesource.com/135861 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/core/SkDrawShadowInfo.h')
-rw-r--r--src/core/SkDrawShadowInfo.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/SkDrawShadowInfo.h b/src/core/SkDrawShadowInfo.h
index d5820919ea..655bd827d8 100644
--- a/src/core/SkDrawShadowInfo.h
+++ b/src/core/SkDrawShadowInfo.h
@@ -29,6 +29,10 @@ namespace SkDrawShadowMetrics {
static constexpr auto kAmbientHeightFactor = 1.0f / 128.0f;
static constexpr auto kAmbientGeomFactor = 64.0f;
+// Assuming that we have a light height of 600 for the spot shadow,
+// the spot values will reach their maximum at a height of approximately 292.3077.
+// We'll round up to 300 to keep it simple.
+static constexpr auto kMaxAmbientRadius = 300*kAmbientHeightFactor*kAmbientGeomFactor;
static inline float divide_and_pin(float numer, float denom, float min, float max) {
float result = SkTPin(sk_ieee_float_divide(numer, denom), min, max);
@@ -38,7 +42,7 @@ static inline float divide_and_pin(float numer, float denom, float min, float ma
}
inline SkScalar AmbientBlurRadius(SkScalar height) {
- return height*kAmbientHeightFactor*kAmbientGeomFactor;
+ return SkTMin(height*kAmbientHeightFactor*kAmbientGeomFactor, kMaxAmbientRadius);
}
inline SkScalar AmbientRecipAlpha(SkScalar height) {