Merge "Allow AssetStreamAdaptor to be seekable" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b69f7c9e0b
@@ -49,6 +49,38 @@ SkStreamRewindable* AssetStreamAdaptor::onDuplicate() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool AssetStreamAdaptor::hasPosition() const {
|
||||
return fAsset->seek(0, SEEK_CUR) != -1;
|
||||
}
|
||||
|
||||
size_t AssetStreamAdaptor::getPosition() const {
|
||||
const off64_t offset = fAsset->seek(0, SEEK_CUR);
|
||||
if (offset == -1) {
|
||||
SkDebugf("---- fAsset->seek(0, SEEK_CUR) failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
bool AssetStreamAdaptor::seek(size_t position) {
|
||||
if (fAsset->seek(position, SEEK_SET) == -1) {
|
||||
SkDebugf("---- fAsset->seek(0, SEEK_SET) failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetStreamAdaptor::move(long offset) {
|
||||
if (fAsset->seek(offset, SEEK_CUR) == -1) {
|
||||
SkDebugf("---- fAsset->seek(%i, SEEK_CUR) failed\n", offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t AssetStreamAdaptor::read(void* buffer, size_t size) {
|
||||
ssize_t amount;
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ public:
|
||||
virtual size_t read(void* buffer, size_t size);
|
||||
virtual bool hasLength() const { return true; }
|
||||
virtual size_t getLength() const;
|
||||
virtual bool hasPosition() const;
|
||||
virtual size_t getPosition() const;
|
||||
virtual bool seek(size_t position);
|
||||
virtual bool move(long offset);
|
||||
virtual bool isAtEnd() const;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user