OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 #ifndef SkStream_DEFINED | 8 #ifndef SkStream_DEFINED |
9 #define SkStream_DEFINED | 9 #define SkStream_DEFINED |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 * always return all N bytes of the request if possible. If they return fewer | 33 * always return all N bytes of the request if possible. If they return fewer |
34 * (the read() call returns the number of bytes read) then that means there is | 34 * (the read() call returns the number of bytes read) then that means there is |
35 * no more data (at EOF or hit an error). The caller should *not* call again | 35 * no more data (at EOF or hit an error). The caller should *not* call again |
36 * in hopes of fulfilling more of the request. | 36 * in hopes of fulfilling more of the request. |
37 */ | 37 */ |
38 class SK_API SkStream : public SkNoncopyable { | 38 class SK_API SkStream : public SkNoncopyable { |
39 public: | 39 public: |
40 virtual ~SkStream() {} | 40 virtual ~SkStream() {} |
41 | 41 |
42 /** | 42 /** |
43 * Attempts to open the specified file as a stream, returns nullptr on fail
ure. | 43 * Attempts to open the specified file, and return a stream to it (using |
| 44 * mmap if available). On success, the caller is responsible for deleting. |
| 45 * On failure, returns NULL. |
44 */ | 46 */ |
45 static std::unique_ptr<SkStreamAsset> MakeFromFile(const char path[]); | 47 static SkStreamAsset* NewFromFile(const char path[]); |
46 | 48 |
47 /** Reads or skips size number of bytes. | 49 /** Reads or skips size number of bytes. |
48 * If buffer == NULL, skip size bytes, return how many were skipped. | 50 * If buffer == NULL, skip size bytes, return how many were skipped. |
49 * If buffer != NULL, copy size bytes into buffer, return how many were cop
ied. | 51 * If buffer != NULL, copy size bytes into buffer, return how many were cop
ied. |
50 * @param buffer when NULL skip size bytes, otherwise copy size bytes into
buffer | 52 * @param buffer when NULL skip size bytes, otherwise copy size bytes into
buffer |
51 * @param size the number of bytes to skip or copy | 53 * @param size the number of bytes to skip or copy |
52 * @return the number of bytes actually read. | 54 * @return the number of bytes actually read. |
53 */ | 55 */ |
54 virtual size_t read(void* buffer, size_t size) = 0; | 56 virtual size_t read(void* buffer, size_t size) = 0; |
55 | 57 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 460 |
459 private: | 461 private: |
460 size_t fBytesWritten; | 462 size_t fBytesWritten; |
461 typedef SkWStream INHERITED; | 463 typedef SkWStream INHERITED; |
462 }; | 464 }; |
463 | 465 |
464 // for now | 466 // for now |
465 typedef SkFILEStream SkURLStream; | 467 typedef SkFILEStream SkURLStream; |
466 | 468 |
467 #endif | 469 #endif |
OLD | NEW |