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

Commit cf69b996 authored by Ady Abraham's avatar Ady Abraham Committed by Android (Google) Code Review
Browse files

Merge changes Ie6cff82f,I0f95f2a3 into sc-dev

* changes:
  SurfaceFlinger: check transaction timings even if it doesn't have a buffer
  SurfaceFlinger: get nextPredictedPresentTime directly from frame timeline
parents 9e494517 29d16cb5
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -424,12 +424,12 @@ bool BufferLayer::shouldPresentNow(nsecs_t expectedPresentTime) const {
    return isBufferDue(expectedPresentTime);
    return isBufferDue(expectedPresentTime);
}
}


bool BufferLayer::frameIsEarly(nsecs_t expectedPresentTime) const {
bool BufferLayer::frameIsEarly(nsecs_t expectedPresentTime, int64_t vsyncId) const {
    // TODO(b/169901895): kEarlyLatchVsyncThreshold should be based on the
    // TODO(b/169901895): kEarlyLatchVsyncThreshold should be based on the
    // vsync period. We can do this change as soon as ag/13100772 is merged.
    // vsync period. We can do this change as soon as ag/13100772 is merged.
    constexpr static std::chrono::nanoseconds kEarlyLatchVsyncThreshold = 5ms;
    constexpr static std::chrono::nanoseconds kEarlyLatchVsyncThreshold = 5ms;


    const auto presentTime = nextPredictedPresentTime();
    const auto presentTime = nextPredictedPresentTime(vsyncId);
    if (!presentTime.has_value()) {
    if (!presentTime.has_value()) {
        return false;
        return false;
    }
    }
+2 −2
Original line number Original line Diff line number Diff line
@@ -191,7 +191,7 @@ protected:


    // Returns true if the next frame is considered too early to present
    // Returns true if the next frame is considered too early to present
    // at the given expectedPresentTime
    // at the given expectedPresentTime
    bool frameIsEarly(nsecs_t expectedPresentTime) const;
    bool frameIsEarly(nsecs_t expectedPresentTime, int64_t vsyncId) const;


    std::atomic<bool> mAutoRefresh{false};
    std::atomic<bool> mAutoRefresh{false};
    std::atomic<bool> mSidebandStreamChanged{false};
    std::atomic<bool> mSidebandStreamChanged{false};
@@ -238,7 +238,7 @@ private:
    FloatRect computeSourceBounds(const FloatRect& parentBounds) const override;
    FloatRect computeSourceBounds(const FloatRect& parentBounds) const override;


    // Returns the predicted present time of the next frame if available
    // Returns the predicted present time of the next frame if available
    virtual std::optional<nsecs_t> nextPredictedPresentTime() const = 0;
    virtual std::optional<nsecs_t> nextPredictedPresentTime(int64_t vsyncId) const = 0;


    // The amount of time SF can delay a frame if it is considered early based
    // The amount of time SF can delay a frame if it is considered early based
    // on the VsyncModulator::VsyncConfig::appWorkDuration
    // on the VsyncModulator::VsyncConfig::appWorkDuration
+1 −1
Original line number Original line Diff line number Diff line
@@ -215,7 +215,7 @@ bool BufferQueueLayer::hasFrameUpdate() const {
    return mQueuedFrames > 0;
    return mQueuedFrames > 0;
}
}


std::optional<nsecs_t> BufferQueueLayer::nextPredictedPresentTime() const {
std::optional<nsecs_t> BufferQueueLayer::nextPredictedPresentTime(int64_t /*vsyncId*/) const {
    Mutex::Autolock lock(mQueueItemLock);
    Mutex::Autolock lock(mQueueItemLock);
    if (mQueueItems.empty()) {
    if (mQueueItems.empty()) {
        return std::nullopt;
        return std::nullopt;
+1 −1
Original line number Original line Diff line number Diff line
@@ -117,7 +117,7 @@ private:
    // Temporary - Used only for LEGACY camera mode.
    // Temporary - Used only for LEGACY camera mode.
    uint32_t getProducerStickyTransform() const;
    uint32_t getProducerStickyTransform() const;


    std::optional<nsecs_t> nextPredictedPresentTime() const override;
    std::optional<nsecs_t> nextPredictedPresentTime(int64_t vsyncId) const override;


    sp<BufferLayerConsumer> mConsumer;
    sp<BufferLayerConsumer> mConsumer;
    sp<IGraphicBufferProducer> mProducer;
    sp<IGraphicBufferProducer> mProducer;
+5 −4
Original line number Original line Diff line number Diff line
@@ -613,13 +613,14 @@ bool BufferStateLayer::hasFrameUpdate() const {
    return mCurrentStateModified && (c.buffer != nullptr || c.bgColorLayer != nullptr);
    return mCurrentStateModified && (c.buffer != nullptr || c.bgColorLayer != nullptr);
}
}


std::optional<nsecs_t> BufferStateLayer::nextPredictedPresentTime() const {
std::optional<nsecs_t> BufferStateLayer::nextPredictedPresentTime(int64_t vsyncId) const {
    const State& drawingState(getDrawingState());
    const auto prediction =
    if (!drawingState.isAutoTimestamp || !drawingState.bufferSurfaceFrameTX) {
            mFlinger->mFrameTimeline->getTokenManager()->getPredictionsForToken(vsyncId);
    if (!prediction.has_value()) {
        return std::nullopt;
        return std::nullopt;
    }
    }


    return drawingState.bufferSurfaceFrameTX->getPredictions().presentTime;
    return prediction->presentTime;
}
}


status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nsecs_t latchTime,
status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nsecs_t latchTime,
Loading