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

Commit f4782de4 authored by Melody Hsu's avatar Melody Hsu Committed by Android (Google) Code Review
Browse files

Merge "[legacy sf flag] - Remove legacyFrontEndEnabled" into main

parents 5a7072f7 11e197a2
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -3218,10 +3218,6 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
    mFlinger->mTimeStats->setPostTime(layerId, mDrawingState.frameNumber, getName().c_str(),
    mFlinger->mTimeStats->setPostTime(layerId, mDrawingState.frameNumber, getName().c_str(),
                                      mOwnerUid, postTime, getGameMode());
                                      mOwnerUid, postTime, getGameMode());


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

    setFrameTimelineVsyncForBufferTransaction(info, postTime);
    setFrameTimelineVsyncForBufferTransaction(info, postTime);


    if (dequeueTime && *dequeueTime != 0) {
    if (dequeueTime && *dequeueTime != 0) {
+76 −114
Original line number Original line Diff line number Diff line
@@ -531,8 +531,6 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI


    mLayerLifecycleManagerEnabled =
    mLayerLifecycleManagerEnabled =
            base::GetBoolProperty("persist.debug.sf.enable_layer_lifecycle_manager"s, true);
            base::GetBoolProperty("persist.debug.sf.enable_layer_lifecycle_manager"s, true);
    mLegacyFrontEndEnabled = !mLayerLifecycleManagerEnabled ||
            base::GetBoolProperty("persist.debug.sf.enable_legacy_frontend"s, false);


    // These are set by the HWC implementation to indicate that they will use the workarounds.
    // These are set by the HWC implementation to indicate that they will use the workarounds.
    mIsHotplugErrViaNegVsync =
    mIsHotplugErrViaNegVsync =
@@ -2440,7 +2438,6 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,
    mustComposite |= mLayerLifecycleManager.getGlobalChanges().get() != 0;
    mustComposite |= mLayerLifecycleManager.getGlobalChanges().get() != 0;


    bool newDataLatched = false;
    bool newDataLatched = false;
    if (!mLegacyFrontEndEnabled) {
    ATRACE_NAME("DisplayCallbackAndStatsUpdates");
    ATRACE_NAME("DisplayCallbackAndStatsUpdates");
    mustComposite |= applyTransactionsLocked(update.transactions, vsyncId);
    mustComposite |= applyTransactionsLocked(update.transactions, vsyncId);
    traverseLegacyLayers([&](Layer* layer) { layer->commitTransaction(); });
    traverseLegacyLayers([&](Layer* layer) { layer->commitTransaction(); });
@@ -2495,8 +2492,7 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,


    updateLayerHistory(latchTime);
    updateLayerHistory(latchTime);
    mLayerSnapshotBuilder.forEachVisibleSnapshot([&](const frontend::LayerSnapshot& snapshot) {
    mLayerSnapshotBuilder.forEachVisibleSnapshot([&](const frontend::LayerSnapshot& snapshot) {
            if (mLayersIdsWithQueuedFrames.find(snapshot.path.id) ==
        if (mLayersIdsWithQueuedFrames.find(snapshot.path.id) == mLayersIdsWithQueuedFrames.end())
                mLayersIdsWithQueuedFrames.end())
            return;
            return;
        Region visibleReg;
        Region visibleReg;
        visibleReg.set(snapshot.transformedBoundsWithoutTransparentRegion);
        visibleReg.set(snapshot.transformedBoundsWithoutTransparentRegion);
@@ -2517,9 +2513,9 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,
        ALOGI("Enter boot animation");
        ALOGI("Enter boot animation");
        mBootStage = BootStage::BOOTANIMATION;
        mBootStage = BootStage::BOOTANIMATION;
    }
    }
    }

    mustComposite |= (getTransactionFlags() & ~eTransactionFlushNeeded) || newDataLatched;
    mustComposite |= (getTransactionFlags() & ~eTransactionFlushNeeded) || newDataLatched;
    if (mustComposite && !mLegacyFrontEndEnabled) {
    if (mustComposite) {
        commitTransactions();
        commitTransactions();
    }
    }


@@ -2621,12 +2617,7 @@ bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId,
                                    mScheduler->getPacesetterRefreshRate());
                                    mScheduler->getPacesetterRefreshRate());


        const bool flushTransactions = clearTransactionFlags(eTransactionFlushNeeded);
        const bool flushTransactions = clearTransactionFlags(eTransactionFlushNeeded);
        bool transactionsAreEmpty;
        bool transactionsAreEmpty = false;
        if (mLegacyFrontEndEnabled) {
            mustComposite |=
                    updateLayerSnapshotsLegacy(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
                                               flushTransactions, transactionsAreEmpty);
        }
        if (mLayerLifecycleManagerEnabled) {
        if (mLayerLifecycleManagerEnabled) {
            mustComposite |=
            mustComposite |=
                    updateLayerSnapshots(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
                    updateLayerSnapshots(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
@@ -5250,16 +5241,9 @@ bool SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelin
    nsecs_t now = systemTime();
    nsecs_t now = systemTime();
    uint32_t clientStateFlags = 0;
    uint32_t clientStateFlags = 0;
    for (auto& resolvedState : states) {
    for (auto& resolvedState : states) {
        if (mLegacyFrontEndEnabled) {
        clientStateFlags |=
        clientStateFlags |=
                    setClientStateLocked(frameTimelineInfo, resolvedState, desiredPresentTime,
                updateLayerCallbacksAndStats(frameTimelineInfo, resolvedState, desiredPresentTime,
                                             isAutoTimestamp, postTime, transactionId);
                                             isAutoTimestamp, postTime, transactionId);

        } else /*mLayerLifecycleManagerEnabled*/ {
            clientStateFlags |= updateLayerCallbacksAndStats(frameTimelineInfo, resolvedState,
                                                             desiredPresentTime, isAutoTimestamp,
                                                             postTime, transactionId);
        }
        if (!mLayerLifecycleManagerEnabled) {
        if (!mLayerLifecycleManagerEnabled) {
            if ((flags & eAnimation) && resolvedState.state.surface) {
            if ((flags & eAnimation) && resolvedState.state.surface) {
                if (const auto layer = LayerHandle::getLayer(resolvedState.state.surface)) {
                if (const auto layer = LayerHandle::getLayer(resolvedState.state.surface)) {
@@ -5331,7 +5315,7 @@ bool SurfaceFlinger::applyAndCommitDisplayTransactionStatesLocked(
    }
    }


    mFrontEndDisplayInfosChanged = mTransactionFlags & eDisplayTransactionNeeded;
    mFrontEndDisplayInfosChanged = mTransactionFlags & eDisplayTransactionNeeded;
    if (mFrontEndDisplayInfosChanged && !mLegacyFrontEndEnabled) {
    if (mFrontEndDisplayInfosChanged) {
        processDisplayChangesLocked();
        processDisplayChangesLocked();
        mFrontEndDisplayInfos.clear();
        mFrontEndDisplayInfos.clear();
        for (const auto& [_, display] : mDisplays) {
        for (const auto& [_, display] : mDisplays) {
@@ -5974,11 +5958,6 @@ status_t SurfaceFlinger::mirrorDisplay(DisplayId displayId, const LayerCreationA
        return result;
        return result;
    }
    }


    if (mLegacyFrontEndEnabled) {
        std::scoped_lock<std::mutex> lock(mMirrorDisplayLock);
        mMirrorDisplays.emplace_back(layerStack, outResult.handle, args.client);
    }

    setTransactionFlags(eTransactionFlushNeeded);
    setTransactionFlags(eTransactionFlushNeeded);
    return NO_ERROR;
    return NO_ERROR;
}
}
@@ -6093,9 +6072,7 @@ void SurfaceFlinger::initializeDisplays() {
    std::vector<TransactionState> transactions;
    std::vector<TransactionState> transactions;
    transactions.emplace_back(state);
    transactions.emplace_back(state);


    if (mLegacyFrontEndEnabled) {
    {
        applyTransactions(transactions, VsyncId{0});
    } else {
        Mutex::Autolock lock(mStateLock);
        Mutex::Autolock lock(mStateLock);
        applyAndCommitDisplayTransactionStatesLocked(transactions);
        applyAndCommitDisplayTransactionStatesLocked(transactions);
    }
    }
@@ -6647,17 +6624,6 @@ perfetto::protos::LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t tra
        }
        }
    }
    }


    if (mLegacyFrontEndEnabled) {
        perfetto::protos::LayersProto layersProto;
        for (const sp<Layer>& layer : mDrawingState.layersSortedByZ) {
            if (stackIdsToSkip.find(layer->getLayerStack().id) != stackIdsToSkip.end()) {
                continue;
            }
            layer->writeToProto(layersProto, traceFlags);
        }
        return layersProto;
    }

    return LayerProtoFromSnapshotGenerator(mLayerSnapshotBuilder, mFrontEndDisplayInfos,
    return LayerProtoFromSnapshotGenerator(mLayerSnapshotBuilder, mFrontEndDisplayInfos,
                                           mLegacyLayers, traceFlags)
                                           mLegacyLayers, traceFlags)
            .generate(mLayerHierarchyBuilder.getHierarchy());
            .generate(mLayerHierarchyBuilder.getHierarchy());
@@ -6906,10 +6872,6 @@ void SurfaceFlinger::dumpAll(const DumpArgs& args, const std::string& compositio
    }
    }
    result.push_back('\n');
    result.push_back('\n');


    if (mLegacyFrontEndEnabled) {
        dumpHwcLayersMinidumpLockedLegacy(result);
    }

    {
    {
        DumpArgs plannerArgs;
        DumpArgs plannerArgs;
        plannerArgs.add(); // first argument is ignored
        plannerArgs.add(); // first argument is ignored
@@ -9235,7 +9197,7 @@ void SurfaceFlinger::moveSnapshotsFromCompositionArgs(
            snapshots[i] = std::move(layerFE->mSnapshot);
            snapshots[i] = std::move(layerFE->mSnapshot);
        }
        }
    }
    }
    if (mLegacyFrontEndEnabled && !mLayerLifecycleManagerEnabled) {
    if (!mLayerLifecycleManagerEnabled) {
        for (auto [layer, layerFE] : layers) {
        for (auto [layer, layerFE] : layers) {
            layer->updateLayerSnapshot(std::move(layerFE->mSnapshot));
            layer->updateLayerSnapshot(std::move(layerFE->mSnapshot));
        }
        }
@@ -9272,7 +9234,7 @@ std::vector<std::pair<Layer*, LayerFE*>> SurfaceFlinger::moveSnapshotsToComposit
                    layers.emplace_back(legacyLayer.get(), layerFE.get());
                    layers.emplace_back(legacyLayer.get(), layerFE.get());
                });
                });
    }
    }
    if (mLegacyFrontEndEnabled && !mLayerLifecycleManagerEnabled) {
    if (!mLayerLifecycleManagerEnabled) {
        auto moveSnapshots = [&layers, &refreshArgs, cursorOnly](Layer* layer) {
        auto moveSnapshots = [&layers, &refreshArgs, cursorOnly](Layer* layer) {
            if (const auto& layerFE = layer->getCompositionEngineLayerFE()) {
            if (const auto& layerFE = layer->getCompositionEngineLayerFE()) {
                if (cursorOnly &&
                if (cursorOnly &&
+0 −1
Original line number Original line Diff line number Diff line
@@ -1486,7 +1486,6 @@ private:
    bool mPowerHintSessionEnabled;
    bool mPowerHintSessionEnabled;


    bool mLayerLifecycleManagerEnabled = false;
    bool mLayerLifecycleManagerEnabled = false;
    bool mLegacyFrontEndEnabled = true;


    frontend::LayerLifecycleManager mLayerLifecycleManager GUARDED_BY(kMainThreadContext);
    frontend::LayerLifecycleManager mLayerLifecycleManager GUARDED_BY(kMainThreadContext);
    frontend::LayerHierarchyBuilder mLayerHierarchyBuilder GUARDED_BY(kMainThreadContext);
    frontend::LayerHierarchyBuilder mLayerHierarchyBuilder GUARDED_BY(kMainThreadContext);
+2 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ namespace android {
class ColorMatrixTest : public CommitAndCompositeTest {};
class ColorMatrixTest : public CommitAndCompositeTest {};


TEST_F(ColorMatrixTest, colorMatrixChanged) {
TEST_F(ColorMatrixTest, colorMatrixChanged) {
    mFlinger.enableLayerLifecycleManager();
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;


@@ -45,6 +46,7 @@ TEST_F(ColorMatrixTest, colorMatrixChanged) {
}
}


TEST_F(ColorMatrixTest, colorMatrixChangedAfterDisplayTransaction) {
TEST_F(ColorMatrixTest, colorMatrixChangedAfterDisplayTransaction) {
    mFlinger.enableLayerLifecycleManager();
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    EXPECT_COLOR_MATRIX_CHANGED(true, true);
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;
    mFlinger.mutableTransactionFlags() |= eTransactionNeeded;


+4 −0
Original line number Original line Diff line number Diff line
@@ -691,6 +691,10 @@ public:
        return mFlinger->initTransactionTraceWriter();
        return mFlinger->initTransactionTraceWriter();
    }
    }


    // Needed since mLayerLifecycleManagerEnabled is false by default and must
    // be enabled for tests to go through the new front end path.
    void enableLayerLifecycleManager() { mFlinger->mLayerLifecycleManagerEnabled = true; }

    void notifyExpectedPresentIfRequired(PhysicalDisplayId displayId, Period vsyncPeriod,
    void notifyExpectedPresentIfRequired(PhysicalDisplayId displayId, Period vsyncPeriod,
                                         TimePoint expectedPresentTime, Fps frameInterval,
                                         TimePoint expectedPresentTime, Fps frameInterval,
                                         std::optional<Period> timeoutOpt) {
                                         std::optional<Period> timeoutOpt) {