[legacy sf flag] - Remove layerLifecycleManagerEnabled
New frontend is enabled in SurfaceFlinger and code guarded
behind the flag can be removed, along with the flag itself.
Bug: b/330785038
Test: presubmit
Flag: EXEMPT (removing old flags)
Change-Id: I65d5bd142a708897507e804223200ada91fc7489
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 1d35730..029bff8 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -534,9 +534,6 @@
mIgnoreHdrCameraLayers = ignore_hdr_camera_layers(false);
- mLayerLifecycleManagerEnabled =
- base::GetBoolProperty("persist.debug.sf.enable_layer_lifecycle_manager"s, true);
-
// These are set by the HWC implementation to indicate that they will use the workarounds.
mIsHotplugErrViaNegVsync =
base::GetBoolProperty("debug.sf.hwc_hotplug_error_via_neg_vsync"s, false);
@@ -2676,11 +2673,8 @@
const bool flushTransactions = clearTransactionFlags(eTransactionFlushNeeded);
bool transactionsAreEmpty = false;
- if (mLayerLifecycleManagerEnabled) {
- mustComposite |=
- updateLayerSnapshots(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
- flushTransactions, transactionsAreEmpty);
- }
+ mustComposite |= updateLayerSnapshots(vsyncId, pacesetterFrameTarget.frameBeginTime().ns(),
+ flushTransactions, transactionsAreEmpty);
// Tell VsyncTracker that we are going to present this frame before scheduling
// setTransactionFlags which will schedule another SF frame. This was if the tracker
@@ -2714,9 +2708,7 @@
mUpdateAttachedChoreographer = false;
Mutex::Autolock lock(mStateLock);
- mScheduler->chooseRefreshRateForContent(mLayerLifecycleManagerEnabled
- ? &mLayerHierarchyBuilder.getHierarchy()
- : nullptr,
+ mScheduler->chooseRefreshRateForContent(&mLayerHierarchyBuilder.getHierarchy(),
updateAttachedChoreographer);
if (FlagManager::getInstance().connected_display()) {
@@ -2837,7 +2829,7 @@
constexpr bool kCursorOnly = false;
const auto layers = moveSnapshotsToCompositionArgs(refreshArgs, kCursorOnly);
- if (mLayerLifecycleManagerEnabled && !mVisibleRegionsDirty) {
+ if (!mVisibleRegionsDirty) {
for (const auto& [token, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) {
auto compositionDisplay = display->getCompositionDisplay();
if (!compositionDisplay->getState().isEnabled) continue;
@@ -3253,28 +3245,20 @@
}
};
- if (mLayerLifecycleManagerEnabled) {
- mLayerSnapshotBuilder.forEachVisibleSnapshot(
- [&, compositionDisplay = compositionDisplay](
- std::unique_ptr<frontend::LayerSnapshot>&
- snapshot) FTL_FAKE_GUARD(kMainThreadContext) {
- auto it = mLegacyLayers.find(snapshot->sequence);
- LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
- "Couldnt find layer object for %s",
- snapshot->getDebugString().c_str());
- auto& legacyLayer = it->second;
- sp<LayerFE> layerFe =
- legacyLayer->getCompositionEngineLayerFE(snapshot->path);
+ mLayerSnapshotBuilder.forEachVisibleSnapshot(
+ [&, compositionDisplay = compositionDisplay](
+ std::unique_ptr<frontend::LayerSnapshot>& snapshot)
+ FTL_FAKE_GUARD(kMainThreadContext) {
+ auto it = mLegacyLayers.find(snapshot->sequence);
+ LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
+ "Couldnt find layer object for %s",
+ snapshot->getDebugString().c_str());
+ auto& legacyLayer = it->second;
+ sp<LayerFE> layerFe =
+ legacyLayer->getCompositionEngineLayerFE(snapshot->path);
- updateInfoFn(compositionDisplay, *snapshot, layerFe);
- });
- } else {
- mDrawingState.traverse([&, compositionDisplay = compositionDisplay](Layer* layer) {
- const auto layerFe = layer->getCompositionEngineLayerFE();
- const frontend::LayerSnapshot& snapshot = *layer->getLayerSnapshot();
- updateInfoFn(compositionDisplay, snapshot, layerFe);
- });
- }
+ updateInfoFn(compositionDisplay, *snapshot, layerFe);
+ });
listener->dispatchHdrLayerInfo(info);
}
}
@@ -3320,9 +3304,8 @@
if (!layer->hasTrustedPresentationListener()) {
return;
}
- const frontend::LayerSnapshot* snapshot = mLayerLifecycleManagerEnabled
- ? mLayerSnapshotBuilder.getSnapshot(layer->sequence)
- : layer->getLayerSnapshot();
+ const frontend::LayerSnapshot* snapshot =
+ mLayerSnapshotBuilder.getSnapshot(layer->sequence);
std::optional<const DisplayDevice*> displayOpt = std::nullopt;
if (snapshot) {
displayOpt = layerStackToDisplay.get(snapshot->outputFilter.layerStack);
@@ -4047,13 +4030,6 @@
// Commit display transactions.
const bool displayTransactionNeeded = transactionFlags & eDisplayTransactionNeeded;
mFrontEndDisplayInfosChanged = displayTransactionNeeded;
- if (displayTransactionNeeded && !mLayerLifecycleManagerEnabled) {
- processDisplayChangesLocked();
- mFrontEndDisplayInfos.clear();
- for (const auto& [_, display] : mDisplays) {
- mFrontEndDisplayInfos.try_emplace(display->getLayerStack(), display->getFrontEndInfo());
- }
- }
mForceTransactionDisplayChange = displayTransactionNeeded;
if (mSomeChildrenChanged) {
@@ -4234,23 +4210,10 @@
outWindowInfos.reserve(sNumWindowInfos);
sNumWindowInfos = 0;
- if (mLayerLifecycleManagerEnabled) {
- mLayerSnapshotBuilder.forEachInputSnapshot(
- [&outWindowInfos](const frontend::LayerSnapshot& snapshot) {
- outWindowInfos.push_back(snapshot.inputInfo);
- });
- } else {
- mDrawingState.traverseInReverseZOrder([&](Layer* layer) FTL_FAKE_GUARD(kMainThreadContext) {
- if (!layer->needsInputInfo()) return;
- const auto opt =
- mFrontEndDisplayInfos.get(layer->getLayerStack())
- .transform([](const frontend::DisplayInfo& info) {
- return Layer::InputDisplayArgs{&info.transform, info.isSecure};
- });
-
- outWindowInfos.push_back(layer->fillInputInfo(opt.value_or(Layer::InputDisplayArgs{})));
- });
- }
+ mLayerSnapshotBuilder.forEachInputSnapshot(
+ [&outWindowInfos](const frontend::LayerSnapshot& snapshot) {
+ outWindowInfos.push_back(snapshot.inputInfo);
+ });
sNumWindowInfos = outWindowInfos.size();
@@ -4324,10 +4287,8 @@
void SurfaceFlinger::onChoreographerAttached() {
SFTRACE_CALL();
- if (mLayerLifecycleManagerEnabled) {
- mUpdateAttachedChoreographer = true;
- scheduleCommit(FrameHint::kNone);
- }
+ mUpdateAttachedChoreographer = true;
+ scheduleCommit(FrameHint::kNone);
}
void SurfaceFlinger::onExpectedPresentTimePosted(TimePoint expectedPresentTime,
@@ -5077,15 +5038,8 @@
void SurfaceFlinger::addTransactionReadyFilters() {
mTransactionHandler.addTransactionReadyFilter(
std::bind(&SurfaceFlinger::transactionReadyTimelineCheck, this, std::placeholders::_1));
- if (mLayerLifecycleManagerEnabled) {
- mTransactionHandler.addTransactionReadyFilter(
- std::bind(&SurfaceFlinger::transactionReadyBufferCheck, this,
- std::placeholders::_1));
- } else {
- mTransactionHandler.addTransactionReadyFilter(
- std::bind(&SurfaceFlinger::transactionReadyBufferCheckLegacy, this,
- std::placeholders::_1));
- }
+ mTransactionHandler.addTransactionReadyFilter(
+ std::bind(&SurfaceFlinger::transactionReadyBufferCheck, this, std::placeholders::_1));
}
// For tests only
@@ -5317,11 +5271,6 @@
const std::vector<ListenerCallbacks>& listenerCallbacks,
int originPid, int originUid, uint64_t transactionId) {
uint32_t transactionFlags = 0;
- if (!mLayerLifecycleManagerEnabled) {
- for (DisplayState& display : displays) {
- transactionFlags |= setDisplayStateLocked(display);
- }
- }
// start and end registration for listeners w/ no surface so they can get their callback. Note
// that listeners with SurfaceControls will start registration during setClientStateLocked
@@ -5329,27 +5278,11 @@
for (const auto& listener : listenerCallbacks) {
mTransactionCallbackInvoker.addEmptyTransaction(listener);
}
- nsecs_t now = systemTime();
uint32_t clientStateFlags = 0;
for (auto& resolvedState : states) {
clientStateFlags |=
updateLayerCallbacksAndStats(frameTimelineInfo, resolvedState, desiredPresentTime,
isAutoTimestamp, postTime, transactionId);
- if (!mLayerLifecycleManagerEnabled) {
- if ((flags & eAnimation) && resolvedState.state.surface) {
- if (const auto layer = LayerHandle::getLayer(resolvedState.state.surface)) {
- const auto layerProps = scheduler::LayerProps{
- .visible = layer->isVisible(),
- .bounds = layer->getBounds(),
- .transform = layer->getTransform(),
- .setFrameRateVote = layer->getFrameRateForLayerTree(),
- .frameRateSelectionPriority = layer->getFrameRateSelectionPriority(),
- .isFrontBuffered = layer->isFrontBuffered(),
- };
- layer->recordLayerHistoryAnimationTx(layerProps, now);
- }
- }
- }
}
transactionFlags |= clientStateFlags;
@@ -6661,53 +6594,35 @@
}
void SurfaceFlinger::dumpVisibleFrontEnd(std::string& result) {
- if (!mLayerLifecycleManagerEnabled) {
- StringAppendF(&result, "Composition layers\n");
- mDrawingState.traverseInZOrder([&](Layer* layer) {
- auto* compositionState = layer->getCompositionState();
- if (!compositionState || !compositionState->isVisible) return;
- android::base::StringAppendF(&result, "* Layer %p (%s)\n", layer,
- layer->getDebugName() ? layer->getDebugName()
- : "<unknown>");
- compositionState->dump(result);
- });
-
- StringAppendF(&result, "Offscreen Layers\n");
- for (Layer* offscreenLayer : mOffscreenLayers) {
- offscreenLayer->traverse(LayerVector::StateSet::Drawing,
- [&](Layer* layer) { layer->dumpOffscreenDebugInfo(result); });
- }
- } else {
- std::ostringstream out;
- out << "\nComposition list\n";
- ui::LayerStack lastPrintedLayerStackHeader = ui::INVALID_LAYER_STACK;
- mLayerSnapshotBuilder.forEachVisibleSnapshot(
- [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) {
- if (snapshot->hasSomethingToDraw()) {
- if (lastPrintedLayerStackHeader != snapshot->outputFilter.layerStack) {
- lastPrintedLayerStackHeader = snapshot->outputFilter.layerStack;
- out << "LayerStack=" << lastPrintedLayerStackHeader.id << "\n";
- }
- out << " " << *snapshot << "\n";
+ std::ostringstream out;
+ out << "\nComposition list\n";
+ ui::LayerStack lastPrintedLayerStackHeader = ui::INVALID_LAYER_STACK;
+ mLayerSnapshotBuilder.forEachVisibleSnapshot(
+ [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) {
+ if (snapshot->hasSomethingToDraw()) {
+ if (lastPrintedLayerStackHeader != snapshot->outputFilter.layerStack) {
+ lastPrintedLayerStackHeader = snapshot->outputFilter.layerStack;
+ out << "LayerStack=" << lastPrintedLayerStackHeader.id << "\n";
}
- });
+ out << " " << *snapshot << "\n";
+ }
+ });
- out << "\nInput list\n";
- lastPrintedLayerStackHeader = ui::INVALID_LAYER_STACK;
- mLayerSnapshotBuilder.forEachInputSnapshot([&](const frontend::LayerSnapshot& snapshot) {
- if (lastPrintedLayerStackHeader != snapshot.outputFilter.layerStack) {
- lastPrintedLayerStackHeader = snapshot.outputFilter.layerStack;
- out << "LayerStack=" << lastPrintedLayerStackHeader.id << "\n";
- }
- out << " " << snapshot << "\n";
- });
+ out << "\nInput list\n";
+ lastPrintedLayerStackHeader = ui::INVALID_LAYER_STACK;
+ mLayerSnapshotBuilder.forEachInputSnapshot([&](const frontend::LayerSnapshot& snapshot) {
+ if (lastPrintedLayerStackHeader != snapshot.outputFilter.layerStack) {
+ lastPrintedLayerStackHeader = snapshot.outputFilter.layerStack;
+ out << "LayerStack=" << lastPrintedLayerStackHeader.id << "\n";
+ }
+ out << " " << snapshot << "\n";
+ });
- out << "\nLayer Hierarchy\n"
- << mLayerHierarchyBuilder.getHierarchy() << "\nOffscreen Hierarchy\n"
- << mLayerHierarchyBuilder.getOffscreenHierarchy() << "\n\n";
- result = out.str();
- dumpHwcLayersMinidump(result);
- }
+ out << "\nLayer Hierarchy\n"
+ << mLayerHierarchyBuilder.getHierarchy() << "\nOffscreen Hierarchy\n"
+ << mLayerHierarchyBuilder.getOffscreenHierarchy() << "\n\n";
+ result = out.str();
+ dumpHwcLayersMinidump(result);
}
perfetto::protos::LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const {
@@ -6828,9 +6743,6 @@
}
void SurfaceFlinger::dumpHwcLayersMinidump(std::string& result) const {
- if (!mLayerLifecycleManagerEnabled) {
- return dumpHwcLayersMinidumpLockedLegacy(result);
- }
for (const auto& [token, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) {
const auto displayId = HalDisplayId::tryCast(display->getId());
if (!displayId) {
@@ -6910,8 +6822,7 @@
* Dump the visible layer list
*/
colorizer.bold(result);
- StringAppendF(&result, "SurfaceFlinger New Frontend Enabled:%s\n",
- mLayerLifecycleManagerEnabled ? "true" : "false");
+ StringAppendF(&result, "SurfaceFlinger New Frontend Enabled:%s\n", "true");
StringAppendF(&result, "Active Layers - layers with client handles (count = %zu)\n",
mNumLayers.load());
colorizer.reset(result);
@@ -8635,12 +8546,8 @@
}
void SurfaceFlinger::traverseLegacyLayers(const LayerVector::Visitor& visitor) const {
- if (mLayerLifecycleManagerEnabled) {
- for (auto& layer : mLegacyLayers) {
- visitor(layer.second.get());
- }
- } else {
- mDrawingState.traverse(visitor);
+ for (auto& layer : mLegacyLayers) {
+ visitor(layer.second.get());
}
}
@@ -9357,89 +9264,49 @@
void SurfaceFlinger::moveSnapshotsFromCompositionArgs(
compositionengine::CompositionRefreshArgs& refreshArgs,
const std::vector<std::pair<Layer*, LayerFE*>>& layers) {
- if (mLayerLifecycleManagerEnabled) {
- std::vector<std::unique_ptr<frontend::LayerSnapshot>>& snapshots =
- mLayerSnapshotBuilder.getSnapshots();
- for (auto [_, layerFE] : layers) {
- auto i = layerFE->mSnapshot->globalZ;
- snapshots[i] = std::move(layerFE->mSnapshot);
- }
- }
- if (!mLayerLifecycleManagerEnabled) {
- for (auto [layer, layerFE] : layers) {
- layer->updateLayerSnapshot(std::move(layerFE->mSnapshot));
- }
+ std::vector<std::unique_ptr<frontend::LayerSnapshot>>& snapshots =
+ mLayerSnapshotBuilder.getSnapshots();
+ for (auto [_, layerFE] : layers) {
+ auto i = layerFE->mSnapshot->globalZ;
+ snapshots[i] = std::move(layerFE->mSnapshot);
}
}
std::vector<std::pair<Layer*, LayerFE*>> SurfaceFlinger::moveSnapshotsToCompositionArgs(
compositionengine::CompositionRefreshArgs& refreshArgs, bool cursorOnly) {
std::vector<std::pair<Layer*, LayerFE*>> layers;
- if (mLayerLifecycleManagerEnabled) {
- nsecs_t currentTime = systemTime();
- const bool needsMetadata = mCompositionEngine->getFeatureFlags().test(
- compositionengine::Feature::kSnapshotLayerMetadata);
- mLayerSnapshotBuilder.forEachSnapshot(
- [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) FTL_FAKE_GUARD(
- kMainThreadContext) {
- if (cursorOnly &&
- snapshot->compositionType !=
- aidl::android::hardware::graphics::composer3::Composition::CURSOR) {
- return;
- }
-
- if (!snapshot->hasSomethingToDraw()) {
- return;
- }
-
- auto it = mLegacyLayers.find(snapshot->sequence);
- LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
- "Couldnt find layer object for %s",
- snapshot->getDebugString().c_str());
- auto& legacyLayer = it->second;
- sp<LayerFE> layerFE = legacyLayer->getCompositionEngineLayerFE(snapshot->path);
- snapshot->fps = getLayerFramerate(currentTime, snapshot->sequence);
- layerFE->mSnapshot = std::move(snapshot);
- refreshArgs.layers.push_back(layerFE);
- layers.emplace_back(legacyLayer.get(), layerFE.get());
- },
- [needsMetadata](const frontend::LayerSnapshot& snapshot) {
- return snapshot.isVisible ||
- (needsMetadata &&
- snapshot.changes.test(
- frontend::RequestedLayerState::Changes::Metadata));
- });
- }
- if (!mLayerLifecycleManagerEnabled) {
- auto moveSnapshots = [&layers, &refreshArgs, cursorOnly](Layer* layer) {
- if (const auto& layerFE = layer->getCompositionEngineLayerFE()) {
+ nsecs_t currentTime = systemTime();
+ const bool needsMetadata = mCompositionEngine->getFeatureFlags().test(
+ compositionengine::Feature::kSnapshotLayerMetadata);
+ mLayerSnapshotBuilder.forEachSnapshot(
+ [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) FTL_FAKE_GUARD(
+ kMainThreadContext) {
if (cursorOnly &&
- layer->getLayerSnapshot()->compositionType !=
- aidl::android::hardware::graphics::composer3::Composition::CURSOR)
+ snapshot->compositionType !=
+ aidl::android::hardware::graphics::composer3::Composition::CURSOR) {
return;
- layer->updateSnapshot(refreshArgs.updatingGeometryThisFrame);
- layerFE->mSnapshot = layer->stealLayerSnapshot();
+ }
+
+ if (!snapshot->hasSomethingToDraw()) {
+ return;
+ }
+
+ auto it = mLegacyLayers.find(snapshot->sequence);
+ LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
+ "Couldnt find layer object for %s",
+ snapshot->getDebugString().c_str());
+ auto& legacyLayer = it->second;
+ sp<LayerFE> layerFE = legacyLayer->getCompositionEngineLayerFE(snapshot->path);
+ snapshot->fps = getLayerFramerate(currentTime, snapshot->sequence);
+ layerFE->mSnapshot = std::move(snapshot);
refreshArgs.layers.push_back(layerFE);
- layers.emplace_back(layer, layerFE.get());
- }
- };
-
- if (cursorOnly || !mVisibleRegionsDirty) {
- // for hot path avoid traversals by walking though the previous composition list
- for (sp<Layer> layer : mPreviouslyComposedLayers) {
- moveSnapshots(layer.get());
- }
- } else {
- mPreviouslyComposedLayers.clear();
- mDrawingState.traverseInZOrder(
- [&moveSnapshots](Layer* layer) { moveSnapshots(layer); });
- mPreviouslyComposedLayers.reserve(layers.size());
- for (auto [layer, _] : layers) {
- mPreviouslyComposedLayers.push_back(sp<Layer>::fromExisting(layer));
- }
- }
- }
-
+ layers.emplace_back(legacyLayer.get(), layerFE.get());
+ },
+ [needsMetadata](const frontend::LayerSnapshot& snapshot) {
+ return snapshot.isVisible ||
+ (needsMetadata &&
+ snapshot.changes.test(frontend::RequestedLayerState::Changes::Metadata));
+ });
return layers;
}