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

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

Issue 2440393002: [tracing] Implement composable memory usage estimators. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/scoped_ui_resource.h ('k') | ui/android/resources/crushed_sprite_resource.h » ('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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 54 // Returns the memory usage of the bitmap.
55 size_t GetAllocatedSizeInBytes() const { 55 size_t EstimateMemoryUsage() const {
56 return pixel_ref_ ? pixel_ref_->rowBytes() * size_.height() : 0; 56 return pixel_ref_ ? pixel_ref_->rowBytes() * size_.height() : 0;
57 } 57 }
58 58
59 private: 59 private:
60 friend class AutoLockUIResourceBitmap; 60 friend class AutoLockUIResourceBitmap;
61 61
62 void Create(sk_sp<SkPixelRef> pixel_ref, 62 void Create(sk_sp<SkPixelRef> pixel_ref,
63 const gfx::Size& size, 63 const gfx::Size& size,
64 UIResourceFormat format); 64 UIResourceFormat format);
65 65
66 sk_sp<SkPixelRef> pixel_ref_; 66 sk_sp<SkPixelRef> pixel_ref_;
67 UIResourceFormat format_; 67 UIResourceFormat format_;
68 gfx::Size size_; 68 gfx::Size size_;
69 bool opaque_; 69 bool opaque_;
70 }; 70 };
71 71
72 class CC_EXPORT AutoLockUIResourceBitmap { 72 class CC_EXPORT AutoLockUIResourceBitmap {
73 public: 73 public:
74 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap); 74 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap);
75 ~AutoLockUIResourceBitmap(); 75 ~AutoLockUIResourceBitmap();
76 const uint8_t* GetPixels() const; 76 const uint8_t* GetPixels() const;
77 77
78 private: 78 private:
79 const UIResourceBitmap& bitmap_; 79 const UIResourceBitmap& bitmap_;
80 }; 80 };
81 81
82 } // namespace cc 82 } // namespace cc
83 83
84 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 84 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_
OLDNEW
« no previous file with comments | « cc/resources/scoped_ui_resource.h ('k') | ui/android/resources/crushed_sprite_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698