Index: ui/gfx/shadow_value.cc |
diff --git a/ui/gfx/shadow_value.cc b/ui/gfx/shadow_value.cc |
index a8ab3f894366b49aab025aa317397c28a2aa2736..9f1779748018b566c64b48ef83aef82e0b70cfce 100644 |
--- a/ui/gfx/shadow_value.cc |
+++ b/ui/gfx/shadow_value.cc |
@@ -80,4 +80,24 @@ Insets ShadowValue::GetBlurRegion(const ShadowValues& shadows) { |
return GetInsets(shadows, true); |
} |
+// static |
+ShadowValues ShadowValue::MakeMdShadowValues(int elevation) { |
+ ShadowValues shadow_values; |
+ // To match the CSS notion of blur (spread outside the bounding box) to the |
+ // Skia notion of blur (spread outside and inside the bounding box), we have |
+ // to double the designer-provided blur values. |
+ const int kBlurCorrection = 2; |
+ // "Key shadow": y offset is elevation and blur is twice the elevation. |
+ shadow_values.emplace_back(gfx::Vector2d(0, elevation), |
+ kBlurCorrection * elevation * 2, |
+ SkColorSetA(SK_ColorBLACK, 0x3d)); |
+ // "Ambient shadow": no offset and blur matches the elevation. |
+ shadow_values.emplace_back(gfx::Vector2d(), kBlurCorrection * elevation, |
+ SkColorSetA(SK_ColorBLACK, 0x1f)); |
+ // To see what this looks like for elevation 24, try this CSS: |
+ // box-shadow: 0 24px 48px rgba(0, 0, 0, .24), |
+ // 0 0 24px rgba(0, 0, 0, .12); |
+ return shadow_values; |
+} |
+ |
} // namespace gfx |