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

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

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 years, 9 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 | « ui/gfx/paint_vector_icon.cc ('k') | ui/gl/gl_context.cc » ('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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 const std::vector<ShadowValue> shadows_; 68 const std::vector<ShadowValue> shadows_;
69 69
70 const float corner_radius_; 70 const float corner_radius_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(ShadowNineboxSource); 72 DISALLOW_COPY_AND_ASSIGN(ShadowNineboxSource);
73 }; 73 };
74 74
75 // Map from elevation/corner radius pair to a cached shadow. 75 // Map from elevation/corner radius pair to a cached shadow.
76 using ShadowDetailsMap = std::map<std::pair<int, int>, ShadowDetails>; 76 using ShadowDetailsMap = std::map<std::pair<int, int>, ShadowDetails>;
77 base::LazyInstance<ShadowDetailsMap> g_shadow_cache = LAZY_INSTANCE_INITIALIZER; 77 base::LazyInstance<ShadowDetailsMap>::DestructorAtExit g_shadow_cache =
78 LAZY_INSTANCE_INITIALIZER;
78 79
79 } // namespace 80 } // namespace
80 81
81 ShadowDetails::ShadowDetails() {} 82 ShadowDetails::ShadowDetails() {}
82 ShadowDetails::ShadowDetails(const ShadowDetails& other) = default; 83 ShadowDetails::ShadowDetails(const ShadowDetails& other) = default;
83 ShadowDetails::~ShadowDetails() {} 84 ShadowDetails::~ShadowDetails() {}
84 85
85 const ShadowDetails& ShadowDetails::Get(int elevation, int corner_radius) { 86 const ShadowDetails& ShadowDetails::Get(int elevation, int corner_radius) {
86 auto iter = 87 auto iter =
87 g_shadow_cache.Get().find(std::make_pair(elevation, corner_radius)); 88 g_shadow_cache.Get().find(std::make_pair(elevation, corner_radius));
(...skipping 17 matching lines...) Expand all
105 SkColorSetA(SK_ColorBLACK, 0x1f)); 106 SkColorSetA(SK_ColorBLACK, 0x1f));
106 // To see what this looks like for elevation 24, try this CSS: 107 // To see what this looks like for elevation 24, try this CSS:
107 // box-shadow: 0 24px 48px rgba(0, 0, 0, .24), 108 // box-shadow: 0 24px 48px rgba(0, 0, 0, .24),
108 // 0 0 24px rgba(0, 0, 0, .12); 109 // 0 0 24px rgba(0, 0, 0, .12);
109 auto* source = new ShadowNineboxSource(shadow->values, corner_radius); 110 auto* source = new ShadowNineboxSource(shadow->values, corner_radius);
110 shadow->ninebox_image = ImageSkia(source, source->size()); 111 shadow->ninebox_image = ImageSkia(source, source->size());
111 return *shadow; 112 return *shadow;
112 } 113 }
113 114
114 } // namespace gfx 115 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/paint_vector_icon.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698