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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 * 'value'. | 217 * 'value'. |
218 */ | 218 */ |
219 static int SizeOfPackedUInt(size_t value); | 219 static int SizeOfPackedUInt(size_t value); |
220 }; | 220 }; |
221 | 221 |
222 ////////////////////////////////////////////////////////////////////////////////
//////// | 222 ////////////////////////////////////////////////////////////////////////////////
//////// |
223 | 223 |
224 #include "SkString.h" | 224 #include "SkString.h" |
225 #include <stdio.h> | 225 #include <stdio.h> |
226 | 226 |
227 struct SkFILE; | |
228 | |
229 /** A stream that wraps a C FILE* file stream. */ | 227 /** A stream that wraps a C FILE* file stream. */ |
230 class SK_API SkFILEStream : public SkStreamAsset { | 228 class SK_API SkFILEStream : public SkStreamAsset { |
231 public: | 229 public: |
232 /** Initialize the stream by calling sk_fopen on the specified path. | 230 /** Initialize the stream by calling sk_fopen on the specified path. |
233 * This internal stream will be closed in the destructor. | 231 * This internal stream will be closed in the destructor. |
234 */ | 232 */ |
235 explicit SkFILEStream(const char path[] = NULL); | 233 explicit SkFILEStream(const char path[] = NULL); |
236 | 234 |
237 enum Ownership { | 235 enum Ownership { |
238 kCallerPasses_Ownership, | 236 kCallerPasses_Ownership, |
(...skipping 25 matching lines...) Expand all Loading... |
264 size_t getPosition() const override; | 262 size_t getPosition() const override; |
265 bool seek(size_t position) override; | 263 bool seek(size_t position) override; |
266 bool move(long offset) override; | 264 bool move(long offset) override; |
267 SkStreamAsset* fork() const override; | 265 SkStreamAsset* fork() const override; |
268 | 266 |
269 size_t getLength() const override; | 267 size_t getLength() const override; |
270 | 268 |
271 const void* getMemoryBase() override; | 269 const void* getMemoryBase() override; |
272 | 270 |
273 private: | 271 private: |
274 SkFILE* fFILE; | 272 FILE* fFILE; |
275 SkString fName; | 273 SkString fName; |
276 Ownership fOwnership; | 274 Ownership fOwnership; |
277 // fData is lazilly initialized when needed. | 275 // fData is lazilly initialized when needed. |
278 mutable SkAutoTUnref<SkData> fData; | 276 mutable SkAutoTUnref<SkData> fData; |
279 | 277 |
280 typedef SkStreamAsset INHERITED; | 278 typedef SkStreamAsset INHERITED; |
281 }; | 279 }; |
282 | 280 |
283 class SK_API SkMemoryStream : public SkStreamMemory { | 281 class SK_API SkMemoryStream : public SkStreamMemory { |
284 public: | 282 public: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 355 |
358 /** Returns true if the current path could be opened. | 356 /** Returns true if the current path could be opened. |
359 */ | 357 */ |
360 bool isValid() const { return fFILE != NULL; } | 358 bool isValid() const { return fFILE != NULL; } |
361 | 359 |
362 bool write(const void* buffer, size_t size) override; | 360 bool write(const void* buffer, size_t size) override; |
363 void flush() override; | 361 void flush() override; |
364 size_t bytesWritten() const override; | 362 size_t bytesWritten() const override; |
365 | 363 |
366 private: | 364 private: |
367 SkFILE* fFILE; | 365 FILE* fFILE; |
368 | 366 |
369 typedef SkWStream INHERITED; | 367 typedef SkWStream INHERITED; |
370 }; | 368 }; |
371 | 369 |
372 class SkMemoryWStream : public SkWStream { | 370 class SkMemoryWStream : public SkWStream { |
373 public: | 371 public: |
374 SkMemoryWStream(void* buffer, size_t size); | 372 SkMemoryWStream(void* buffer, size_t size); |
375 bool write(const void* buffer, size_t size) override; | 373 bool write(const void* buffer, size_t size) override; |
376 size_t bytesWritten() const override { return fBytesWritten; } | 374 size_t bytesWritten() const override { return fBytesWritten; } |
377 | 375 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 438 |
441 private: | 439 private: |
442 size_t fBytesWritten; | 440 size_t fBytesWritten; |
443 typedef SkWStream INHERITED; | 441 typedef SkWStream INHERITED; |
444 }; | 442 }; |
445 | 443 |
446 // for now | 444 // for now |
447 typedef SkFILEStream SkURLStream; | 445 typedef SkFILEStream SkURLStream; |
448 | 446 |
449 #endif | 447 #endif |
OLD | NEW |