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

Commit 9c006e03 authored by Robert Carr's avatar Robert Carr
Browse files

BLASTBufferQueue: Support setFrameRate

Surface::setFrameRate calls through to SurfaceFlinger
using the IGBP as a token. But of course in the case of BBQ
we have no IGBP on the server side, and this will produce errors.
To fix this we continue overriding Surface methods in the BBQSurface
, and forward through to the SurfaceControl variants of the function.

Bug: 170890018
Test: Existing tests pass
Change-Id: Ia2f5584a1fa871cff9511ddba155e6c957cefc3f
parent 05086b25
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -354,10 +354,15 @@ bool BLASTBufferQueue::maxBuffersAcquired() const {
}

class BBQSurface : public Surface {
private:
    sp<BLASTBufferQueue> mBbq;
public:
    BBQSurface(const sp<IGraphicBufferProducer>& igbp, bool controlledByApp) :
        Surface(igbp, controlledByApp) {
  BBQSurface(const sp<IGraphicBufferProducer>& igbp, bool controlledByApp,
      const sp<BLASTBufferQueue>& bbq) :
      Surface(igbp, controlledByApp),
      mBbq(bbq) {
    }

    void allocateBuffers() override {
        uint32_t reqWidth = mReqWidth ? mReqWidth : mUserWidth;
        uint32_t reqHeight = mReqHeight ? mReqHeight : mUserHeight;
@@ -369,10 +374,27 @@ public:

        }).detach();
    }

    status_t setFrameRate(float frameRate, int8_t compatibility) override {
        if (!ValidateFrameRate(frameRate, compatibility, "BBQSurface::setFrameRate")) {
            return BAD_VALUE;
        }
        return mBbq->setFrameRate(frameRate, compatibility);
    }
};

// TODO: Can we coalesce this with frame updates? Need to confirm
// no timing issues.
status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility) {
    std::unique_lock _lock{mMutex};
    SurfaceComposerClient::Transaction t;

    return t.setFrameRate(mSurfaceControl, frameRate, compatibility)
        .apply();
}

sp<Surface> BLASTBufferQueue::getSurface() {
    return new BBQSurface(mProducer, true);
    return new BBQSurface(mProducer, true, this);
}

} // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ public:
    void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height);
    void flushShadowQueue() { mFlushShadowQueue = true; }

    status_t setFrameRate(float frameRate, int8_t compatibility);

    virtual ~BLASTBufferQueue() = default;

private:
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public:
    status_t getUniqueId(uint64_t* outId) const;
    status_t getConsumerUsage(uint64_t* outUsage) const;

    status_t setFrameRate(float frameRate, int8_t compatibility);
    virtual status_t setFrameRate(float frameRate, int8_t compatibility);

protected:
    virtual ~Surface();