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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 virtual ~SkROBuffer(); | 60 virtual ~SkROBuffer(); |
61 | 61 |
62 const SkBufferHead* fHead; | 62 const SkBufferHead* fHead; |
63 const size_t fAvailable; | 63 const size_t fAvailable; |
64 | 64 |
65 friend class SkRWBuffer; | 65 friend class SkRWBuffer; |
66 }; | 66 }; |
67 | 67 |
68 /** | 68 /** |
69 * Accumulates bytes of memory that are "appended" to it, growing internal stor
age as needed. | 69 * Accumulates bytes of memory that are "appended" to it, growing internal stor
age as needed. |
70 * The growth is done such that at any time in the writer's thread, an RBuffer
or StreamAsset | 70 * The growth is done such that at any time, a RBuffer or StreamAsset can be sn
apped off, which |
71 * can be snapped off (and safely passed to another thread). The RBuffer/Stream
Asset snapshot | 71 * can see the previously stored bytes, but which will be unaware of any future
writes. |
72 * can see the previously stored bytes, but will be unaware of any future write
s. | |
73 */ | 72 */ |
74 class SK_API SkRWBuffer { | 73 class SK_API SkRWBuffer { |
75 public: | 74 public: |
76 SkRWBuffer(size_t initialCapacity = 0); | 75 SkRWBuffer(size_t initialCapacity = 0); |
77 ~SkRWBuffer(); | 76 ~SkRWBuffer(); |
78 | 77 |
79 size_t size() const { return fTotalUsed; } | 78 size_t size() const { return fTotalUsed; } |
80 void append(const void* buffer, size_t length); | 79 void append(const void* buffer, size_t length); |
81 | 80 |
82 SkROBuffer* newRBufferSnapshot() const; | 81 SkROBuffer* newRBufferSnapshot() const; |
83 SkStreamAsset* newStreamSnapshot() const; | 82 SkStreamAsset* newStreamSnapshot() const; |
84 | 83 |
85 #ifdef SK_DEBUG | 84 #ifdef SK_DEBUG |
86 void validate() const; | 85 void validate() const; |
87 #else | 86 #else |
88 void validate() const {} | 87 void validate() const {} |
89 #endif | 88 #endif |
90 | 89 |
91 private: | 90 private: |
92 SkBufferHead* fHead; | 91 SkBufferHead* fHead; |
93 SkBufferBlock* fTail; | 92 SkBufferBlock* fTail; |
94 size_t fTotalUsed; | 93 size_t fTotalUsed; |
95 }; | 94 }; |
96 | 95 |
97 #endif | 96 #endif |
OLD | NEW |