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

Commit b7702c5c authored by Jesse Hall's avatar Jesse Hall Committed by Android (Google) Code Review
Browse files

Merge "BufferQueueProducer: Throttle EGL frame production." into lmp-mr1-dev

parents 5acc751f 99a0afba
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -197,6 +197,12 @@ private:


    uint32_t mStickyTransform;
    uint32_t mStickyTransform;


    // This saves the fence from the last queueBuffer, such that the
    // next queueBuffer call can throttle buffer production. The prior
    // queueBuffer's fence is not nessessarily available elsewhere,
    // since the previous buffer might have already been acquired.
    sp<Fence> mLastQueueBufferFence;

}; // class BufferQueueProducer
}; // class BufferQueueProducer


} // namespace android
} // namespace android
+11 −1
Original line number Original line Diff line number Diff line
@@ -38,7 +38,8 @@ BufferQueueProducer::BufferQueueProducer(const sp<BufferQueueCore>& core) :
    mCore(core),
    mCore(core),
    mSlots(core->mSlots),
    mSlots(core->mSlots),
    mConsumerName(),
    mConsumerName(),
    mStickyTransform(0) {}
    mStickyTransform(0),
    mLastQueueBufferFence(Fence::NO_FENCE) {}


BufferQueueProducer::~BufferQueueProducer() {}
BufferQueueProducer::~BufferQueueProducer() {}


@@ -644,6 +645,15 @@ status_t BufferQueueProducer::queueBuffer(int slot,
        ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
        ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
    } // Autolock scope
    } // Autolock scope


    // Wait without lock held
    if (mCore->mConnectedApi == NATIVE_WINDOW_API_EGL) {
        // Waiting here allows for two full buffers to be queued but not a
        // third. In the event that frames take varying time, this makes a
        // small trade-off in favor of latency rather than throughput.
        mLastQueueBufferFence->waitForever("Throttling EGL Production");
        mLastQueueBufferFence = fence;
    }

    // Call back without lock held
    // Call back without lock held
    if (listener != NULL) {
    if (listener != NULL) {
        listener->onFrameAvailable();
        listener->onFrameAvailable();