| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 | 358 |
| 359 SkData* SkMemoryStream::setData(SkData* data) { | 359 SkData* SkMemoryStream::setData(SkData* data) { |
| 360 fData->unref(); | 360 fData->unref(); |
| 361 if (NULL == data) { | 361 if (NULL == data) { |
| 362 fData = SkData::NewEmpty(); | 362 fData = SkData::NewEmpty(); |
| 363 } else { | 363 } else { |
| 364 fData = data; | 364 fData = data; |
| 365 fData->ref(); | 365 fData->ref(); |
| 366 } | 366 } |
| 367 fOffset = 0; |
| 367 return data; | 368 return data; |
| 368 } | 369 } |
| 369 | 370 |
| 370 void SkMemoryStream::skipToAlign4() { | 371 void SkMemoryStream::skipToAlign4() { |
| 371 // cast to remove unary-minus warning | 372 // cast to remove unary-minus warning |
| 372 fOffset += -(int)fOffset & 0x03; | 373 fOffset += -(int)fOffset & 0x03; |
| 373 } | 374 } |
| 374 | 375 |
| 375 size_t SkMemoryStream::read(void* buffer, size_t size) { | 376 size_t SkMemoryStream::read(void* buffer, size_t size) { |
| 376 size_t dataSize = fData->size(); | 377 size_t dataSize = fData->size(); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 | 838 |
| 838 // If we get here, then our attempt at using mmap failed, so try normal | 839 // If we get here, then our attempt at using mmap failed, so try normal |
| 839 // file access. | 840 // file access. |
| 840 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); | 841 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); |
| 841 if (!stream->isValid()) { | 842 if (!stream->isValid()) { |
| 842 stream->unref(); | 843 stream->unref(); |
| 843 stream = NULL; | 844 stream = NULL; |
| 844 } | 845 } |
| 845 return stream; | 846 return stream; |
| 846 } | 847 } |
| OLD | NEW |