OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/shadow_value.h" | 5 #include "ui/gfx/shadow_value.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 Insets ShadowValue::GetMargin(const ShadowValues& shadows) { | 73 Insets ShadowValue::GetMargin(const ShadowValues& shadows) { |
74 gfx::Insets margins = GetInsets(shadows, false); | 74 gfx::Insets margins = GetInsets(shadows, false); |
75 return -margins; | 75 return -margins; |
76 } | 76 } |
77 | 77 |
78 // static | 78 // static |
79 Insets ShadowValue::GetBlurRegion(const ShadowValues& shadows) { | 79 Insets ShadowValue::GetBlurRegion(const ShadowValues& shadows) { |
80 return GetInsets(shadows, true); | 80 return GetInsets(shadows, true); |
81 } | 81 } |
82 | 82 |
| 83 // static |
| 84 ShadowValues ShadowValue::MakeMdShadowValues(int elevation) { |
| 85 ShadowValues shadow_values; |
| 86 // To match the CSS notion of blur (spread outside the bounding box) to the |
| 87 // Skia notion of blur (spread outside and inside the bounding box), we have |
| 88 // to double the designer-provided blur values. |
| 89 const int kBlurCorrection = 2; |
| 90 // "Key shadow": y offset is elevation and blur is twice the elevation. |
| 91 shadow_values.emplace_back(gfx::Vector2d(0, elevation), |
| 92 kBlurCorrection * elevation * 2, |
| 93 SkColorSetA(SK_ColorBLACK, 0x3d)); |
| 94 // "Ambient shadow": no offset and blur matches the elevation. |
| 95 shadow_values.emplace_back(gfx::Vector2d(), kBlurCorrection * elevation, |
| 96 SkColorSetA(SK_ColorBLACK, 0x1f)); |
| 97 // To see what this looks like for elevation 24, try this CSS: |
| 98 // box-shadow: 0 24px 48px rgba(0, 0, 0, .24), |
| 99 // 0 0 24px rgba(0, 0, 0, .12); |
| 100 return shadow_values; |
| 101 } |
| 102 |
83 } // namespace gfx | 103 } // namespace gfx |
OLD | NEW |