OLD | NEW |
---|---|
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 Loading... | |
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 // support efficient random access and forward iteration. (They don't need to be contiguous.) | 232 // support efficient random access and forward iteration. (They don't need to be contiguous.) |
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 |
mtklein
2014/11/18 21:38:32
oh snap
tomhudson
2014/11/18 21:49:37
Sigh, I guess there is no standard spec here? SkCa
mtklein
2014/11/18 21:54:35
Goodness, why would we ever have a standard spec f
| |
OLD | NEW |