| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 SkRWBuffer_DEFINED | 8 #ifndef SkRWBuffer_DEFINED |
| 9 #define SkRWBuffer_DEFINED | 9 #define SkRWBuffer_DEFINED |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 * The growth is done such that at any time in the writer's thread, an RBuffer
or StreamAsset | 72 * The growth is done such that at any time in the writer's thread, an RBuffer
or StreamAsset |
| 73 * can be snapped off (and safely passed to another thread). The RBuffer/Stream
Asset snapshot | 73 * can be snapped off (and safely passed to another thread). The RBuffer/Stream
Asset snapshot |
| 74 * can see the previously stored bytes, but will be unaware of any future write
s. | 74 * can see the previously stored bytes, but will be unaware of any future write
s. |
| 75 */ | 75 */ |
| 76 class SK_API SkRWBuffer { | 76 class SK_API SkRWBuffer { |
| 77 public: | 77 public: |
| 78 SkRWBuffer(size_t initialCapacity = 0); | 78 SkRWBuffer(size_t initialCapacity = 0); |
| 79 ~SkRWBuffer(); | 79 ~SkRWBuffer(); |
| 80 | 80 |
| 81 size_t size() const { return fTotalUsed; } | 81 size_t size() const { return fTotalUsed; } |
| 82 void append(const void* buffer, size_t length); | 82 |
| 83 /** |
| 84 * Append |length| bytes from |buffer|. |
| 85 * |
| 86 * If the caller knows in advance how much more data they are going to appe
nd, they can |
| 87 * pass a |reserve| hint (representing the number of upcoming bytes *in add
ition* to the |
| 88 * current append), to minimize the number of internal allocations. |
| 89 */ |
| 90 void append(const void* buffer, size_t length, size_t reserve = 0); |
| 83 | 91 |
| 84 SkROBuffer* newRBufferSnapshot() const; | 92 SkROBuffer* newRBufferSnapshot() const; |
| 85 SkStreamAsset* newStreamSnapshot() const; | 93 SkStreamAsset* newStreamSnapshot() const; |
| 86 | 94 |
| 87 #ifdef SK_DEBUG | 95 #ifdef SK_DEBUG |
| 88 void validate() const; | 96 void validate() const; |
| 89 #else | 97 #else |
| 90 void validate() const {} | 98 void validate() const {} |
| 91 #endif | 99 #endif |
| 92 | 100 |
| 93 private: | 101 private: |
| 94 SkBufferHead* fHead; | 102 SkBufferHead* fHead; |
| 95 SkBufferBlock* fTail; | 103 SkBufferBlock* fTail; |
| 96 size_t fTotalUsed; | 104 size_t fTotalUsed; |
| 97 }; | 105 }; |
| 98 | 106 |
| 99 #endif | 107 #endif |
| OLD | NEW |