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 #include "SkRWBuffer.h" | 8 #include "SkRWBuffer.h" |
9 #include "SkStream.h" | 9 #include "SkStream.h" |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 fRemaining -= this->size(); | 161 fRemaining -= this->size(); |
162 fBlock = fBlock->fNext; | 162 fBlock = fBlock->fNext; |
163 } | 163 } |
164 return fRemaining != 0; | 164 return fRemaining != 0; |
165 } | 165 } |
166 | 166 |
167 SkRWBuffer::SkRWBuffer(size_t initialCapacity) : fHead(nullptr), fTail(nullptr),
fTotalUsed(0) {} | 167 SkRWBuffer::SkRWBuffer(size_t initialCapacity) : fHead(nullptr), fTail(nullptr),
fTotalUsed(0) {} |
168 | 168 |
169 SkRWBuffer::~SkRWBuffer() { | 169 SkRWBuffer::~SkRWBuffer() { |
170 this->validate(); | 170 this->validate(); |
171 fHead->unref(); | 171 if (fHead) { |
| 172 fHead->unref(); |
| 173 } |
172 } | 174 } |
173 | 175 |
174 void SkRWBuffer::append(const void* src, size_t length) { | 176 void SkRWBuffer::append(const void* src, size_t length) { |
175 this->validate(); | 177 this->validate(); |
176 if (0 == length) { | 178 if (0 == length) { |
177 return; | 179 return; |
178 } | 180 } |
179 | 181 |
180 fTotalUsed += length; | 182 fTotalUsed += length; |
181 | 183 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 const SkROBuffer* fBuffer; | 345 const SkROBuffer* fBuffer; |
344 SkROBuffer::Iter fIter; | 346 SkROBuffer::Iter fIter; |
345 size_t fLocalOffset; | 347 size_t fLocalOffset; |
346 size_t fGlobalOffset; | 348 size_t fGlobalOffset; |
347 }; | 349 }; |
348 | 350 |
349 SkStreamAsset* SkRWBuffer::newStreamSnapshot() const { | 351 SkStreamAsset* SkRWBuffer::newStreamSnapshot() const { |
350 SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot()); | 352 SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot()); |
351 return new SkROBufferStreamAsset(buffer); | 353 return new SkROBufferStreamAsset(buffer); |
352 } | 354 } |
OLD | NEW |