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

Commit 134651af authored by Valerie Hau's avatar Valerie Hau
Browse files

Move frame number to layer state

It is logical for BufferStateLayers to store the frame number
in the layer state along with all other state information

Bug: 146345307
Test: build, boot, libgui_test
Change-Id: I8bc117bd7601290feb6244e207d09de6de361903
parent b2a6955c
Loading
Loading
Loading
Loading
+14 −13
Original line number Original line Diff line number Diff line
@@ -239,7 +239,7 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, nsecs_t postTi
        mReleasePreviousBuffer = true;
        mReleasePreviousBuffer = true;
    }
    }


    mFrameCounter++;
    mCurrentState.frameNumber++;


    mCurrentState.buffer = buffer;
    mCurrentState.buffer = buffer;
    mCurrentState.clientCacheId = clientCacheId;
    mCurrentState.clientCacheId = clientCacheId;
@@ -247,10 +247,11 @@ bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, nsecs_t postTi
    setTransactionFlags(eTransactionNeeded);
    setTransactionFlags(eTransactionNeeded);


    const int32_t layerId = getSequence();
    const int32_t layerId = getSequence();
    mFlinger->mTimeStats->setPostTime(layerId, mFrameNumber, getName().c_str(), postTime);
    mFlinger->mTimeStats->setPostTime(layerId, mCurrentState.frameNumber, getName().c_str(),
                                      postTime);
    mFlinger->mFrameTracer->traceNewLayer(layerId, getName().c_str());
    mFlinger->mFrameTracer->traceNewLayer(layerId, getName().c_str());
    mFlinger->mFrameTracer->traceTimestamp(layerId, buffer->getId(), mFrameNumber, postTime,
    mFlinger->mFrameTracer->traceTimestamp(layerId, buffer->getId(), mCurrentState.frameNumber,
                                           FrameTracer::FrameEvent::POST);
                                           postTime, FrameTracer::FrameEvent::POST);
    mCurrentState.desiredPresentTime = desiredPresentTime;
    mCurrentState.desiredPresentTime = desiredPresentTime;


    mFlinger->mScheduler->recordLayerHistory(this,
    mFlinger->mScheduler->recordLayerHistory(this,
@@ -414,7 +415,7 @@ bool BufferStateLayer::framePresentTimeIsCurrent(nsecs_t expectedPresentTime) co
}
}


uint64_t BufferStateLayer::getFrameNumber(nsecs_t /*expectedPresentTime*/) const {
uint64_t BufferStateLayer::getFrameNumber(nsecs_t /*expectedPresentTime*/) const {
    return mFrameNumber;
    return mDrawingState.frameNumber;
}
}


bool BufferStateLayer::getAutoRefresh() const {
bool BufferStateLayer::getAutoRefresh() const {
@@ -491,7 +492,7 @@ status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nse
        ALOGE("[%s] rejecting buffer: "
        ALOGE("[%s] rejecting buffer: "
              "bufferWidth=%d, bufferHeight=%d, front.active.{w=%d, h=%d}",
              "bufferWidth=%d, bufferHeight=%d, front.active.{w=%d, h=%d}",
              getDebugName(), bufferWidth, bufferHeight, s.active.w, s.active.h);
              getDebugName(), bufferWidth, bufferHeight, s.active.w, s.active.h);
        mFlinger->mTimeStats->removeTimeRecord(layerId, mFrameNumber);
        mFlinger->mTimeStats->removeTimeRecord(layerId, mDrawingState.frameNumber);
        return BAD_VALUE;
        return BAD_VALUE;
    }
    }


@@ -499,8 +500,6 @@ status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nse
        handle->latchTime = latchTime;
        handle->latchTime = latchTime;
    }
    }


    mFrameNumber = mFrameCounter;

    if (!SyncFeatures::getInstance().useNativeFenceSync()) {
    if (!SyncFeatures::getInstance().useNativeFenceSync()) {
        // Bind the new buffer to the GL texture.
        // Bind the new buffer to the GL texture.
        //
        //
@@ -517,11 +516,13 @@ status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nse
    }
    }


    const uint64_t bufferID = getCurrentBufferId();
    const uint64_t bufferID = getCurrentBufferId();
    mFlinger->mTimeStats->setAcquireFence(layerId, mFrameNumber, mBufferInfo.mFenceTime);
    mFlinger->mTimeStats->setAcquireFence(layerId, mDrawingState.frameNumber,
    mFlinger->mFrameTracer->traceFence(layerId, bufferID, mFrameNumber, mBufferInfo.mFenceTime,
                                          mBufferInfo.mFenceTime);
    mFlinger->mFrameTracer->traceFence(layerId, bufferID, mDrawingState.frameNumber,
                                       mBufferInfo.mFenceTime,
                                       FrameTracer::FrameEvent::ACQUIRE_FENCE);
                                       FrameTracer::FrameEvent::ACQUIRE_FENCE);
    mFlinger->mTimeStats->setLatchTime(layerId, mFrameNumber, latchTime);
    mFlinger->mTimeStats->setLatchTime(layerId, mDrawingState.frameNumber, latchTime);
    mFlinger->mFrameTracer->traceTimestamp(layerId, bufferID, mFrameNumber, latchTime,
    mFlinger->mFrameTracer->traceTimestamp(layerId, bufferID, mDrawingState.frameNumber, latchTime,
                                           FrameTracer::FrameEvent::LATCH);
                                           FrameTracer::FrameEvent::LATCH);


    mCurrentStateModified = false;
    mCurrentStateModified = false;
@@ -548,7 +549,7 @@ status_t BufferStateLayer::updateActiveBuffer() {
status_t BufferStateLayer::updateFrameNumber(nsecs_t /*latchTime*/) {
status_t BufferStateLayer::updateFrameNumber(nsecs_t /*latchTime*/) {
    // TODO(marissaw): support frame history events
    // TODO(marissaw): support frame history events
    mPreviousFrameNumber = mCurrentFrameNumber;
    mPreviousFrameNumber = mCurrentFrameNumber;
    mCurrentFrameNumber = mFrameNumber;
    mCurrentFrameNumber = mDrawingState.frameNumber;
    return NO_ERROR;
    return NO_ERROR;
}
}


+1 −0
Original line number Original line Diff line number Diff line
@@ -101,6 +101,7 @@ Layer::Layer(const LayerCreationArgs& args)
    mCurrentState.active.w = UINT32_MAX;
    mCurrentState.active.w = UINT32_MAX;
    mCurrentState.active.h = UINT32_MAX;
    mCurrentState.active.h = UINT32_MAX;
    mCurrentState.active.transform.set(0, 0);
    mCurrentState.active.transform.set(0, 0);
    mCurrentState.frameNumber = 0;
    mCurrentState.transform = 0;
    mCurrentState.transform = 0;
    mCurrentState.transformToDisplayInverse = false;
    mCurrentState.transformToDisplayInverse = false;
    mCurrentState.crop.makeInvalid();
    mCurrentState.crop.makeInvalid();
+1 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,7 @@ public:
        ui::Dataspace dataspace;
        ui::Dataspace dataspace;


        // The fields below this point are only used by BufferStateLayer
        // The fields below this point are only used by BufferStateLayer
        uint64_t frameNumber;
        Geometry active;
        Geometry active;


        uint32_t transform;
        uint32_t transform;