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

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: Fix minor edit error in SkTileGrid::bytesUsed 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
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 size_t bytesUsed() const { return fAlloc.approxBytesAllocated() +
117 fReserved * (sizeof(Record) + sizeof(Type8 )) +
118 sizeof(SkRecord); }
119
116 private: 120 private:
117 // Implementation notes! 121 // Implementation notes!
118 // 122 //
119 // Logically an SkRecord is structured as an array of pointers into a big ch unk of memory where 123 // 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: 124 // records representing each canvas draw call are stored:
121 // 125 //
122 // fRecords: [*][*][*]... 126 // fRecords: [*][*][*]...
123 // | | | 127 // | | |
124 // | | | 128 // | | |
125 // | | +---------------------------------------+ 129 // | | +---------------------------------------+
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 231
228 SkVarAlloc fAlloc; 232 SkVarAlloc fAlloc;
229 SkAutoTMalloc<Record> fRecords; 233 SkAutoTMalloc<Record> fRecords;
230 SkAutoTMalloc<Type8> fTypes; 234 SkAutoTMalloc<Type8> fTypes;
231 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step. 235 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step.
232 unsigned fCount; 236 unsigned fCount;
233 unsigned fReserved; 237 unsigned fReserved;
234 }; 238 };
235 239
236 #endif//SkRecord_DEFINED 240 #endif//SkRecord_DEFINED
OLDNEW
« src/core/SkRTree.h ('K') | « src/core/SkRTree.cpp ('k') | src/core/SkTileGrid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698