OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 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 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return new SkMemoryStream(); | 234 return new SkMemoryStream(); |
235 } | 235 } |
236 | 236 |
237 if (fData.get()) { | 237 if (fData.get()) { |
238 return new SkMemoryStream(fData); | 238 return new SkMemoryStream(fData); |
239 } | 239 } |
240 | 240 |
241 if (!fName.isEmpty()) { | 241 if (!fName.isEmpty()) { |
242 SkAutoTDelete<SkFILEStream> that(new SkFILEStream(fName.c_str())); | 242 SkAutoTDelete<SkFILEStream> that(new SkFILEStream(fName.c_str())); |
243 if (sk_fidentical(that->fFILE, this->fFILE)) { | 243 if (sk_fidentical(that->fFILE, this->fFILE)) { |
244 return that.detach(); | 244 return that.release(); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 fData = SkData::MakeFromFILE(fFILE); | 248 fData = SkData::MakeFromFILE(fFILE); |
249 if (nullptr == fData) { | 249 if (nullptr == fData) { |
250 return nullptr; | 250 return nullptr; |
251 } | 251 } |
252 return new SkMemoryStream(fData); | 252 return new SkMemoryStream(fData); |
253 } | 253 } |
254 | 254 |
255 size_t SkFILEStream::getPosition() const { | 255 size_t SkFILEStream::getPosition() const { |
256 return sk_ftell(fFILE); | 256 return sk_ftell(fFILE); |
257 } | 257 } |
258 | 258 |
259 bool SkFILEStream::seek(size_t position) { | 259 bool SkFILEStream::seek(size_t position) { |
260 return sk_fseek(fFILE, position); | 260 return sk_fseek(fFILE, position); |
261 } | 261 } |
262 | 262 |
263 bool SkFILEStream::move(long offset) { | 263 bool SkFILEStream::move(long offset) { |
264 return sk_fmove(fFILE, offset); | 264 return sk_fmove(fFILE, offset); |
265 } | 265 } |
266 | 266 |
267 SkStreamAsset* SkFILEStream::fork() const { | 267 SkStreamAsset* SkFILEStream::fork() const { |
268 SkAutoTDelete<SkStreamAsset> that(this->duplicate()); | 268 SkAutoTDelete<SkStreamAsset> that(this->duplicate()); |
269 that->seek(this->getPosition()); | 269 that->seek(this->getPosition()); |
270 return that.detach(); | 270 return that.release(); |
271 } | 271 } |
272 | 272 |
273 size_t SkFILEStream::getLength() const { | 273 size_t SkFILEStream::getLength() const { |
274 return sk_fgetsize(fFILE); | 274 return sk_fgetsize(fFILE); |
275 } | 275 } |
276 | 276 |
277 const void* SkFILEStream::getMemoryBase() { | 277 const void* SkFILEStream::getMemoryBase() { |
278 if (nullptr == fData.get()) { | 278 if (nullptr == fData.get()) { |
279 return nullptr; | 279 return nullptr; |
280 } | 280 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 return true; | 396 return true; |
397 } | 397 } |
398 | 398 |
399 bool SkMemoryStream::move(long offset) { | 399 bool SkMemoryStream::move(long offset) { |
400 return this->seek(fOffset + offset); | 400 return this->seek(fOffset + offset); |
401 } | 401 } |
402 | 402 |
403 SkMemoryStream* SkMemoryStream::fork() const { | 403 SkMemoryStream* SkMemoryStream::fork() const { |
404 SkAutoTDelete<SkMemoryStream> that(this->duplicate()); | 404 SkAutoTDelete<SkMemoryStream> that(this->duplicate()); |
405 that->seek(fOffset); | 405 that->seek(fOffset); |
406 return that.detach(); | 406 return that.release(); |
407 } | 407 } |
408 | 408 |
409 size_t SkMemoryStream::getLength() const { | 409 size_t SkMemoryStream::getLength() const { |
410 return fData->size(); | 410 return fData->size(); |
411 } | 411 } |
412 | 412 |
413 const void* SkMemoryStream::getMemoryBase() { | 413 const void* SkMemoryStream::getMemoryBase() { |
414 return fData->data(); | 414 return fData->data(); |
415 } | 415 } |
416 | 416 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 | 778 |
779 bool move(long offset) override { | 779 bool move(long offset) override { |
780 return seek(fOffset + offset); | 780 return seek(fOffset + offset); |
781 } | 781 } |
782 | 782 |
783 SkBlockMemoryStream* fork() const override { | 783 SkBlockMemoryStream* fork() const override { |
784 SkAutoTDelete<SkBlockMemoryStream> that(this->duplicate()); | 784 SkAutoTDelete<SkBlockMemoryStream> that(this->duplicate()); |
785 that->fCurrent = this->fCurrent; | 785 that->fCurrent = this->fCurrent; |
786 that->fOffset = this->fOffset; | 786 that->fOffset = this->fOffset; |
787 that->fCurrentOffset = this->fCurrentOffset; | 787 that->fCurrentOffset = this->fCurrentOffset; |
788 return that.detach(); | 788 return that.release(); |
789 } | 789 } |
790 | 790 |
791 size_t getLength() const override { | 791 size_t getLength() const override { |
792 return fSize; | 792 return fSize; |
793 } | 793 } |
794 | 794 |
795 const void* getMemoryBase() override { | 795 const void* getMemoryBase() override { |
796 if (nullptr != fBlockMemory->fHead && | 796 if (nullptr != fBlockMemory->fHead && |
797 nullptr == fBlockMemory->fHead->fNext) { | 797 nullptr == fBlockMemory->fHead->fNext) { |
798 return fBlockMemory->fHead->start(); | 798 return fBlockMemory->fHead->start(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 while (true) { | 906 while (true) { |
907 count = input->read(scratch, sizeof(scratch)); | 907 count = input->read(scratch, sizeof(scratch)); |
908 if (0 == count) { | 908 if (0 == count) { |
909 return true; | 909 return true; |
910 } | 910 } |
911 if (!out->write(scratch, count)) { | 911 if (!out->write(scratch, count)) { |
912 return false; | 912 return false; |
913 } | 913 } |
914 } | 914 } |
915 } | 915 } |
OLD | NEW |