Skip to content

Commit f9f3f96

Browse files
committed
SF: Allow multiple invalid stack layers through to CE
Currently, all duplicate stack layers are denied passage to the CompositionEngine. This makes sense when dealing with per-display on-screen content, but breaks apart if for mirrored and off-screen content. Allow multiple invalid (-1) stack layers through, as this state is used to represent stack layers that can be updated safely by multiple sources or are associated with one source. Fixes: 397775142 Test: atest SurfaceFlinger_test, atest MultiDisplayTest Flag: com.android.graphics.surfaceflinger.flags.reject_dupe_layerstacks Change-Id: Ic103471a8cc997eb30e7f14d08559e351b01b801
1 parent ca3bbac commit f9f3f96

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,18 +2856,20 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
28562856

28572857
// Tracks layer stacks of displays that are added to CompositionEngine output.
28582858
ui::DisplayMap<ui::LayerStack, ftl::Unit> outputLayerStacks;
2859-
auto isOutputLayerStack = [&outputLayerStacks](DisplayId id, ui::LayerStack layerStack) {
2860-
if (FlagManager::getInstance().reject_dupe_layerstacks() &&
2861-
outputLayerStacks.contains(layerStack)) {
2862-
// TODO: remove log and DisplayId from params once reject_dupe_layerstacks flag is
2863-
// removed
2864-
ALOGD("Existing layer stack ID %d output to another display %" PRIu64
2865-
", dropping display from outputs",
2866-
layerStack.id, id.value);
2867-
return true;
2859+
auto isUniqueOutputLayerStack = [&outputLayerStacks](DisplayId id, ui::LayerStack layerStack) {
2860+
if (FlagManager::getInstance().reject_dupe_layerstacks()) {
2861+
if (layerStack != ui::INVALID_LAYER_STACK && outputLayerStacks.contains(layerStack)) {
2862+
// TODO: remove log and DisplayId from params once reject_dupe_layerstacks flag is
2863+
// removed
2864+
ALOGD("Existing layer stack ID %d output to another display %" PRIu64
2865+
", dropping display from outputs",
2866+
layerStack.id, id.value);
2867+
return false;
2868+
}
28682869
}
2870+
28692871
outputLayerStacks.try_emplace(layerStack);
2870-
return false;
2872+
return true;
28712873
};
28722874

28732875
// Add outputs for physical displays.
@@ -2876,7 +2878,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
28762878

28772879
if (const auto display = getCompositionDisplayLocked(id)) {
28782880
const auto layerStack = physicalDisplayLayerStacks.get(id)->get();
2879-
if (!isOutputLayerStack(display->getId(), layerStack)) {
2881+
if (isUniqueOutputLayerStack(display->getId(), layerStack)) {
28802882
refreshArgs.outputs.push_back(display);
28812883
}
28822884
}
@@ -2895,7 +2897,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
28952897

28962898
if (!refreshRate.isValid() ||
28972899
mScheduler->isVsyncInPhase(pacesetterTarget.frameBeginTime(), refreshRate)) {
2898-
if (!isOutputLayerStack(display->getId(), display->getLayerStack())) {
2900+
if (isUniqueOutputLayerStack(display->getId(), display->getLayerStack())) {
28992901
refreshArgs.outputs.push_back(display->getCompositionDisplay());
29002902
}
29012903
}

0 commit comments

Comments
 (0)