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

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

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: fix mac 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 | « cc/output/renderer_pixeltest.cc ('k') | cc/resources/ui_resource_bitmap.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 #ifndef CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 5 #ifndef CC_RESOURCES_UI_RESOURCE_BITMAP_H_
6 #define CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 6 #define CC_RESOURCES_UI_RESOURCE_BITMAP_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 UIResourceBitmap(const gfx::Size& size, bool is_opaque); 47 UIResourceBitmap(const gfx::Size& size, bool is_opaque);
48 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size); 48 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size);
49 UIResourceBitmap(const UIResourceBitmap& other); 49 UIResourceBitmap(const UIResourceBitmap& other);
50 ~UIResourceBitmap(); 50 ~UIResourceBitmap();
51 51
52 // Returns the memory usage of the bitmap. 52 // Returns the memory usage of the bitmap.
53 size_t EstimateMemoryUsage() const { 53 size_t EstimateMemoryUsage() const {
54 return pixel_ref_ ? pixel_ref_->rowBytes() * size_.height() : 0; 54 return pixel_ref_ ? pixel_ref_->rowBytes() * size_.height() : 0;
55 } 55 }
56 56
57 const uint8_t* GetPixels() const {
58 return pixel_ref_ ? static_cast<const uint8_t*>(pixel_ref_->pixels())
f(malita) 2017/04/17 19:31:36 nit: prev version assumes pixel_ref_ is non-null;
reed1 2017/04/17 20:18:40 removed check.
59 : nullptr;
60 }
61
57 private: 62 private:
58 friend class AutoLockUIResourceBitmap; 63 friend class AutoLockUIResourceBitmap;
59 64
60 void Create(sk_sp<SkPixelRef> pixel_ref, 65 void Create(sk_sp<SkPixelRef> pixel_ref,
61 const gfx::Size& size, 66 const gfx::Size& size,
62 UIResourceFormat format); 67 UIResourceFormat format);
63 68
64 sk_sp<SkPixelRef> pixel_ref_; 69 sk_sp<SkPixelRef> pixel_ref_;
65 UIResourceFormat format_; 70 UIResourceFormat format_;
66 gfx::Size size_; 71 gfx::Size size_;
67 bool opaque_; 72 bool opaque_;
68 }; 73 };
69 74
70 class CC_EXPORT AutoLockUIResourceBitmap {
71 public:
72 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap);
73 ~AutoLockUIResourceBitmap();
74 const uint8_t* GetPixels() const;
75
76 private:
77 const UIResourceBitmap& bitmap_;
78 };
79
80 } // namespace cc 75 } // namespace cc
81 76
82 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 77 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_
OLDNEW
« no previous file with comments | « cc/output/renderer_pixeltest.cc ('k') | cc/resources/ui_resource_bitmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698