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. | |
44 */ | |
45 | |
46 static std::unique_ptr<SkStreamAsset> MakeFromFile(const char path[]); | |
47 | |
48 /** | |
43 * Attempts to open the specified file, and return a stream to it (using | 49 * 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. | 50 * mmap if available). On success, the caller is responsible for deleting. |
45 * On failure, returns NULL. | 51 * On failure, returns NULL. |
46 */ | 52 */ |
47 static SkStreamAsset* NewFromFile(const char path[]); | 53 static SkStreamAsset* NewFromFile(const char path[]) { |
reed1
2016/09/15 13:38:49
can we add a guard to deprecate/remove this versio
bungeman-skia
2016/09/15 16:35:47
I don't see anyone else using it, so I think it ca
| |
54 return SkStream::MakeFromFile(path).release(); | |
55 } | |
48 | 56 |
49 /** Reads or skips size number of bytes. | 57 /** Reads or skips size number of bytes. |
50 * If buffer == NULL, skip size bytes, return how many were skipped. | 58 * If buffer == NULL, skip size bytes, return how many were skipped. |
51 * If buffer != NULL, copy size bytes into buffer, return how many were cop ied. | 59 * If buffer != NULL, copy size bytes into buffer, return how many were cop ied. |
52 * @param buffer when NULL skip size bytes, otherwise copy size bytes into buffer | 60 * @param buffer when NULL skip size bytes, otherwise copy size bytes into buffer |
53 * @param size the number of bytes to skip or copy | 61 * @param size the number of bytes to skip or copy |
54 * @return the number of bytes actually read. | 62 * @return the number of bytes actually read. |
55 */ | 63 */ |
56 virtual size_t read(void* buffer, size_t size) = 0; | 64 virtual size_t read(void* buffer, size_t size) = 0; |
57 | 65 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 | 468 |
461 private: | 469 private: |
462 size_t fBytesWritten; | 470 size_t fBytesWritten; |
463 typedef SkWStream INHERITED; | 471 typedef SkWStream INHERITED; |
464 }; | 472 }; |
465 | 473 |
466 // for now | 474 // for now |
467 typedef SkFILEStream SkURLStream; | 475 typedef SkFILEStream SkURLStream; |
468 | 476 |
469 #endif | 477 #endif |
OLD | NEW |