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

Commit 35ebcac0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SF: Track display info required for frontend updates"

parents 562431f3 67b431ca
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@

#include "Display/DisplaySnapshot.h"
#include "DisplayDevice.h"
#include "FrontEnd/FrontEndDisplayInfo.h"
#include "Layer.h"
#include "RefreshRateOverlay.h"
#include "SurfaceFlinger.h"
@@ -131,7 +132,7 @@ void DisplayDevice::setDisplayName(const std::string& displayName) {
    }
}

auto DisplayDevice::getInputInfo() const -> InputInfo {
auto DisplayDevice::getFrontEndInfo() const -> FrontEndDisplayInfo {
    gui::DisplayInfo info;
    info.displayId = getLayerStack().id;

@@ -160,7 +161,9 @@ auto DisplayDevice::getInputInfo() const -> InputInfo {
    return {.info = info,
            .transform = displayTransform,
            .receivesInput = receivesInput(),
            .isSecure = isSecure()};
            .isSecure = isSecure(),
            .isPrimary = isPrimary(),
            .rotationFlags = ui::Transform::toRotationFlags(mOrientation)};
}

void DisplayDevice::setPowerMode(hal::PowerMode mode) {
+2 −9
Original line number Diff line number Diff line
@@ -45,11 +45,11 @@
#include "DisplayHardware/DisplayMode.h"
#include "DisplayHardware/Hal.h"
#include "DisplayHardware/PowerAdvisor.h"
#include "FrontEnd/FrontEndDisplayInfo.h"
#include "Scheduler/RefreshRateSelector.h"
#include "ThreadContext.h"
#include "TracedOrdinal.h"
#include "Utils/Dumper.h"

namespace android {

class Fence;
@@ -167,14 +167,7 @@ public:
    void setDisplayName(const std::string& displayName);
    const std::string& getDisplayName() const { return mDisplayName; }

    struct InputInfo {
        gui::DisplayInfo info;
        ui::Transform transform;
        bool receivesInput;
        bool isSecure;
    };

    InputInfo getInputInfo() const;
    surfaceflinger::FrontEndDisplayInfo getFrontEndInfo() const;

    /* ------------------------------------------------------------------------
     * Display power mode management.
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <gui/DisplayInfo.h>

// TODO (b/259553365) fix namespace to be consistent with other components
namespace android::surfaceflinger {

// Display information needed to populate input and calculate layer geometry.
struct FrontEndDisplayInfo {
    gui::DisplayInfo info;
    ui::Transform transform;
    bool receivesInput;
    bool isSecure;
    // TODO(b/238781169) can eliminate once sPrimaryDisplayRotationFlags is removed.
    bool isPrimary;
    ui::Transform::RotationFlags rotationFlags;
};

} // namespace android::surfaceflinger
+8 −27
Original line number Diff line number Diff line
@@ -3124,6 +3124,10 @@ void SurfaceFlinger::commitTransactionsLocked(uint32_t transactionFlags) {
    const bool displayTransactionNeeded = transactionFlags & eDisplayTransactionNeeded;
    if (displayTransactionNeeded) {
        processDisplayChangesLocked();
        mFrontEndDisplayInfos.clear();
        for (const auto& [_, display] : mDisplays) {
            mFrontEndDisplayInfos.try_emplace(display->getLayerStack(), display->getFrontEndInfo());
        }
    }
    mForceTransactionDisplayChange = displayTransactionNeeded;

@@ -3293,29 +3297,6 @@ void SurfaceFlinger::persistDisplayBrightness(bool needsComposite) {

void SurfaceFlinger::buildWindowInfos(std::vector<WindowInfo>& outWindowInfos,
                                      std::vector<DisplayInfo>& outDisplayInfos) {
    display::DisplayMap<ui::LayerStack, DisplayDevice::InputInfo> displayInputInfos;

    for (const auto& [_, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) {
        const auto layerStack = display->getLayerStack();
        const auto info = display->getInputInfo();

        const auto [it, emplaced] = displayInputInfos.try_emplace(layerStack, info);
        if (emplaced) {
            continue;
        }

        // If the layer stack is mirrored on multiple displays, the first display that is configured
        // to receive input takes precedence.
        auto& otherInfo = it->second;
        if (otherInfo.receivesInput) {
            ALOGW_IF(display->receivesInput(),
                     "Multiple displays claim to accept input for the same layer stack: %u",
                     layerStack.id);
        } else {
            otherInfo = info;
        }
    }

    static size_t sNumWindowInfos = 0;
    outWindowInfos.reserve(sNumWindowInfos);
    sNumWindowInfos = 0;
@@ -3323,8 +3304,8 @@ void SurfaceFlinger::buildWindowInfos(std::vector<WindowInfo>& outWindowInfos,
    mDrawingState.traverseInReverseZOrder([&](Layer* layer) {
        if (!layer->needsInputInfo()) return;

        const auto opt = displayInputInfos.get(layer->getLayerStack())
                                 .transform([](const DisplayDevice::InputInfo& info) {
        const auto opt = mFrontEndDisplayInfos.get(layer->getLayerStack())
                                 .transform([](const FrontEndDisplayInfo& info) {
                                     return Layer::InputDisplayArgs{&info.transform, info.isSecure};
                                 });

@@ -3333,8 +3314,8 @@ void SurfaceFlinger::buildWindowInfos(std::vector<WindowInfo>& outWindowInfos,

    sNumWindowInfos = outWindowInfos.size();

    outDisplayInfos.reserve(displayInputInfos.size());
    for (const auto& [_, info] : displayInputInfos) {
    outDisplayInfos.reserve(mFrontEndDisplayInfos.size());
    for (const auto& [_, info] : mFrontEndDisplayInfos) {
        outDisplayInfos.push_back(info.info);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@
#include "DisplayIdGenerator.h"
#include "Effects/Daltonizer.h"
#include "FlagManager.h"
#include "FrontEnd/FrontEndDisplayInfo.h"
#include "FrontEnd/LayerCreationArgs.h"
#include "FrontEnd/TransactionHandler.h"
#include "LayerVector.h"
@@ -1366,6 +1367,7 @@ private:
    } mPowerHintSessionMode;

    TransactionHandler mTransactionHandler;
    display::DisplayMap<ui::LayerStack, FrontEndDisplayInfo> mFrontEndDisplayInfos;
};

class SurfaceComposerAIDL : public gui::BnSurfaceComposer {