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

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

Issue 2406103002: [tracing] Add memory usage of Android UI resources to memory-infra (Closed)
Patch Set: nit. Created 4 years, 2 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 BytesUsed() const {
56 return pixel_ref_ ? pixel_ref_->rowBytes() * size_.height() : 0;
David Trainor- moved to gerrit 2016/10/13 04:07:21 Would pixel_ref_->getAllocatedSizeInBytes() be mor
ssid 2016/10/13 17:45:16 Done.
ssid 2016/10/13 18:54:48 Sorry I misunderstood. Yes, I am planning to make
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698