diff --git a/include/core/SkReader32.h b/include/core/SkReader32.h index 1c72a87eb7..598723ce70 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 aeeb37de4b..7ec170c160 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.