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

Side by Side Diff: src/core/SkRecord.h

Issue 490253003: Implement SkPicture::bytesUsed() for SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More tweaks for object size Created 6 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 | « src/core/SkRTree.cpp ('k') | src/core/SkTileGrid.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 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkRecord_DEFINED 8 #ifndef SkRecord_DEFINED
9 #define SkRecord_DEFINED 9 #define SkRecord_DEFINED
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 T* replace(unsigned i, const SkRecords::Adopted<Existing>& proofOfAdoption) { 106 T* replace(unsigned i, const SkRecords::Adopted<Existing>& proofOfAdoption) {
107 SkASSERT(i < this->count()); 107 SkASSERT(i < this->count());
108 108
109 SkASSERT(Existing::kType == fTypes[i]); 109 SkASSERT(Existing::kType == fTypes[i]);
110 SkASSERT(proofOfAdoption == fRecords[i].ptr<Existing>()); 110 SkASSERT(proofOfAdoption == fRecords[i].ptr<Existing>());
111 111
112 fTypes[i] = T::kType; 112 fTypes[i] = T::kType;
113 return fRecords[i].set(this->allocCommand<T>()); 113 return fRecords[i].set(this->allocCommand<T>());
114 } 114 }
115 115
116 // Does not return the bytes in any pointers embedded in the Records; caller s
117 // need to iterate with a visitor to measure those they care for.
118 size_t bytesUsed() const { return fAlloc.approxBytesAllocated() +
119 fReserved * (sizeof(Record) + sizeof(Type8 )) +
120 sizeof(SkRecord); }
121
116 private: 122 private:
117 // Implementation notes! 123 // Implementation notes!
118 // 124 //
119 // Logically an SkRecord is structured as an array of pointers into a big ch unk of memory where 125 // Logically an SkRecord is structured as an array of pointers into a big ch unk of memory where
120 // records representing each canvas draw call are stored: 126 // records representing each canvas draw call are stored:
121 // 127 //
122 // fRecords: [*][*][*]... 128 // fRecords: [*][*][*]...
123 // | | | 129 // | | |
124 // | | | 130 // | | |
125 // | | +---------------------------------------+ 131 // | | +---------------------------------------+
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 233
228 SkVarAlloc fAlloc; 234 SkVarAlloc fAlloc;
229 SkAutoTMalloc<Record> fRecords; 235 SkAutoTMalloc<Record> fRecords;
230 SkAutoTMalloc<Type8> fTypes; 236 SkAutoTMalloc<Type8> fTypes;
231 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step. 237 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step.
232 unsigned fCount; 238 unsigned fCount;
233 unsigned fReserved; 239 unsigned fReserved;
234 }; 240 };
235 241
236 #endif//SkRecord_DEFINED 242 #endif//SkRecord_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkRTree.cpp ('k') | src/core/SkTileGrid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698