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

Commit 47b7bb43 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

[sf-newfe] Update layer history for invisible layers

Fixes a bug with new frontend where we were only updating
layer history for layers that has something to draw.

Cl also adds integration tests to validate frontend to
layerhistory path.

Test: LayerHistoryIntegrationTest
Fixes: 300701739
Change-Id: I223b4817bdf9909e3890de0b5051bc0ff345f829
parent 80e8cfe3
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -1267,7 +1267,8 @@ bool Layer::propagateFrameRateForLayerTree(FrameRate parentFrameRate, bool overr
        return parentFrameRate;
    }();

    *transactionNeeded |= setFrameRateForLayerTreeLegacy(frameRate);
    auto now = systemTime();
    *transactionNeeded |= setFrameRateForLayerTreeLegacy(frameRate, now);

    // The frame rate is propagated to the children
    bool childrenHaveFrameRate = false;
@@ -1283,7 +1284,8 @@ bool Layer::propagateFrameRateForLayerTree(FrameRate parentFrameRate, bool overr
    // layer as NoVote to allow the children to control the refresh rate
    if (!frameRate.isValid() && childrenHaveFrameRate) {
        *transactionNeeded |=
                setFrameRateForLayerTreeLegacy(FrameRate(Fps(), FrameRateCompatibility::NoVote));
                setFrameRateForLayerTreeLegacy(FrameRate(Fps(), FrameRateCompatibility::NoVote),
                                               now);
    }

    // We return whether this layer or its children has a vote. We ignore ExactOrMultiple votes for
@@ -1492,7 +1494,7 @@ void Layer::setFrameTimelineVsyncForSkippedFrames(const FrameTimelineInfo& info,
    addSurfaceFrameDroppedForBuffer(surfaceFrame, postTime);
}

bool Layer::setFrameRateForLayerTreeLegacy(FrameRate frameRate) {
bool Layer::setFrameRateForLayerTreeLegacy(FrameRate frameRate, nsecs_t now) {
    if (mDrawingState.frameRateForLayerTree == frameRate) {
        return false;
    }
@@ -1506,19 +1508,20 @@ bool Layer::setFrameRateForLayerTreeLegacy(FrameRate frameRate) {
    setTransactionFlags(eTransactionNeeded);

    mFlinger->mScheduler
            ->recordLayerHistory(sequence, getLayerProps(), systemTime(),
            ->recordLayerHistory(sequence, getLayerProps(), now, now,
                                 scheduler::LayerHistory::LayerUpdateType::SetFrameRate);
    return true;
}

bool Layer::setFrameRateForLayerTree(FrameRate frameRate, const scheduler::LayerProps& layerProps) {
bool Layer::setFrameRateForLayerTree(FrameRate frameRate, const scheduler::LayerProps& layerProps,
                                     nsecs_t now) {
    if (mDrawingState.frameRateForLayerTree == frameRate) {
        return false;
    }

    mDrawingState.frameRateForLayerTree = frameRate;
    mFlinger->mScheduler
            ->recordLayerHistory(sequence, layerProps, systemTime(),
            ->recordLayerHistory(sequence, layerProps, now, now,
                                 scheduler::LayerHistory::LayerUpdateType::SetFrameRate);
    return true;
}
@@ -3225,7 +3228,7 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
                                      mOwnerUid, postTime, getGameMode());

    if (mFlinger->mLegacyFrontEndEnabled) {
        recordLayerHistoryBufferUpdate(getLayerProps());
        recordLayerHistoryBufferUpdate(getLayerProps(), systemTime());
    }

    setFrameTimelineVsyncForBufferTransaction(info, postTime);
@@ -3256,7 +3259,7 @@ void Layer::setDesiredPresentTime(nsecs_t desiredPresentTime, bool isAutoTimesta
    mDrawingState.isAutoTimestamp = isAutoTimestamp;
}

void Layer::recordLayerHistoryBufferUpdate(const scheduler::LayerProps& layerProps) {
void Layer::recordLayerHistoryBufferUpdate(const scheduler::LayerProps& layerProps, nsecs_t now) {
    ATRACE_CALL();
    const nsecs_t presentTime = [&] {
        if (!mDrawingState.isAutoTimestamp) {
@@ -3310,14 +3313,14 @@ void Layer::recordLayerHistoryBufferUpdate(const scheduler::LayerProps& layerPro
        ATRACE_FORMAT_INSTANT("presentIn %s", to_string(presentIn).c_str());
    }

    mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime,
    mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime, now,
                                             scheduler::LayerHistory::LayerUpdateType::Buffer);
}

void Layer::recordLayerHistoryAnimationTx(const scheduler::LayerProps& layerProps) {
void Layer::recordLayerHistoryAnimationTx(const scheduler::LayerProps& layerProps, nsecs_t now) {
    const nsecs_t presentTime =
            mDrawingState.isAutoTimestamp ? 0 : mDrawingState.desiredPresentTime;
    mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime,
    mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime, now,
                                             scheduler::LayerHistory::LayerUpdateType::AnimationTX);
}

+4 −4
Original line number Diff line number Diff line
@@ -908,10 +908,10 @@ public:
    void callReleaseBufferCallback(const sp<ITransactionCompletedListener>& listener,
                                   const sp<GraphicBuffer>& buffer, uint64_t framenumber,
                                   const sp<Fence>& releaseFence);
    bool setFrameRateForLayerTreeLegacy(FrameRate);
    bool setFrameRateForLayerTree(FrameRate, const scheduler::LayerProps&);
    void recordLayerHistoryBufferUpdate(const scheduler::LayerProps&);
    void recordLayerHistoryAnimationTx(const scheduler::LayerProps&);
    bool setFrameRateForLayerTreeLegacy(FrameRate, nsecs_t now);
    bool setFrameRateForLayerTree(FrameRate, const scheduler::LayerProps&, nsecs_t now);
    void recordLayerHistoryBufferUpdate(const scheduler::LayerProps&, nsecs_t now);
    void recordLayerHistoryAnimationTx(const scheduler::LayerProps&, nsecs_t now);
    auto getLayerProps() const {
        return scheduler::LayerProps{
                .visible = isVisible(),
+1 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public:

private:
    friend class LayerHistoryTest;
    friend class LayerHistoryIntegrationTest;
    friend class TestableScheduler;

    using LayerPair = std::pair<Layer*, std::unique_ptr<LayerInfo>>;
+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ class LayerInfo {
    static constexpr size_t kNumSmallDirtyThreshold = 2;

    friend class LayerHistoryTest;
    friend class LayerHistoryIntegrationTest;
    friend class LayerInfoTest;

public:
@@ -264,6 +265,7 @@ private:

    private:
        friend class LayerHistoryTest;
        friend class LayerHistoryIntegrationTest;

        // Holds the refresh rate when it was calculated
        struct RefreshRateData {
+2 −2
Original line number Diff line number Diff line
@@ -625,9 +625,9 @@ void Scheduler::onLayerDestroyed(Layer* layer) {
}

void Scheduler::recordLayerHistory(int32_t id, const LayerProps& layerProps, nsecs_t presentTime,
                                   LayerHistory::LayerUpdateType updateType) {
                                   nsecs_t now, LayerHistory::LayerUpdateType updateType) {
    if (pacesetterSelectorPtr()->canSwitch()) {
        mLayerHistory.record(id, layerProps, presentTime, systemTime(), updateType);
        mLayerHistory.record(id, layerProps, presentTime, now, updateType);
    }
}

Loading