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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
9 #include "SkRWBuffer.h" | 9 #include "SkRWBuffer.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 fHead->validate(fAvailable); | 135 fHead->validate(fAvailable); |
136 fHead->unref(); | 136 fHead->unref(); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 SkROBuffer::Iter::Iter(const SkROBuffer* buffer) { | 140 SkROBuffer::Iter::Iter(const SkROBuffer* buffer) { |
141 this->reset(buffer); | 141 this->reset(buffer); |
142 } | 142 } |
143 | 143 |
144 void SkROBuffer::Iter::reset(const SkROBuffer* buffer) { | 144 void SkROBuffer::Iter::reset(const SkROBuffer* buffer) { |
145 if (buffer) { | 145 if (buffer && buffer->fHead) { |
146 fBlock = &buffer->fHead->fBlock; | 146 fBlock = &buffer->fHead->fBlock; |
147 fRemaining = buffer->fAvailable; | 147 fRemaining = buffer->fAvailable; |
148 } else { | 148 } else { |
149 fBlock = nullptr; | 149 fBlock = nullptr; |
150 fRemaining = 0; | 150 fRemaining = 0; |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 const void* SkROBuffer::Iter::data() const { | 154 const void* SkROBuffer::Iter::data() const { |
155 return fRemaining ? fBlock->startData() : nullptr; | 155 return fRemaining ? fBlock->startData() : nullptr; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 const SkROBuffer* fBuffer; | 335 const SkROBuffer* fBuffer; |
336 SkROBuffer::Iter fIter; | 336 SkROBuffer::Iter fIter; |
337 size_t fLocalOffset; | 337 size_t fLocalOffset; |
338 size_t fGlobalOffset; | 338 size_t fGlobalOffset; |
339 }; | 339 }; |
340 | 340 |
341 SkStreamAsset* SkRWBuffer::newStreamSnapshot() const { | 341 SkStreamAsset* SkRWBuffer::newStreamSnapshot() const { |
342 SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot()); | 342 SkAutoTUnref<SkROBuffer> buffer(this->newRBufferSnapshot()); |
343 return new SkROBufferStreamAsset(buffer); | 343 return new SkROBufferStreamAsset(buffer); |
344 } | 344 } |
OLD | NEW |