From: reed@google.com Date: Tue, 26 Apr 2011 17:49:03 +0000 (+0000) Subject: add helper available() X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~18613 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b3d5349bedf37ec6fcf03bac04cf33129fc176a;p=platform%2Fupstream%2FlibSkiaSharp.git add helper available() git-svn-id: http://skia.googlecode.com/svn/trunk@1188 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/include/core/SkReader32.h b/include/core/SkReader32.h index 1c72a87..598723c 100644 --- a/include/core/SkReader32.h +++ b/include/core/SkReader32.h @@ -43,6 +43,10 @@ public: bool eof() const { return fCurr >= fStop; } const void* base() const { return fBase; } const void* peek() const { return fCurr; } + + uint32_t available() const { return fStop - fCurr; } + bool isAvailable(uint32_t size) const { return fCurr + size <= fStop; } + void rewind() { fCurr = fBase; } void setOffset(size_t offset) { diff --git a/include/core/SkWriter32.h b/include/core/SkWriter32.h index aeeb37d..7ec170c 100644 --- a/include/core/SkWriter32.h +++ b/include/core/SkWriter32.h @@ -70,6 +70,14 @@ public: // write count bytes (must be a multiple of 4) void writeMul4(const void* values, size_t size) { + this->write(values, size); + } + + /** + * Write size bytes from values. size must be a multiple of 4, though + * values need not be 4-byte aligned. + */ + void write(const void* values, size_t size) { SkASSERT(SkAlign4(size) == size); // if we could query how much is avail in the current block, we might // copy that much, and then alloc the rest. That would reduce the waste @@ -83,7 +91,7 @@ public: 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.