diff options
author | 2012-08-30 14:03:21 +0000 | |
---|---|---|
committer | 2012-08-30 14:03:21 +0000 | |
commit | 1cf58d03a87e1ff17cd47e9de3da4c678456618d (patch) | |
tree | 2db1871402b6ea330351de7b04da11f30d6047ae /include/core/SkWriter32.h | |
parent | a9b0623eac4a473517c15418dbdc1e331ee752d2 (diff) |
add SkWriter32::rewindToOffset() -- used for peephole edits in picture recording
git-svn-id: http://skia.googlecode.com/svn/trunk@5345 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkWriter32.h')
-rw-r--r-- | include/core/SkWriter32.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/include/core/SkWriter32.h b/include/core/SkWriter32.h index 78cfb2b165..f961736dcc 100644 --- a/include/core/SkWriter32.h +++ b/include/core/SkWriter32.h @@ -49,6 +49,14 @@ public: */ void* getSingleBlock() const { return fSingleBlock; } + // return the current offset (will always be a multiple of 4) + uint32_t bytesWritten() const { return fSize; } + // DEPRECATED: use byetsWritten instead + uint32_t size() const { return this->bytesWritten(); } + + void reset(); + uint32_t* reserve(size_t size); // size MUST be multiple of 4 + /** * Specify the single block to back the writer, rathern than dynamically * allocating the memory. If block == NULL, then the writer reverts to @@ -152,16 +160,18 @@ public: */ static size_t WriteStringSize(const char* str, size_t len = (size_t)-1); - // return the current offset (will always be a multiple of 4) - uint32_t size() const { return fSize; } - void reset(); - uint32_t* reserve(size_t size); // size MUST be multiple of 4 - // return the address of the 4byte int at the specified offset (which must // be a multiple of 4. This does not allocate any new space, so the returned // address is only valid for 1 int. uint32_t* peek32(size_t offset); + /** + * Move the cursor back to offset bytes from the beginning. + * This has the same restrictions as peek32: offset must be <= size() and + * offset must be a multiple of 4. + */ + void rewindToOffset(size_t offset); + // copy into a single buffer (allocated by caller). Must be at least size() void flatten(void* dst) const; @@ -185,6 +195,8 @@ private: bool fHeadIsExternalStorage; Block* newBlock(size_t bytes); + + SkDEBUGCODE(void validate() const;) }; /** |