Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: include/core/SkStream.h

Issue 19677002: Add a detachAsStream to SkDynamicMemoryWStream. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Line length. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/gmmain.cpp ('k') | src/core/SkStream.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 virtual bool rewind() SK_OVERRIDE; 273 virtual bool rewind() SK_OVERRIDE;
274 virtual SkStreamAsset* duplicate() const SK_OVERRIDE; 274 virtual SkStreamAsset* duplicate() const SK_OVERRIDE;
275 275
276 virtual size_t getPosition() const SK_OVERRIDE; 276 virtual size_t getPosition() const SK_OVERRIDE;
277 virtual bool seek(size_t position) SK_OVERRIDE; 277 virtual bool seek(size_t position) SK_OVERRIDE;
278 virtual bool move(long offset) SK_OVERRIDE; 278 virtual bool move(long offset) SK_OVERRIDE;
279 virtual SkStreamAsset* fork() const SK_OVERRIDE; 279 virtual SkStreamAsset* fork() const SK_OVERRIDE;
280 280
281 virtual size_t getLength() const SK_OVERRIDE; 281 virtual size_t getLength() const SK_OVERRIDE;
282 282
283 const void* getMemoryBase() SK_OVERRIDE; 283 virtual const void* getMemoryBase() SK_OVERRIDE;
284 284
285 private: 285 private:
286 SkFILE* fFILE; 286 SkFILE* fFILE;
287 SkString fName; 287 SkString fName;
288 Ownership fOwnership; 288 Ownership fOwnership;
289 // fData is lazilly initialized when needed. 289 // fData is lazilly initialized when needed.
290 mutable SkAutoTUnref<SkData> fData; 290 mutable SkAutoTUnref<SkData> fData;
291 291
292 typedef SkStreamAsset INHERITED; 292 typedef SkStreamAsset INHERITED;
293 }; 293 };
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 409 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE;
410 // random access write 410 // random access write
411 // modifies stream and returns true if offset + size is less than or equal t o getOffset() 411 // modifies stream and returns true if offset + size is less than or equal t o getOffset()
412 bool write(const void* buffer, size_t offset, size_t size); 412 bool write(const void* buffer, size_t offset, size_t size);
413 bool read(void* buffer, size_t offset, size_t size); 413 bool read(void* buffer, size_t offset, size_t size);
414 size_t getOffset() const { return fBytesWritten; } 414 size_t getOffset() const { return fBytesWritten; }
415 size_t bytesWritten() const { return fBytesWritten; } 415 size_t bytesWritten() const { return fBytesWritten; }
416 416
417 // copy what has been written to the stream into dst 417 // copy what has been written to the stream into dst
418 void copyTo(void* dst) const; 418 void copyTo(void* dst) const;
reed1 2013/07/17 20:58:47 I wish this guy would return size_t number of byte
bungeman-skia 2013/07/17 21:29:48 That's what ::bytesWritten() is for. To clarify, t
419 419
420 /** 420 /**
421 * Return a copy of the data written so far. This call is responsible for 421 * Return a copy of the data written so far. This call is responsible for
422 * calling unref() when they are finished with the data. 422 * calling unref() when they are finished with the data.
423 */ 423 */
424 SkData* copyToData() const; 424 SkData* copyToData() const;
425 425
426 // reset the stream to its original state 426 /** Reset, returning a reader stream with the current content. */
427 SkStreamAsset* detatchAsStream();
428
429 /** Reset the stream to its original, empty, state. */
427 void reset(); 430 void reset();
428 void padToAlign4(); 431 void padToAlign4();
429 private: 432 private:
430 struct Block; 433 struct Block;
431 Block* fHead; 434 Block* fHead;
432 Block* fTail; 435 Block* fTail;
433 size_t fBytesWritten; 436 size_t fBytesWritten;
434 mutable SkData* fCopy; // is invalidated if we write after it is created 437 mutable SkData* fCopy; // is invalidated if we write after it is created
435 438
436 void invalidateCopy(); 439 void invalidateCopy();
437 440
441 // For access to the Block type.
442 friend class SkBlockMemoryStream;
443 friend class SkBlockMemoryRefCnt;
444
438 typedef SkWStream INHERITED; 445 typedef SkWStream INHERITED;
439 }; 446 };
440 447
441 448
442 class SK_API SkDebugWStream : public SkWStream { 449 class SK_API SkDebugWStream : public SkWStream {
443 public: 450 public:
444 SK_DECLARE_INST_COUNT(SkDebugWStream) 451 SK_DECLARE_INST_COUNT(SkDebugWStream)
445 452
446 // overrides 453 // overrides
447 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 454 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE;
448 virtual void newline() SK_OVERRIDE; 455 virtual void newline() SK_OVERRIDE;
449 456
450 private: 457 private:
451 typedef SkWStream INHERITED; 458 typedef SkWStream INHERITED;
452 }; 459 };
453 460
454 // for now 461 // for now
455 typedef SkFILEStream SkURLStream; 462 typedef SkFILEStream SkURLStream;
456 463
457 #endif 464 #endif
OLDNEW
« no previous file with comments | « gm/gmmain.cpp ('k') | src/core/SkStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698