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

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

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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/color_analysis_unittest.cc ('k') | ui/gfx/icon_util.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 (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/color_utils.h" 5 #include "ui/gfx/color_utils.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 return SkColorSetARGB(alpha, 230 return SkColorSetARGB(alpha,
231 static_cast<int>(std::round(r)), 231 static_cast<int>(std::round(r)),
232 static_cast<int>(std::round(g)), 232 static_cast<int>(std::round(g)),
233 static_cast<int>(std::round(b))); 233 static_cast<int>(std::round(b)));
234 } 234 }
235 235
236 void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]) { 236 void BuildLumaHistogram(const SkBitmap& bitmap, int histogram[256]) {
237 DCHECK_EQ(kN32_SkColorType, bitmap.colorType()); 237 DCHECK_EQ(kN32_SkColorType, bitmap.colorType());
238 238
239 SkAutoLockPixels bitmap_lock(bitmap);
240
241 int pixel_width = bitmap.width(); 239 int pixel_width = bitmap.width();
242 int pixel_height = bitmap.height(); 240 int pixel_height = bitmap.height();
243 for (int y = 0; y < pixel_height; ++y) { 241 for (int y = 0; y < pixel_height; ++y) {
244 for (int x = 0; x < pixel_width; ++x) 242 for (int x = 0; x < pixel_width; ++x)
245 ++histogram[GetLuma(bitmap.getColor(x, y))]; 243 ++histogram[GetLuma(bitmap.getColor(x, y))];
246 } 244 }
247 } 245 }
248 246
249 double CalculateBoringScore(const SkBitmap& bitmap) { 247 double CalculateBoringScore(const SkBitmap& bitmap) {
250 if (bitmap.isNull() || bitmap.empty()) 248 if (bitmap.isNull() || bitmap.empty())
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 "rgba(%s,%s)", SkColorToRgbString(color).c_str(), 354 "rgba(%s,%s)", SkColorToRgbString(color).c_str(),
357 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); 355 base::DoubleToString(SkColorGetA(color) / 255.0).c_str());
358 } 356 }
359 357
360 std::string SkColorToRgbString(SkColor color) { 358 std::string SkColorToRgbString(SkColor color) {
361 return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color), 359 return base::StringPrintf("%d,%d,%d", SkColorGetR(color), SkColorGetG(color),
362 SkColorGetB(color)); 360 SkColorGetB(color));
363 } 361 }
364 362
365 } // namespace color_utils 363 } // namespace color_utils
OLDNEW
« no previous file with comments | « ui/gfx/color_analysis_unittest.cc ('k') | ui/gfx/icon_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698