| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkWriter32_DEFINED | 10 #ifndef SkWriter32_DEFINED |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 */ | 199 */ |
| 200 void writeString(const char* str, size_t len = (size_t)-1); | 200 void writeString(const char* str, size_t len = (size_t)-1); |
| 201 | 201 |
| 202 /** | 202 /** |
| 203 * Computes the size (aligned to multiple of 4) need to write the string | 203 * Computes the size (aligned to multiple of 4) need to write the string |
| 204 * in a call to writeString(). If the length is not specified, it will be | 204 * in a call to writeString(). If the length is not specified, it will be |
| 205 * computed by calling strlen(). | 205 * computed by calling strlen(). |
| 206 */ | 206 */ |
| 207 static size_t WriteStringSize(const char* str, size_t len = (size_t)-1); | 207 static size_t WriteStringSize(const char* str, size_t len = (size_t)-1); |
| 208 | 208 |
| 209 void writeData(const SkData* data) { | |
| 210 uint32_t len = data ? SkToU32(data->size()) : 0; | |
| 211 this->write32(len); | |
| 212 if (data) { | |
| 213 this->writePad(data->data(), len); | |
| 214 } | |
| 215 } | |
| 216 | |
| 217 static size_t WriteDataSize(const SkData* data) { | |
| 218 return 4 + SkAlign4(data ? data->size() : 0); | |
| 219 } | |
| 220 | |
| 221 /** | 209 /** |
| 222 * Move the cursor back to offset bytes from the beginning. | 210 * Move the cursor back to offset bytes from the beginning. |
| 223 * offset must be a multiple of 4 no greater than size(). | 211 * offset must be a multiple of 4 no greater than size(). |
| 224 */ | 212 */ |
| 225 void rewindToOffset(size_t offset) { | 213 void rewindToOffset(size_t offset) { |
| 226 SkASSERT(SkAlign4(offset) == offset); | 214 SkASSERT(SkAlign4(offset) == offset); |
| 227 SkASSERT(offset <= bytesWritten()); | 215 SkASSERT(offset <= bytesWritten()); |
| 228 fUsed = offset; | 216 fUsed = offset; |
| 229 } | 217 } |
| 230 | 218 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 union { | 261 union { |
| 274 void* fPtrAlignment; | 262 void* fPtrAlignment; |
| 275 double fDoubleAlignment; | 263 double fDoubleAlignment; |
| 276 char fStorage[SIZE]; | 264 char fStorage[SIZE]; |
| 277 } fData; | 265 } fData; |
| 278 | 266 |
| 279 typedef SkWriter32 INHERITED; | 267 typedef SkWriter32 INHERITED; |
| 280 }; | 268 }; |
| 281 | 269 |
| 282 #endif | 270 #endif |
| OLD | NEW |