diff options
| -rw-r--r-- | services/surfaceflinger/DisplayDevice.cpp | 7 | ||||
| -rw-r--r-- | services/surfaceflinger/DisplayDevice.h | 11 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/FrontEndDisplayInfo.h | 35 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 35 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 2 |
5 files changed, 52 insertions, 38 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 9868c8ead8..c5f5372f19 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -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) { diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h index 1602a71709..afa13e5795 100644 --- a/services/surfaceflinger/DisplayDevice.h +++ b/services/surfaceflinger/DisplayDevice.h @@ -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. diff --git a/services/surfaceflinger/FrontEnd/FrontEndDisplayInfo.h b/services/surfaceflinger/FrontEnd/FrontEndDisplayInfo.h new file mode 100644 index 0000000000..95e69b33e2 --- /dev/null +++ b/services/surfaceflinger/FrontEnd/FrontEndDisplayInfo.h @@ -0,0 +1,35 @@ +/* + * 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 diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index dc9129ce78..4365b64610 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -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); } } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index c2d33436df..7c0926a1ee 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -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 { |