Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: ui/gfx/shadow_util.cc

Issue 2951583002: Update voice interaction icon shadow (Closed)
Patch Set: fix const Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shelf/voice_interaction_overlay.cc ('k') | ui/gfx/shadow_value.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_util.h" 5 #include "ui/gfx/shadow_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const ShadowDetails& ShadowDetails::Get(int elevation, int corner_radius) { 86 const ShadowDetails& ShadowDetails::Get(int elevation, int corner_radius) {
87 auto iter = 87 auto iter =
88 g_shadow_cache.Get().find(std::make_pair(elevation, corner_radius)); 88 g_shadow_cache.Get().find(std::make_pair(elevation, corner_radius));
89 if (iter != g_shadow_cache.Get().end()) 89 if (iter != g_shadow_cache.Get().end())
90 return iter->second; 90 return iter->second;
91 91
92 auto insertion = g_shadow_cache.Get().insert(std::make_pair( 92 auto insertion = g_shadow_cache.Get().insert(std::make_pair(
93 std::make_pair(elevation, corner_radius), ShadowDetails())); 93 std::make_pair(elevation, corner_radius), ShadowDetails()));
94 DCHECK(insertion.second); 94 DCHECK(insertion.second);
95 ShadowDetails* shadow = &insertion.first->second; 95 ShadowDetails* shadow = &insertion.first->second;
96 // To match the CSS notion of blur (spread outside the bounding box) to the 96 shadow->values = ShadowValue::MakeMdShadowValues(elevation);
97 // Skia notion of blur (spread outside and inside the bounding box), we have
98 // to double the designer-provided blur values.
99 const int kBlurCorrection = 2;
100 // "Key shadow": y offset is elevation and blur is twice the elevation.
101 shadow->values.emplace_back(gfx::Vector2d(0, elevation),
102 kBlurCorrection * elevation * 2,
103 SkColorSetA(SK_ColorBLACK, 0x3d));
104 // "Ambient shadow": no offset and blur matches the elevation.
105 shadow->values.emplace_back(gfx::Vector2d(), kBlurCorrection * elevation,
106 SkColorSetA(SK_ColorBLACK, 0x1f));
107 // To see what this looks like for elevation 24, try this CSS:
108 // box-shadow: 0 24px 48px rgba(0, 0, 0, .24),
109 // 0 0 24px rgba(0, 0, 0, .12);
110 auto* source = new ShadowNineboxSource(shadow->values, corner_radius); 97 auto* source = new ShadowNineboxSource(shadow->values, corner_radius);
111 shadow->ninebox_image = ImageSkia(source, source->size()); 98 shadow->ninebox_image = ImageSkia(source, source->size());
112 return *shadow; 99 return *shadow;
113 } 100 }
114 101
115 } // namespace gfx 102 } // namespace gfx
OLDNEW
« no previous file with comments | « ash/shelf/voice_interaction_overlay.cc ('k') | ui/gfx/shadow_value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698