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

Commit 341ade0d 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

Change-Id: I2d70827a484b5db52759f34c0999e400bb11c82d
parents 3ea0aae1 b69f7c9e
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: