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

Commit 3172e202 authored by Steven Thomas's avatar Steven Thomas
Browse files

Add plumbing for upcoming setFrameRate() api

Add plumbing from the app to surface flinger for the
ANativeWindow_setFrameRate() and ASurfaceTransaction_setFrameRate() api
calls we'll be adding soon.

We don't do anything in surface flinger with this data yet.

Bug: 143912624

Test: Added a new test, SetFrameRateTest.
Change-Id: I1cab87f3ce5afca4591a39d8e7a42cb1e86a368f
parent 92bd250e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -147,6 +147,16 @@ status_t BufferHubConsumer::discardFreeBuffers() {
    return INVALID_OPERATION;
}

status_t BufferHubConsumer::setFrameRate(float /*frameRate*/) {
    ALOGE("BufferHubConsumer::setFrameRate: not implemented.");
    return INVALID_OPERATION;
}

status_t BufferHubConsumer::getFrameRate(float* /*frameRate*/) const {
    ALOGE("BufferHubConsumer::getFrameRate: not implemented.");
    return INVALID_OPERATION;
}

status_t BufferHubConsumer::dumpState(const String8& /*prefix*/, String8* /*outResult*/) const {
    ALOGE("BufferHubConsumer::dumpState: not implemented.");
    return INVALID_OPERATION;
+12 −0
Original line number Diff line number Diff line
@@ -775,6 +775,18 @@ status_t BufferQueueConsumer::discardFreeBuffers() {
    return NO_ERROR;
}

status_t BufferQueueConsumer::setFrameRate(float frameRate) {
    std::lock_guard<std::mutex> lock(mCore->mMutex);
    mCore->mFrameRate = frameRate;
    return NO_ERROR;
}

status_t BufferQueueConsumer::getFrameRate(float* frameRate) const {
    std::lock_guard<std::mutex> lock(mCore->mMutex);
    *frameRate = mCore->mFrameRate;
    return NO_ERROR;
}

status_t BufferQueueConsumer::dumpState(const String8& prefix, String8* outResult) const {
    struct passwd* pwd = getpwnam("shell");
    uid_t shellUid = pwd ? pwd->pw_uid : 0;
+10 −0
Original line number Diff line number Diff line
@@ -1670,4 +1670,14 @@ status_t BufferQueueProducer::setAutoPrerotation(bool autoPrerotation) {
    return NO_ERROR;
}

status_t BufferQueueProducer::setFrameRate(float frameRate) {
    ATRACE_CALL();
    BQ_LOGV("setFrameRate: %.0f", frameRate);

    std::lock_guard<std::mutex> lock(mCore->mMutex);

    mCore->mFrameRate = frameRate;
    return NO_ERROR;
}

} // namespace android
+18 −0
Original line number Diff line number Diff line
@@ -363,6 +363,24 @@ status_t ConsumerBase::discardFreeBuffers() {
    return OK;
}

status_t ConsumerBase::setFrameRate(float frameRate) {
    Mutex::Autolock _l(mMutex);
    if (mAbandoned) {
        CB_LOGE("setFrameRate: ConsumerBase is abandoned!");
        return NO_INIT;
    }
    return mConsumer->setFrameRate(frameRate);
}

status_t ConsumerBase::getFrameRate(float* frameRate) {
    Mutex::Autolock _l(mMutex);
    if (mAbandoned) {
        CB_LOGE("getFrameRate: ConsumerBase is abandoned!");
        return NO_INIT;
    }
    return mConsumer->getFrameRate(frameRate);
}

void ConsumerBase::dumpState(String8& result) const {
    dumpState(result, "");
}
+16 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ enum class Tag : uint32_t {
    GET_SIDEBAND_STREAM,
    GET_OCCUPANCY_HISTORY,
    DISCARD_FREE_BUFFERS,
    SET_FRAME_RATE,
    GET_FRAME_RATE,
    DUMP_STATE,
    LAST = DUMP_STATE,
};
@@ -163,6 +165,16 @@ public:
                Tag::DISCARD_FREE_BUFFERS);
    }

    status_t setFrameRate(float frameRate) override {
        using Signature = decltype(&IGraphicBufferConsumer::setFrameRate);
        return callRemote<Signature>(Tag::SET_FRAME_RATE, frameRate);
    }

    status_t getFrameRate(float* frameRate) const override {
        using Signature = decltype(&IGraphicBufferConsumer::getFrameRate);
        return callRemote<Signature>(Tag::GET_FRAME_RATE, frameRate);
    }

    status_t dumpState(const String8& prefix, String8* outResult) const override {
        using Signature = status_t (IGraphicBufferConsumer::*)(const String8&, String8*) const;
        return callRemote<Signature>(Tag::DUMP_STATE, prefix, outResult);
@@ -220,6 +232,10 @@ status_t BnGraphicBufferConsumer::onTransact(uint32_t code, const Parcel& data,
            return callLocal(data, reply, &IGraphicBufferConsumer::getOccupancyHistory);
        case Tag::DISCARD_FREE_BUFFERS:
            return callLocal(data, reply, &IGraphicBufferConsumer::discardFreeBuffers);
        case Tag::SET_FRAME_RATE:
            return callLocal(data, reply, &IGraphicBufferConsumer::setFrameRate);
        case Tag::GET_FRAME_RATE:
            return callLocal(data, reply, &IGraphicBufferConsumer::getFrameRate);
        case Tag::DUMP_STATE: {
            using Signature = status_t (IGraphicBufferConsumer::*)(const String8&, String8*) const;
            return callLocal<Signature>(data, reply, &IGraphicBufferConsumer::dumpState);
Loading