OLD | NEW |
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 Loading... |
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 static_cast<const uint8_t*>(pixel_ref_->pixels()); |
| 59 } |
| 60 |
57 private: | 61 private: |
58 friend class AutoLockUIResourceBitmap; | 62 friend class AutoLockUIResourceBitmap; |
59 | 63 |
60 void Create(sk_sp<SkPixelRef> pixel_ref, | 64 void Create(sk_sp<SkPixelRef> pixel_ref, |
61 const gfx::Size& size, | 65 const gfx::Size& size, |
62 UIResourceFormat format); | 66 UIResourceFormat format); |
63 | 67 |
64 sk_sp<SkPixelRef> pixel_ref_; | 68 sk_sp<SkPixelRef> pixel_ref_; |
65 UIResourceFormat format_; | 69 UIResourceFormat format_; |
66 gfx::Size size_; | 70 gfx::Size size_; |
67 bool opaque_; | 71 bool opaque_; |
68 }; | 72 }; |
69 | 73 |
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 | 74 } // namespace cc |
81 | 75 |
82 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ | 76 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
OLD | NEW |