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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 virtual ~SkWStream(); | 185 virtual ~SkWStream(); |
186 | 186 |
187 /** Called to write bytes to a SkWStream. Returns true on success | 187 /** Called to write bytes to a SkWStream. Returns true on success |
188 @param buffer the address of at least size bytes to be written to the st
ream | 188 @param buffer the address of at least size bytes to be written to the st
ream |
189 @param size The number of bytes in buffer to write to the stream | 189 @param size The number of bytes in buffer to write to the stream |
190 @return true on success | 190 @return true on success |
191 */ | 191 */ |
192 virtual bool write(const void* buffer, size_t size) = 0; | 192 virtual bool write(const void* buffer, size_t size) = 0; |
193 virtual void newline(); | 193 virtual void newline(); |
194 virtual void flush(); | 194 virtual void flush(); |
| 195 virtual void sync(); |
195 | 196 |
196 virtual size_t bytesWritten() const = 0; | 197 virtual size_t bytesWritten() const = 0; |
197 | 198 |
198 // helpers | 199 // helpers |
199 | 200 |
200 bool write8(U8CPU); | 201 bool write8(U8CPU); |
201 bool write16(U16CPU); | 202 bool write16(U16CPU); |
202 bool write32(uint32_t); | 203 bool write32(uint32_t); |
203 | 204 |
204 bool writeText(const char text[]); | 205 bool writeText(const char text[]); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 public: | 354 public: |
354 SkFILEWStream(const char path[]); | 355 SkFILEWStream(const char path[]); |
355 virtual ~SkFILEWStream(); | 356 virtual ~SkFILEWStream(); |
356 | 357 |
357 /** Returns true if the current path could be opened. | 358 /** Returns true if the current path could be opened. |
358 */ | 359 */ |
359 bool isValid() const { return fFILE != NULL; } | 360 bool isValid() const { return fFILE != NULL; } |
360 | 361 |
361 bool write(const void* buffer, size_t size) override; | 362 bool write(const void* buffer, size_t size) override; |
362 void flush() override; | 363 void flush() override; |
| 364 void sync() override; |
363 size_t bytesWritten() const override; | 365 size_t bytesWritten() const override; |
364 | 366 |
365 private: | 367 private: |
366 FILE* fFILE; | 368 FILE* fFILE; |
367 | 369 |
368 typedef SkWStream INHERITED; | 370 typedef SkWStream INHERITED; |
369 }; | 371 }; |
370 | 372 |
371 class SkMemoryWStream : public SkWStream { | 373 class SkMemoryWStream : public SkWStream { |
372 public: | 374 public: |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 441 |
440 private: | 442 private: |
441 size_t fBytesWritten; | 443 size_t fBytesWritten; |
442 typedef SkWStream INHERITED; | 444 typedef SkWStream INHERITED; |
443 }; | 445 }; |
444 | 446 |
445 // for now | 447 // for now |
446 typedef SkFILEStream SkURLStream; | 448 typedef SkFILEStream SkURLStream; |
447 | 449 |
448 #endif | 450 #endif |
OLD | NEW |