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

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

Merge "Force async behavior for the virtual display output BufferQueue" into klp-dev

parents 19733a32 8db92553
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -637,7 +637,8 @@ void BufferQueue::cancelBuffer(int buf, const sp<Fence>& fence) {


status_t BufferQueue::connect(int api, bool producerControlledByApp, QueueBufferOutput* output) {
status_t BufferQueue::connect(int api, bool producerControlledByApp, QueueBufferOutput* output) {
    ATRACE_CALL();
    ATRACE_CALL();
    ST_LOGV("connect: api=%d", api);
    ST_LOGV("connect: api=%d producerControlledByApp=%s", api,
            producerControlledByApp ? "true" : "false");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


    if (mAbandoned) {
    if (mAbandoned) {
@@ -1001,7 +1002,8 @@ status_t BufferQueue::releaseBuffer(


status_t BufferQueue::consumerConnect(const sp<IConsumerListener>& consumerListener,
status_t BufferQueue::consumerConnect(const sp<IConsumerListener>& consumerListener,
        bool controlledByApp) {
        bool controlledByApp) {
    ST_LOGV("consumerConnect");
    ST_LOGV("consumerConnect controlledByApp=%s",
            controlledByApp ? "true" : "false");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


    if (mAbandoned) {
    if (mAbandoned) {
+12 −5
Original line number Original line Diff line number Diff line
@@ -175,9 +175,12 @@ void VirtualDisplaySurface::onFrameCommitted() {
        sp<Fence> outFence = mHwc.getLastRetireFence(mDisplayId);
        sp<Fence> outFence = mHwc.getLastRetireFence(mDisplayId);
        VDS_LOGV("onFrameCommitted: queue sink sslot=%d", sslot);
        VDS_LOGV("onFrameCommitted: queue sink sslot=%d", sslot);
        status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
        status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot,
                QueueBufferInput(systemTime(), false,
                QueueBufferInput(
                    systemTime(), false /* isAutoTimestamp */,
                    Rect(mSinkBufferWidth, mSinkBufferHeight),
                    Rect(mSinkBufferWidth, mSinkBufferHeight),
                    NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, outFence),
                    NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
                    true /* async*/,
                    outFence),
                &qbo);
                &qbo);
        if (result == NO_ERROR) {
        if (result == NO_ERROR) {
            updateQueueBufferOutput(qbo);
            updateQueueBufferOutput(qbo);
@@ -205,7 +208,10 @@ status_t VirtualDisplaySurface::setBufferCount(int bufferCount) {
}
}


status_t VirtualDisplaySurface::dequeueBuffer(Source source,
status_t VirtualDisplaySurface::dequeueBuffer(Source source,
        uint32_t format, int* sslot, sp<Fence>* fence, bool async) {
        uint32_t format, int* sslot, sp<Fence>* fence) {
    // Don't let a slow consumer block us
    bool async = (source == SOURCE_SINK);

    status_t result = mSource[source]->dequeueBuffer(sslot, fence, async,
    status_t result = mSource[source]->dequeueBuffer(sslot, fence, async,
            mSinkBufferWidth, mSinkBufferHeight, format, mProducerUsage);
            mSinkBufferWidth, mSinkBufferHeight, format, mProducerUsage);
    if (result < 0)
    if (result < 0)
@@ -244,6 +250,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool
            "Unexpected dequeueBuffer() in %s state", dbgStateStr());
            "Unexpected dequeueBuffer() in %s state", dbgStateStr());
    mDbgState = DBG_STATE_GLES;
    mDbgState = DBG_STATE_GLES;


    VDS_LOGW_IF(!async, "EGL called dequeueBuffer with !async despite eglSwapInterval(0)");
    VDS_LOGV("dequeueBuffer %dx%d fmt=%d usage=%#x", w, h, format, usage);
    VDS_LOGV("dequeueBuffer %dx%d fmt=%d usage=%#x", w, h, format, usage);


    status_t result = NO_ERROR;
    status_t result = NO_ERROR;
@@ -275,7 +282,7 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool
        *fence = mOutputFence;
        *fence = mOutputFence;
    } else {
    } else {
        int sslot;
        int sslot;
        result = dequeueBuffer(source, format, &sslot, fence, async);
        result = dequeueBuffer(source, format, &sslot, fence);
        if (result >= 0) {
        if (result >= 0) {
            *pslot = mapSource2ProducerSlot(source, sslot);
            *pslot = mapSource2ProducerSlot(source, sslot);
        }
        }
@@ -391,7 +398,7 @@ status_t VirtualDisplaySurface::refreshOutputBuffer() {
    }
    }


    int sslot;
    int sslot;
    status_t result = dequeueBuffer(SOURCE_SINK, 0, &sslot, &mOutputFence, false);
    status_t result = dequeueBuffer(SOURCE_SINK, 0, &sslot, &mOutputFence);
    if (result < 0)
    if (result < 0)
        return result;
        return result;
    mOutputProducerSlot = mapSource2ProducerSlot(SOURCE_SINK, sslot);
    mOutputProducerSlot = mapSource2ProducerSlot(SOURCE_SINK, sslot);
+1 −1
Original line number Original line Diff line number Diff line
@@ -110,7 +110,7 @@ private:
    //
    //
    static Source fbSourceForCompositionType(CompositionType type);
    static Source fbSourceForCompositionType(CompositionType type);
    status_t dequeueBuffer(Source source, uint32_t format,
    status_t dequeueBuffer(Source source, uint32_t format,
            int* sslot, sp<Fence>* fence, bool async);
            int* sslot, sp<Fence>* fence);
    void updateQueueBufferOutput(const QueueBufferOutput& qbo);
    void updateQueueBufferOutput(const QueueBufferOutput& qbo);
    void resetPerFrameState();
    void resetPerFrameState();
    status_t refreshOutputBuffer();
    status_t refreshOutputBuffer();