Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7a1403f authored by Leon Scroggins's avatar Leon Scroggins Committed by android-build-merger
Browse files

Merge "Allow AssetStreamAdaptor to be seekable" into pi-dev am: b69f7c9e

am: 341ade0d

Change-Id: I79e724492884ff9f993d07da3f36cd84b4aaa2eb
parents d733e94f 341ade0d
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -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;

+4 −0
Original line number Diff line number Diff line
@@ -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: