add helper available()

git-svn-id: http://skia.googlecode.com/svn/trunk@1188 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-04-26 17:49:03 +00:00
parent bb6992a9d6
commit 5b3d5349be
2 changed files with 13 additions and 1 deletions

View File

@ -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) {

View File

@ -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