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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 */ | 56 */ |
57 virtual size_t read(void* buffer, size_t size) = 0; | 57 virtual size_t read(void* buffer, size_t size) = 0; |
58 | 58 |
59 /** Skip size number of bytes. | 59 /** Skip size number of bytes. |
60 * @return the actual number bytes that could be skipped. | 60 * @return the actual number bytes that could be skipped. |
61 */ | 61 */ |
62 size_t skip(size_t size) { | 62 size_t skip(size_t size) { |
63 return this->read(NULL, size); | 63 return this->read(NULL, size); |
64 } | 64 } |
65 | 65 |
| 66 /** |
| 67 * Attempt to peek at size bytes. |
| 68 * If this stream supports peeking, and it can peek size bytes, copy size |
| 69 * bytes into buffer, and return true. |
| 70 * If the stream does not support peeking, or cannot peek size bytes, |
| 71 * return false and leave buffer unchanged. |
| 72 * The stream is guaranteed to be in the same visible state after this |
| 73 * call, regardless of success or failure. |
| 74 * @param buffer Must not be NULL. Destination to copy bytes. |
| 75 * @param size Number of bytes to copy. |
| 76 * @return Whether the peek was performed. |
| 77 */ |
| 78 virtual bool peek(void* /* buffer */, size_t /* size */) const { return fals
e; } |
| 79 |
66 /** Returns true when all the bytes in the stream have been read. | 80 /** Returns true when all the bytes in the stream have been read. |
67 * This may return true early (when there are no more bytes to be read) | 81 * This may return true early (when there are no more bytes to be read) |
68 * or late (after the first unsuccessful read). | 82 * or late (after the first unsuccessful read). |
69 */ | 83 */ |
70 virtual bool isAtEnd() const = 0; | 84 virtual bool isAtEnd() const = 0; |
71 | 85 |
72 int8_t readS8(); | 86 int8_t readS8(); |
73 int16_t readS16(); | 87 int16_t readS16(); |
74 int32_t readS32(); | 88 int32_t readS32(); |
75 | 89 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 * The function returns the data parameter as a convenience. | 326 * The function returns the data parameter as a convenience. |
313 */ | 327 */ |
314 SkData* setData(SkData*); | 328 SkData* setData(SkData*); |
315 | 329 |
316 void skipToAlign4(); | 330 void skipToAlign4(); |
317 const void* getAtPos(); | 331 const void* getAtPos(); |
318 | 332 |
319 size_t read(void* buffer, size_t size) override; | 333 size_t read(void* buffer, size_t size) override; |
320 bool isAtEnd() const override; | 334 bool isAtEnd() const override; |
321 | 335 |
| 336 bool peek(void* buffer, size_t size) const override; |
| 337 |
322 bool rewind() override; | 338 bool rewind() override; |
323 SkMemoryStream* duplicate() const override; | 339 SkMemoryStream* duplicate() const override; |
324 | 340 |
325 size_t getPosition() const override; | 341 size_t getPosition() const override; |
326 bool seek(size_t position) override; | 342 bool seek(size_t position) override; |
327 bool move(long offset) override; | 343 bool move(long offset) override; |
328 SkMemoryStream* fork() const override; | 344 SkMemoryStream* fork() const override; |
329 | 345 |
330 size_t getLength() const override; | 346 size_t getLength() const override; |
331 | 347 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 453 |
438 private: | 454 private: |
439 size_t fBytesWritten; | 455 size_t fBytesWritten; |
440 typedef SkWStream INHERITED; | 456 typedef SkWStream INHERITED; |
441 }; | 457 }; |
442 | 458 |
443 // for now | 459 // for now |
444 typedef SkFILEStream SkURLStream; | 460 typedef SkFILEStream SkURLStream; |
445 | 461 |
446 #endif | 462 #endif |
OLD | NEW |