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

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

Issue 10272004: Move RefCountedMemory class to base namespace. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/color_analysis.h ('k') | ui/views/widget/default_theme_provider.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/color_analysis.h" 5 #include "ui/gfx/color_analysis.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ui/gfx/codec/png_codec.h" 10 #include "ui/gfx/codec/png_codec.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 int GridSampler::GetSample(int width, int height) { 150 int GridSampler::GetSample(int width, int height) {
151 calls_++; 151 calls_++;
152 // We may keep getting called after we've gone of the edge of the grid; in 152 // We may keep getting called after we've gone of the edge of the grid; in
153 // this case we offset future return values by the number of times we've gone 153 // this case we offset future return values by the number of times we've gone
154 // off the grid. 154 // off the grid.
155 return (width * height * calls_ / kNumberOfClusters) % (width * height) + 155 return (width * height * calls_ / kNumberOfClusters) % (width * height) +
156 calls_ / kNumberOfClusters; 156 calls_ / kNumberOfClusters;
157 } 157 }
158 158
159 SkColor CalculateRecommendedBgColorForPNG( 159 SkColor CalculateRecommendedBgColorForPNG(
160 scoped_refptr<RefCountedMemory> png) { 160 scoped_refptr<base::RefCountedMemory> png) {
161 RandomSampler sampler; 161 RandomSampler sampler;
162 return CalculateRecommendedBgColorForPNG(png, sampler); 162 return CalculateRecommendedBgColorForPNG(png, sampler);
163 } 163 }
164 164
165 SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png, 165 SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png,
166 uint32_t darkness_limit, 166 uint32_t darkness_limit,
167 uint32_t brightness_limit) { 167 uint32_t brightness_limit) {
168 RandomSampler sampler; 168 RandomSampler sampler;
169 return CalculateKMeanColorOfPNG(png, darkness_limit, brightness_limit, 169 return CalculateKMeanColorOfPNG(png, darkness_limit, brightness_limit,
170 sampler); 170 sampler);
171 } 171 }
172 172
173 SkColor CalculateRecommendedBgColorForPNG( 173 SkColor CalculateRecommendedBgColorForPNG(
174 scoped_refptr<RefCountedMemory> png, 174 scoped_refptr<base::RefCountedMemory> png,
175 KMeanImageSampler& sampler) { 175 KMeanImageSampler& sampler) {
176 return CalculateKMeanColorOfPNG(png, 176 return CalculateKMeanColorOfPNG(png,
177 kMinDarkness, 177 kMinDarkness,
178 kMaxBrightness, 178 kMaxBrightness,
179 sampler); 179 sampler);
180 } 180 }
181 181
182 SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png, 182 SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png,
183 uint32_t darkness_limit, 183 uint32_t darkness_limit,
184 uint32_t brightness_limit, 184 uint32_t brightness_limit,
185 KMeanImageSampler& sampler) { 185 KMeanImageSampler& sampler) {
186 int img_width, img_height; 186 int img_width, img_height;
187 std::vector<uint8_t> decoded_data; 187 std::vector<uint8_t> decoded_data;
188 SkColor color = kDefaultBgColor; 188 SkColor color = kDefaultBgColor;
189 189
190 if (png.get() && 190 if (png.get() &&
191 png->size() && 191 png->size() &&
192 gfx::PNGCodec::Decode(png->front(), 192 gfx::PNGCodec::Decode(png->front(),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // set the color anyway to make sure we at least have a value here. 316 // set the color anyway to make sure we at least have a value here.
317 color = SkColorSetARGB(0xFF, r, g, b); 317 color = SkColorSetARGB(0xFF, r, g, b);
318 } 318 }
319 } 319 }
320 } 320 }
321 321
322 return color; 322 return color;
323 } 323 }
324 324
325 } // color_utils 325 } // color_utils
OLDNEW
« no previous file with comments | « ui/gfx/color_analysis.h ('k') | ui/views/widget/default_theme_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698