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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 operator SkRecords::Type () { return (SkRecords::Type)fType; } | 160 operator SkRecords::Type () { return (SkRecords::Type)fType; } |
161 | 161 |
162 private: | 162 private: |
163 uint8_t fType; | 163 uint8_t fType; |
164 }; | 164 }; |
165 | 165 |
166 // No point in allocating any more than one of an empty struct. | 166 // No point in allocating any more than one of an empty struct. |
167 // We could just return NULL but it's sort of confusing to return NULL on su
ccess. | 167 // We could just return NULL but it's sort of confusing to return NULL on su
ccess. |
168 template <typename T> | 168 template <typename T> |
169 SK_WHEN(SkTIsEmpty<T>, T*) allocCommand() { | 169 SK_WHEN(SkTIsEmpty<T>, T*) allocCommand() { |
170 static T singleton = {}; | 170 static T singleton; |
171 return &singleton; | 171 return &singleton; |
172 } | 172 } |
173 | 173 |
174 template <typename T> | 174 template <typename T> |
175 SK_WHEN(!SkTIsEmpty<T>, T*) allocCommand() { return this->alloc<T>(); } | 175 SK_WHEN(!SkTIsEmpty<T>, T*) allocCommand() { return this->alloc<T>(); } |
176 | 176 |
177 // An untyped pointer to some bytes in fAlloc. This is the interface for po
lymorphic dispatch: | 177 // An untyped pointer to some bytes in fAlloc. This is the interface for po
lymorphic dispatch: |
178 // visit() and mutate() work with the parallel fTypes array to do the work o
f a vtable. | 178 // visit() and mutate() work with the parallel fTypes array to do the work o
f a vtable. |
179 struct Record { | 179 struct Record { |
180 public: | 180 public: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 SkChunkAlloc fAlloc; | 220 SkChunkAlloc fAlloc; |
221 SkAutoTMalloc<Record> fRecords; | 221 SkAutoTMalloc<Record> fRecords; |
222 SkAutoTMalloc<Type8> fTypes; | 222 SkAutoTMalloc<Type8> fTypes; |
223 // fCount and fReserved measure both fRecords and fTypes, which always grow
in lock step. | 223 // fCount and fReserved measure both fRecords and fTypes, which always grow
in lock step. |
224 unsigned fCount; | 224 unsigned fCount; |
225 unsigned fReserved; | 225 unsigned fReserved; |
226 const unsigned kFirstReserveCount; | 226 const unsigned kFirstReserveCount; |
227 }; | 227 }; |
228 | 228 |
229 #endif//SkRecord_DEFINED | 229 #endif//SkRecord_DEFINED |
OLD | NEW |