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

Side by Side Diff: components/user_manager/user_image/user_image.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 | « components/suggestions/image_encoder.cc ('k') | components/wallpaper/wallpaper_manager_base.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/user_manager/user_image/user_image.h" 5 #include "components/user_manager/user_image/user_image.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/gfx/codec/jpeg_codec.h" 10 #include "ui/gfx/codec/jpeg_codec.h"
11 #include "ui/gfx/codec/png_codec.h" 11 #include "ui/gfx/codec/png_codec.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
13 13
14 namespace user_manager { 14 namespace user_manager {
15 15
16 namespace { 16 namespace {
17 17
18 // Default quality for encoding user images. 18 // Default quality for encoding user images.
19 const int kDefaultEncodingQuality = 90; 19 const int kDefaultEncodingQuality = 90;
20 20
21 } // namespace 21 } // namespace
22 22
23 // static 23 // static
24 scoped_refptr<base::RefCountedBytes> UserImage::Encode( 24 scoped_refptr<base::RefCountedBytes> UserImage::Encode(
25 const SkBitmap& bitmap, 25 const SkBitmap& bitmap,
26 ImageFormat image_format) { 26 ImageFormat image_format) {
27 TRACE_EVENT2("oobe", "UserImage::Encode", 27 TRACE_EVENT2("oobe", "UserImage::Encode",
28 "width", bitmap.width(), "height", bitmap.height()); 28 "width", bitmap.width(), "height", bitmap.height());
29 SkAutoLockPixels lock_bitmap(bitmap);
30 std::vector<unsigned char> output; 29 std::vector<unsigned char> output;
31 auto* bitmap_data = reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)); 30 auto* bitmap_data = reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0));
32 if (image_format == FORMAT_JPEG) { 31 if (image_format == FORMAT_JPEG) {
33 if (gfx::JPEGCodec::Encode( 32 if (gfx::JPEGCodec::Encode(
34 bitmap_data, 33 bitmap_data,
35 gfx::JPEGCodec::FORMAT_SkBitmap, 34 gfx::JPEGCodec::FORMAT_SkBitmap,
36 bitmap.width(), 35 bitmap.width(),
37 bitmap.height(), 36 bitmap.height(),
38 bitmap.width() * bitmap.bytesPerPixel(), 37 bitmap.width() * bitmap.bytesPerPixel(),
39 kDefaultEncodingQuality, &output)) { 38 kDefaultEncodingQuality, &output)) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 image_format_(image_format) { 92 image_format_(image_format) {
94 } 93 }
95 94
96 UserImage::~UserImage() {} 95 UserImage::~UserImage() {}
97 96
98 void UserImage::MarkAsSafe() { 97 void UserImage::MarkAsSafe() {
99 is_safe_format_ = true; 98 is_safe_format_ = true;
100 } 99 }
101 100
102 } // namespace user_manager 101 } // namespace user_manager
OLDNEW
« no previous file with comments | « components/suggestions/image_encoder.cc ('k') | components/wallpaper/wallpaper_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698