| 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 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 Loading... |
| 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 |
| OLD | NEW |