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

Commit f9f3f967 authored by Gil Dekel's avatar Gil Dekel
Browse files

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
parent ca3bbac5
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -2856,18 +2856,20 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(

    // Tracks layer stacks of displays that are added to CompositionEngine output.
    ui::DisplayMap<ui::LayerStack, ftl::Unit> outputLayerStacks;
    auto isOutputLayerStack = [&outputLayerStacks](DisplayId id, ui::LayerStack layerStack) {
        if (FlagManager::getInstance().reject_dupe_layerstacks() &&
            outputLayerStacks.contains(layerStack)) {
    auto isUniqueOutputLayerStack = [&outputLayerStacks](DisplayId id, ui::LayerStack layerStack) {
        if (FlagManager::getInstance().reject_dupe_layerstacks()) {
            if (layerStack != ui::INVALID_LAYER_STACK && outputLayerStacks.contains(layerStack)) {
                // TODO: remove log and DisplayId from params once reject_dupe_layerstacks flag is
                // removed
                ALOGD("Existing layer stack ID %d output to another display %" PRIu64
                      ", dropping display from outputs",
                      layerStack.id, id.value);
            return true;
                return false;
            }
        }

        outputLayerStacks.try_emplace(layerStack);
        return false;
        return true;
    };

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

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

            if (!refreshRate.isValid() ||
                mScheduler->isVsyncInPhase(pacesetterTarget.frameBeginTime(), refreshRate)) {
                if (!isOutputLayerStack(display->getId(), display->getLayerStack())) {
                if (isUniqueOutputLayerStack(display->getId(), display->getLayerStack())) {
                    refreshArgs.outputs.push_back(display->getCompositionDisplay());
                }
            }