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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 fFILE = NULL; | 248 fFILE = NULL; |
249 } | 249 } |
250 return false; | 250 return false; |
251 } | 251 } |
252 | 252 |
253 SkStreamAsset* SkFILEStream::duplicate() const { | 253 SkStreamAsset* SkFILEStream::duplicate() const { |
254 if (NULL == fFILE) { | 254 if (NULL == fFILE) { |
255 return new SkMemoryStream(); | 255 return new SkMemoryStream(); |
256 } | 256 } |
257 | 257 |
258 if (NULL != fData.get()) { | 258 if (fData.get()) { |
259 return new SkMemoryStream(fData); | 259 return new SkMemoryStream(fData); |
260 } | 260 } |
261 | 261 |
262 if (!fName.isEmpty()) { | 262 if (!fName.isEmpty()) { |
263 SkAutoTUnref<SkFILEStream> that(new SkFILEStream(fName.c_str())); | 263 SkAutoTUnref<SkFILEStream> that(new SkFILEStream(fName.c_str())); |
264 if (sk_fidentical(that->fFILE, this->fFILE)) { | 264 if (sk_fidentical(that->fFILE, this->fFILE)) { |
265 return that.detach(); | 265 return that.detach(); |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 SkDynamicMemoryWStream tempStream; | 932 SkDynamicMemoryWStream tempStream; |
933 const size_t bufferSize = 4096; | 933 const size_t bufferSize = 4096; |
934 char buffer[bufferSize]; | 934 char buffer[bufferSize]; |
935 do { | 935 do { |
936 size_t bytesRead = stream->read(buffer, bufferSize); | 936 size_t bytesRead = stream->read(buffer, bufferSize); |
937 tempStream.write(buffer, bytesRead); | 937 tempStream.write(buffer, bytesRead); |
938 } while (!stream->isAtEnd()); | 938 } while (!stream->isAtEnd()); |
939 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream, | 939 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream, |
940 // cheaper than copying to SkData | 940 // cheaper than copying to SkData |
941 } | 941 } |
OLD | NEW |