| 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 27 matching lines...) Expand all Loading... |
| 38 : fHead(NULL) | 38 : fHead(NULL) |
| 39 , fTail(NULL) | 39 , fTail(NULL) |
| 40 , fMinSize(minSize) | 40 , fMinSize(minSize) |
| 41 , fSize(0) | 41 , fSize(0) |
| 42 , fWrittenBeforeLastBlock(0) | 42 , fWrittenBeforeLastBlock(0) |
| 43 {} | 43 {} |
| 44 | 44 |
| 45 ~SkWriter32(); | 45 ~SkWriter32(); |
| 46 | 46 |
| 47 // return the current offset (will always be a multiple of 4) | 47 // return the current offset (will always be a multiple of 4) |
| 48 uint32_t bytesWritten() const { return fSize; } | 48 size_t bytesWritten() const { return fSize; } |
| 49 // DEPRECATED: use bytesWritten instead TODO(mtklein): clean up | 49 // DEPRECATED: use bytesWritten instead TODO(mtklein): clean up |
| 50 uint32_t size() const { return this->bytesWritten(); } | 50 size_t size() const { return this->bytesWritten(); } |
| 51 | 51 |
| 52 // Returns true if we've written only into the storage passed into construct
or or reset. | 52 // Returns true if we've written only into the storage passed into construct
or or reset. |
| 53 // (You may be able to use this to avoid a call to flatten.) | 53 // (You may be able to use this to avoid a call to flatten.) |
| 54 bool wroteOnlyToStorage() const { | 54 bool wroteOnlyToStorage() const { |
| 55 return fHead == &fExternalBlock && this->bytesWritten() <= fExternalBloc
k.fSizeOfBlock; | 55 return fHead == &fExternalBlock && this->bytesWritten() <= fExternalBloc
k.fSizeOfBlock; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void reset(); | 58 void reset(); |
| 59 void reset(void* storage, size_t size); | 59 void reset(void* storage, size_t size); |
| 60 | 60 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 enum { | 263 enum { |
| 264 MIN_BLOCKSIZE = sizeof(SkWriter32::Block) + sizeof(intptr_t) | 264 MIN_BLOCKSIZE = sizeof(SkWriter32::Block) + sizeof(intptr_t) |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 Block fExternalBlock; | 267 Block fExternalBlock; |
| 268 Block* fHead; | 268 Block* fHead; |
| 269 Block* fTail; | 269 Block* fTail; |
| 270 size_t fMinSize; | 270 size_t fMinSize; |
| 271 uint32_t fSize; | 271 size_t fSize; |
| 272 // sum of bytes written in all blocks *before* fTail | 272 // sum of bytes written in all blocks *before* fTail |
| 273 uint32_t fWrittenBeforeLastBlock; | 273 size_t fWrittenBeforeLastBlock; |
| 274 | 274 |
| 275 bool isHeadExternallyAllocated() const { | 275 bool isHeadExternallyAllocated() const { |
| 276 return fHead == &fExternalBlock; | 276 return fHead == &fExternalBlock; |
| 277 } | 277 } |
| 278 | 278 |
| 279 Block* newBlock(size_t bytes); | 279 Block* newBlock(size_t bytes); |
| 280 | 280 |
| 281 // only call from reserve() | 281 // only call from reserve() |
| 282 Block* doReserve(size_t bytes); | 282 Block* doReserve(size_t bytes); |
| 283 | 283 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 296 | 296 |
| 297 private: | 297 private: |
| 298 union { | 298 union { |
| 299 void* fPtrAlignment; | 299 void* fPtrAlignment; |
| 300 double fDoubleAlignment; | 300 double fDoubleAlignment; |
| 301 char fStorage[SIZE]; | 301 char fStorage[SIZE]; |
| 302 } fData; | 302 } fData; |
| 303 }; | 303 }; |
| 304 | 304 |
| 305 #endif | 305 #endif |
| OLD | NEW |