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

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: Move to SkPictureUtils, start unit test Created 6 years, 3 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 /* 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 T* replace(unsigned i, const SkRecords::Adopted<Existing>& proofOfAdoption) { 103 T* replace(unsigned i, const SkRecords::Adopted<Existing>& proofOfAdoption) {
104 SkASSERT(i < this->count()); 104 SkASSERT(i < this->count());
105 105
106 SkASSERT(Existing::kType == fTypes[i]); 106 SkASSERT(Existing::kType == fTypes[i]);
107 SkASSERT(proofOfAdoption == fRecords[i].ptr<Existing>()); 107 SkASSERT(proofOfAdoption == fRecords[i].ptr<Existing>());
108 108
109 fTypes[i] = T::kType; 109 fTypes[i] = T::kType;
110 return fRecords[i].set(this->allocCommand<T>()); 110 return fRecords[i].set(this->allocCommand<T>());
111 } 111 }
112 112
113 size_t bytesUsed() const { return fAlloc.totalCapacity() +
mtklein 2014/11/17 20:19:32 fAlloc doesn't know how large it is any more, so y
114 fReserved * (sizeof(Record) + sizeof(Type8 )) +
115 sizeof(SkRecord); }
116
113 private: 117 private:
114 // Implementation notes! 118 // Implementation notes!
115 // 119 //
116 // Logically an SkRecord is structured as an array of pointers into a big ch unk of memory where 120 // Logically an SkRecord is structured as an array of pointers into a big ch unk of memory where
117 // records representing each canvas draw call are stored: 121 // records representing each canvas draw call are stored:
118 // 122 //
119 // fRecords: [*][*][*]... 123 // fRecords: [*][*][*]...
120 // | | | 124 // | | |
121 // | | | 125 // | | |
122 // | | +---------------------------------------+ 126 // | | +---------------------------------------+
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 SkChunkAlloc fAlloc; 229 SkChunkAlloc fAlloc;
226 SkAutoTMalloc<Record> fRecords; 230 SkAutoTMalloc<Record> fRecords;
227 SkAutoTMalloc<Type8> fTypes; 231 SkAutoTMalloc<Type8> fTypes;
228 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step. 232 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step.
229 unsigned fCount; 233 unsigned fCount;
230 unsigned fReserved; 234 unsigned fReserved;
231 const unsigned kFirstReserveCount; 235 const unsigned kFirstReserveCount;
232 }; 236 };
233 237
234 #endif//SkRecord_DEFINED 238 #endif//SkRecord_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698