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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 void DrawToCanvas(SkCanvas* canvas, SkPaint* paint); | 44 void DrawToCanvas(SkCanvas* canvas, SkPaint* paint); |
45 | 45 |
46 // User must ensure that |skbitmap| is immutable. The SkBitmap Format should | 46 // User must ensure that |skbitmap| is immutable. The SkBitmap Format should |
47 // be 32-bit RGBA or 8-bit ALPHA. | 47 // be 32-bit RGBA or 8-bit ALPHA. |
48 explicit UIResourceBitmap(const SkBitmap& skbitmap); | 48 explicit UIResourceBitmap(const SkBitmap& skbitmap); |
49 UIResourceBitmap(const gfx::Size& size, bool is_opaque); | 49 UIResourceBitmap(const gfx::Size& size, bool is_opaque); |
50 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size); | 50 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size); |
51 UIResourceBitmap(const UIResourceBitmap& other); | 51 UIResourceBitmap(const UIResourceBitmap& other); |
52 ~UIResourceBitmap(); | 52 ~UIResourceBitmap(); |
53 | 53 |
54 // Returns the memory usage of the bitmap. | |
55 size_t GetAllocatedSizeInBytes() const { | |
56 return pixel_ref_ ? pixel_ref_->rowBytes() * size_.height() : 0; | |
ericrk
2016/10/14 00:07:38
I think this is fine - in some other places we use
David Trainor- moved to gerrit
2016/10/14 01:35:31
Ah yeah sorry I didn't realize the other method wa
ssid
2016/10/14 01:38:22
Okay keeping it as is. I will ping Skia owners to
| |
57 } | |
58 | |
54 private: | 59 private: |
55 friend class AutoLockUIResourceBitmap; | 60 friend class AutoLockUIResourceBitmap; |
56 | 61 |
57 void Create(sk_sp<SkPixelRef> pixel_ref, | 62 void Create(sk_sp<SkPixelRef> pixel_ref, |
58 const gfx::Size& size, | 63 const gfx::Size& size, |
59 UIResourceFormat format); | 64 UIResourceFormat format); |
60 | 65 |
61 sk_sp<SkPixelRef> pixel_ref_; | 66 sk_sp<SkPixelRef> pixel_ref_; |
62 UIResourceFormat format_; | 67 UIResourceFormat format_; |
63 gfx::Size size_; | 68 gfx::Size size_; |
64 bool opaque_; | 69 bool opaque_; |
65 }; | 70 }; |
66 | 71 |
67 class CC_EXPORT AutoLockUIResourceBitmap { | 72 class CC_EXPORT AutoLockUIResourceBitmap { |
68 public: | 73 public: |
69 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap); | 74 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap); |
70 ~AutoLockUIResourceBitmap(); | 75 ~AutoLockUIResourceBitmap(); |
71 const uint8_t* GetPixels() const; | 76 const uint8_t* GetPixels() const; |
72 | 77 |
73 private: | 78 private: |
74 const UIResourceBitmap& bitmap_; | 79 const UIResourceBitmap& bitmap_; |
75 }; | 80 }; |
76 | 81 |
77 } // namespace cc | 82 } // namespace cc |
78 | 83 |
79 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ | 84 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
OLD | NEW |