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

Side by Side Diff: cc/resources/ui_resource_bitmap.cc

Issue 1869753003: Replace many skia::RefPtr with sk_sp<> in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Web*LayerImpl bindings + Dana's nits Created 4 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
« no previous file with comments | « cc/resources/ui_resource_bitmap.h ('k') | cc/test/fake_content_layer_client.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/resources/ui_resource_bitmap.h" 5 #include "cc/resources/ui_resource_bitmap.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 17 matching lines...) Expand all
28 break; 28 break;
29 default: 29 default:
30 NOTREACHED() << "Invalid SkColorType for UIResourceBitmap: " << sk_type; 30 NOTREACHED() << "Invalid SkColorType for UIResourceBitmap: " << sk_type;
31 break; 31 break;
32 } 32 }
33 return format; 33 return format;
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref, 38 void UIResourceBitmap::Create(sk_sp<SkPixelRef> pixel_ref,
39 const gfx::Size& size, 39 const gfx::Size& size,
40 UIResourceFormat format) { 40 UIResourceFormat format) {
41 DCHECK(size.width()); 41 DCHECK(size.width());
42 DCHECK(size.height()); 42 DCHECK(size.height());
43 DCHECK(pixel_ref); 43 DCHECK(pixel_ref);
44 DCHECK(pixel_ref->isImmutable()); 44 DCHECK(pixel_ref->isImmutable());
45 format_ = format; 45 format_ = format;
46 size_ = size; 46 size_ = size;
47 pixel_ref_ = pixel_ref; 47 pixel_ref_ = std::move(pixel_ref);
48 48
49 // Default values for secondary parameters. 49 // Default values for secondary parameters.
50 opaque_ = (format == ETC1); 50 opaque_ = (format == ETC1);
51 } 51 }
52 52
53 UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) { 53 UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) {
54 DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels()); 54 DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels());
55 DCHECK(skbitmap.isImmutable()); 55 DCHECK(skbitmap.isImmutable());
56 56
57 skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef()); 57 sk_sp<SkPixelRef> pixel_ref = sk_ref_sp(skbitmap.pixelRef());
58 const SkImageInfo& info = pixel_ref->info(); 58 const SkImageInfo& info = pixel_ref->info();
59 Create(pixel_ref, gfx::Size(info.width(), info.height()), 59 Create(pixel_ref, gfx::Size(info.width(), info.height()),
f(malita) 2016/04/27 14:00:41 std::move(pixel_ref)?
tomhudson 2016/04/27 14:43:12 Done.
60 SkColorTypeToUIResourceFormat(skbitmap.colorType())); 60 SkColorTypeToUIResourceFormat(skbitmap.colorType()));
61 61
62 SetOpaque(skbitmap.isOpaque()); 62 SetOpaque(skbitmap.isOpaque());
63 } 63 }
64 64
65 UIResourceBitmap::UIResourceBitmap(const gfx::Size& size, bool is_opaque) { 65 UIResourceBitmap::UIResourceBitmap(const gfx::Size& size, bool is_opaque) {
66 SkAlphaType alphaType = is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 66 SkAlphaType alphaType = is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
67 SkImageInfo info = 67 SkImageInfo info =
68 SkImageInfo::MakeN32(size.width(), size.height(), alphaType); 68 SkImageInfo::MakeN32(size.width(), size.height(), alphaType);
69 skia::RefPtr<SkPixelRef> pixel_ref = skia::AdoptRef( 69 sk_sp<SkPixelRef> pixel_ref(
70 SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), NULL)); 70 SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), NULL));
71 pixel_ref->setImmutable(); 71 pixel_ref->setImmutable();
72 Create(pixel_ref, size, UIResourceBitmap::RGBA8); 72 Create(std::move(pixel_ref), size, UIResourceBitmap::RGBA8);
73 SetOpaque(is_opaque); 73 SetOpaque(is_opaque);
74 } 74 }
75 75
76 UIResourceBitmap::UIResourceBitmap(const skia::RefPtr<SkPixelRef>& pixel_ref, 76 UIResourceBitmap::UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref,
77 const gfx::Size& size) { 77 const gfx::Size& size) {
78 Create(pixel_ref, size, UIResourceBitmap::ETC1); 78 Create(std::move(pixel_ref), size, UIResourceBitmap::ETC1);
79 } 79 }
80 80
81 UIResourceBitmap::UIResourceBitmap(const UIResourceBitmap& other) = default; 81 UIResourceBitmap::UIResourceBitmap(const UIResourceBitmap& other) = default;
82 82
83 UIResourceBitmap::~UIResourceBitmap() {} 83 UIResourceBitmap::~UIResourceBitmap() {}
84 84
85 AutoLockUIResourceBitmap::AutoLockUIResourceBitmap( 85 AutoLockUIResourceBitmap::AutoLockUIResourceBitmap(
86 const UIResourceBitmap& bitmap) : bitmap_(bitmap) { 86 const UIResourceBitmap& bitmap) : bitmap_(bitmap) {
87 bitmap_.pixel_ref_->lockPixels(); 87 bitmap_.pixel_ref_->lockPixels();
88 } 88 }
89 89
90 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() { 90 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() {
91 bitmap_.pixel_ref_->unlockPixels(); 91 bitmap_.pixel_ref_->unlockPixels();
92 } 92 }
93 93
94 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const { 94 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const {
95 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels()); 95 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels());
96 } 96 }
97 97
98 } // namespace cc 98 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/ui_resource_bitmap.h ('k') | cc/test/fake_content_layer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698