OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkDataTable_DEFINED | 8 #ifndef SkDataTable_DEFINED |
9 #define SkDataTable_DEFINED | 9 #define SkDataTable_DEFINED |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 */ | 56 */ |
57 const char* atStr(int index) const { | 57 const char* atStr(int index) const { |
58 size_t size; | 58 size_t size; |
59 const char* str = this->atT<const char>(index, &size); | 59 const char* str = this->atT<const char>(index, &size); |
60 SkASSERT(strlen(str) + 1 == size); | 60 SkASSERT(strlen(str) + 1 == size); |
61 return str; | 61 return str; |
62 } | 62 } |
63 | 63 |
64 typedef void (*FreeProc)(void* context); | 64 typedef void (*FreeProc)(void* context); |
65 | 65 |
66 static SkDataTable* NewEmpty(); | 66 static sk_sp<SkDataTable> MakeEmpty(); |
67 | 67 |
68 /** | 68 /** |
69 * Return a new DataTable that contains a copy of the data stored in each | 69 * Return a new DataTable that contains a copy of the data stored in each |
70 * "array". | 70 * "array". |
71 * | 71 * |
72 * @param ptrs array of points to each element to be copied into the table. | 72 * @param ptrs array of points to each element to be copied into the table. |
73 * @param sizes array of byte-lengths for each entry in the corresponding | 73 * @param sizes array of byte-lengths for each entry in the corresponding |
74 * ptrs[] array. | 74 * ptrs[] array. |
75 * @param count the number of array elements in ptrs[] and sizes[] to copy. | 75 * @param count the number of array elements in ptrs[] and sizes[] to copy. |
76 */ | 76 */ |
77 static SkDataTable* NewCopyArrays(const void * const * ptrs, | 77 static sk_sp<SkDataTable> MakeCopyArrays(const void * const * ptrs, |
78 const size_t sizes[], int count); | 78 const size_t sizes[], int count); |
79 | 79 |
80 /** | 80 /** |
81 * Return a new table that contains a copy of the data in array. | 81 * Return a new table that contains a copy of the data in array. |
82 * | 82 * |
83 * @param array contiguous array of data for all elements to be copied. | 83 * @param array contiguous array of data for all elements to be copied. |
84 * @param elemSize byte-length for a given element. | 84 * @param elemSize byte-length for a given element. |
85 * @param count the number of entries to be copied out of array. The number | 85 * @param count the number of entries to be copied out of array. The number |
86 * of bytes that will be copied is count * elemSize. | 86 * of bytes that will be copied is count * elemSize. |
87 */ | 87 */ |
88 static SkDataTable* NewCopyArray(const void* array, size_t elemSize, | 88 static sk_sp<SkDataTable> MakeCopyArray(const void* array, size_t elemSize,
int count); |
89 int count); | |
90 | 89 |
91 static SkDataTable* NewArrayProc(const void* array, size_t elemSize, | 90 static sk_sp<SkDataTable> MakeArrayProc(const void* array, size_t elemSize,
int count, |
92 int count, FreeProc proc, void* context); | 91 FreeProc proc, void* context); |
93 | 92 |
94 private: | 93 private: |
95 struct Dir { | 94 struct Dir { |
96 const void* fPtr; | 95 const void* fPtr; |
97 uintptr_t fSize; | 96 uintptr_t fSize; |
98 }; | 97 }; |
99 | 98 |
100 int fCount; | 99 int fCount; |
101 size_t fElemSize; | 100 size_t fElemSize; |
102 union { | 101 union { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 */ | 156 */ |
158 void appendString(const SkString& string) { | 157 void appendString(const SkString& string) { |
159 this->append(string.c_str(), string.size() + 1); | 158 this->append(string.c_str(), string.size() + 1); |
160 } | 159 } |
161 | 160 |
162 /** | 161 /** |
163 * Return an SkDataTable from the accumulated entries that were added by | 162 * Return an SkDataTable from the accumulated entries that were added by |
164 * calls to append(). This call also clears any accumluated entries from | 163 * calls to append(). This call also clears any accumluated entries from |
165 * this builder, so its count() will be 0 after this call. | 164 * this builder, so its count() will be 0 after this call. |
166 */ | 165 */ |
167 SkDataTable* detachDataTable(); | 166 sk_sp<SkDataTable> detachDataTable(); |
168 | 167 |
169 private: | 168 private: |
170 SkTDArray<SkDataTable::Dir> fDir; | 169 SkTDArray<SkDataTable::Dir> fDir; |
171 SkChunkAlloc* fHeap; | 170 SkChunkAlloc* fHeap; |
172 size_t fMinChunkSize; | 171 size_t fMinChunkSize; |
173 }; | 172 }; |
174 | 173 |
175 #endif | 174 #endif |
OLD | NEW |