SF: Rename HwcConfigIndexType to DisplayModeId
Bug: 159590486
Bug: 176148651
Test: atest libsurfaceflinger_unittest
Change-Id: Ie177b213bb7a8ab9f67a51d2b5cf27d8fd97b780
diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp
index b63e8c8..c12a7b1 100644
--- a/services/surfaceflinger/Scheduler/EventThread.cpp
+++ b/services/surfaceflinger/Scheduler/EventThread.cpp
@@ -41,9 +41,10 @@
#include <utils/Errors.h>
#include <utils/Trace.h>
-#include "EventThread.h"
+#include "DisplayHardware/DisplayMode.h"
#include "FrameTimeline.h"
-#include "HwcStrongTypes.h"
+
+#include "EventThread.h"
#undef LOG_TAG
#define LOG_TAG "EventThread"
@@ -117,8 +118,8 @@
return event;
}
-DisplayEventReceiver::Event makeConfigChanged(PhysicalDisplayId displayId,
- HwcConfigIndexType configId, nsecs_t vsyncPeriod) {
+DisplayEventReceiver::Event makeConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId,
+ nsecs_t vsyncPeriod) {
DisplayEventReceiver::Event event;
event.header = {DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED, displayId, systemTime()};
event.config.configId = configId.value();
@@ -368,7 +369,7 @@
mCondition.notify_all();
}
-void EventThread::onConfigChanged(PhysicalDisplayId displayId, HwcConfigIndexType configId,
+void EventThread::onConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId,
nsecs_t vsyncPeriod) {
std::lock_guard<std::mutex> lock(mMutex);
diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h
index e75b718..15efe21 100644
--- a/services/surfaceflinger/Scheduler/EventThread.h
+++ b/services/surfaceflinger/Scheduler/EventThread.h
@@ -31,7 +31,7 @@
#include <thread>
#include <vector>
-#include "HwcStrongTypes.h"
+#include "DisplayHardware/DisplayMode.h"
// ---------------------------------------------------------------------------
namespace android {
@@ -124,7 +124,7 @@
virtual void onHotplugReceived(PhysicalDisplayId displayId, bool connected) = 0;
// called when SF changes the active config and apps needs to be notified about the change
- virtual void onConfigChanged(PhysicalDisplayId displayId, HwcConfigIndexType configId,
+ virtual void onConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId,
nsecs_t vsyncPeriod) = 0;
// called when SF updates the Frame Rate Override list
@@ -173,7 +173,7 @@
void onHotplugReceived(PhysicalDisplayId displayId, bool connected) override;
- void onConfigChanged(PhysicalDisplayId displayId, HwcConfigIndexType configId,
+ void onConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId,
nsecs_t vsyncPeriod) override;
void onFrameRateOverridesChanged(PhysicalDisplayId displayId,
diff --git a/services/surfaceflinger/Scheduler/HwcStrongTypes.h b/services/surfaceflinger/Scheduler/HwcStrongTypes.h
deleted file mode 100644
index b6a33a2..0000000
--- a/services/surfaceflinger/Scheduler/HwcStrongTypes.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2019 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 "StrongTyping.h"
-
-#include <cstddef>
-
-namespace android {
-
-// Strong types for the different indexes as they are referring to a different base.
-using HwcConfigIndexType = StrongTyping<size_t, struct HwcConfigIndexTypeTag, Compare, Add, Hash>;
-
-} // namespace android
\ No newline at end of file
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
index b02596a..0f1e267 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
@@ -489,7 +489,7 @@
}
std::optional<Fps> RefreshRateConfigs::onKernelTimerChanged(
- std::optional<HwcConfigIndexType> desiredActiveConfigId, bool timerExpired) const {
+ std::optional<DisplayModeId> desiredActiveConfigId, bool timerExpired) const {
std::lock_guard lock(mLock);
const auto& current = desiredActiveConfigId ? *mRefreshRates.at(*desiredActiveConfigId)
@@ -554,26 +554,25 @@
return *mRefreshRates.at(getCurrentPolicyLocked()->defaultConfig);
}
-void RefreshRateConfigs::setCurrentConfigId(HwcConfigIndexType configId) {
+void RefreshRateConfigs::setCurrentConfigId(DisplayModeId configId) {
std::lock_guard lock(mLock);
mCurrentRefreshRate = mRefreshRates.at(configId).get();
}
-RefreshRateConfigs::RefreshRateConfigs(const DisplayModes& configs,
- HwcConfigIndexType currentConfigId)
+RefreshRateConfigs::RefreshRateConfigs(const DisplayModes& configs, DisplayModeId currentConfigId)
: mKnownFrameRates(constructKnownFrameRates(configs)) {
updateDisplayConfigs(configs, currentConfigId);
}
void RefreshRateConfigs::updateDisplayConfigs(const DisplayModes& configs,
- HwcConfigIndexType currentConfigId) {
+ DisplayModeId currentConfigId) {
std::lock_guard lock(mLock);
LOG_ALWAYS_FATAL_IF(configs.empty());
LOG_ALWAYS_FATAL_IF(currentConfigId.value() >= configs.size());
mRefreshRates.clear();
- for (auto configId = HwcConfigIndexType(0); configId.value() < configs.size(); configId++) {
- const auto& config = configs.at(static_cast<size_t>(configId.value()));
+ for (const auto& config : configs) {
+ const auto configId = config->getId();
const auto fps = Fps::fromPeriodNsecs(config->getVsyncPeriod());
mRefreshRates.emplace(configId,
std::make_unique<RefreshRate>(configId, config, fps,
@@ -663,7 +662,7 @@
return mDisplayManagerPolicy;
}
-bool RefreshRateConfigs::isConfigAllowed(HwcConfigIndexType config) const {
+bool RefreshRateConfigs::isConfigAllowed(DisplayModeId config) const {
std::lock_guard lock(mLock);
for (const RefreshRate* refreshRate : mAppRequestRefreshRates) {
if (refreshRate->configId == config) {
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
index a5d37c2..ef193ca 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
@@ -27,7 +27,6 @@
#include "DisplayHardware/DisplayMode.h"
#include "DisplayHardware/HWComposer.h"
#include "Fps.h"
-#include "HwcStrongTypes.h"
#include "Scheduler/SchedulerUtils.h"
#include "Scheduler/Seamlessness.h"
#include "Scheduler/StrongTyping.h"
@@ -65,10 +64,10 @@
};
public:
- RefreshRate(HwcConfigIndexType configId, DisplayModePtr config, Fps fps, ConstructorTag)
+ RefreshRate(DisplayModeId configId, DisplayModePtr config, Fps fps, ConstructorTag)
: configId(configId), hwcConfig(config), fps(std::move(fps)) {}
- HwcConfigIndexType getConfigId() const { return configId; }
+ DisplayModeId getConfigId() const { return configId; }
nsecs_t getVsyncPeriod() const { return hwcConfig->getVsyncPeriod(); }
int32_t getConfigGroup() const { return hwcConfig->getConfigGroup(); }
std::string getName() const { return to_string(fps); }
@@ -99,7 +98,7 @@
// This config ID corresponds to the position of the config in the vector that is stored
// on the device.
- const HwcConfigIndexType configId;
+ const DisplayModeId configId;
// The config itself
DisplayModePtr hwcConfig;
// Refresh rate in frames per second
@@ -107,7 +106,7 @@
};
using AllRefreshRatesMapType =
- std::unordered_map<HwcConfigIndexType, std::unique_ptr<const RefreshRate>>;
+ std::unordered_map<DisplayModeId, std::unique_ptr<const RefreshRate>>;
struct FpsRange {
Fps min{0.0f};
@@ -131,7 +130,7 @@
public:
// The default config, used to ensure we only initiate display config switches within the
// same config group as defaultConfigId's group.
- HwcConfigIndexType defaultConfig;
+ DisplayModeId defaultConfig;
// Whether or not we switch config groups to get the best frame rate.
bool allowGroupSwitching = kAllowGroupSwitchingDefault;
// The primary refresh rate range represents display manager's general guidance on the
@@ -148,18 +147,18 @@
Policy() = default;
- Policy(HwcConfigIndexType defaultConfig, const FpsRange& range)
+ Policy(DisplayModeId defaultConfig, const FpsRange& range)
: Policy(defaultConfig, kAllowGroupSwitchingDefault, range, range) {}
- Policy(HwcConfigIndexType defaultConfig, bool allowGroupSwitching, const FpsRange& range)
+ Policy(DisplayModeId defaultConfig, bool allowGroupSwitching, const FpsRange& range)
: Policy(defaultConfig, allowGroupSwitching, range, range) {}
- Policy(HwcConfigIndexType defaultConfig, const FpsRange& primaryRange,
+ Policy(DisplayModeId defaultConfig, const FpsRange& primaryRange,
const FpsRange& appRequestRange)
: Policy(defaultConfig, kAllowGroupSwitchingDefault, primaryRange, appRequestRange) {}
- Policy(HwcConfigIndexType defaultConfig, bool allowGroupSwitching,
- const FpsRange& primaryRange, const FpsRange& appRequestRange)
+ Policy(DisplayModeId defaultConfig, bool allowGroupSwitching, const FpsRange& primaryRange,
+ const FpsRange& appRequestRange)
: defaultConfig(defaultConfig),
allowGroupSwitching(allowGroupSwitching),
primaryRange(primaryRange),
@@ -199,7 +198,7 @@
Policy getDisplayManagerPolicy() const EXCLUDES(mLock);
// Returns true if config is allowed by the current policy.
- bool isConfigAllowed(HwcConfigIndexType config) const EXCLUDES(mLock);
+ bool isConfigAllowed(DisplayModeId config) const EXCLUDES(mLock);
// Describes the different options the layer voted for refresh rate
enum class LayerVoteType {
@@ -265,7 +264,7 @@
return {mMinSupportedRefreshRate->getFps(), mMaxSupportedRefreshRate->getFps()};
}
- std::optional<Fps> onKernelTimerChanged(std::optional<HwcConfigIndexType> desiredActiveConfigId,
+ std::optional<Fps> onKernelTimerChanged(std::optional<DisplayModeId> desiredActiveConfigId,
bool timerExpired) const EXCLUDES(mLock);
// Returns the highest refresh rate according to the current policy. May change at runtime. Only
@@ -279,16 +278,16 @@
// the policy.
RefreshRate getCurrentRefreshRateByPolicy() const;
- // Returns the refresh rate that corresponds to a HwcConfigIndexType. This may change at
+ // Returns the refresh rate that corresponds to a DisplayModeId. This may change at
// runtime.
// TODO(b/159590486) An invalid config id may be given here if the dipslay configs have changed.
- RefreshRate getRefreshRateFromConfigId(HwcConfigIndexType configId) const EXCLUDES(mLock) {
+ RefreshRate getRefreshRateFromConfigId(DisplayModeId configId) const EXCLUDES(mLock) {
std::lock_guard lock(mLock);
return *mRefreshRates.at(configId);
};
// Stores the current configId the device operates at
- void setCurrentConfigId(HwcConfigIndexType configId) EXCLUDES(mLock);
+ void setCurrentConfigId(DisplayModeId configId) EXCLUDES(mLock);
// Returns a string that represents the layer vote type
static std::string layerVoteTypeString(LayerVoteType vote);
@@ -296,9 +295,9 @@
// Returns a known frame rate that is the closest to frameRate
Fps findClosestKnownFrameRate(Fps frameRate) const;
- RefreshRateConfigs(const DisplayModes& configs, HwcConfigIndexType currentConfigId);
+ RefreshRateConfigs(const DisplayModes& configs, DisplayModeId currentConfigId);
- void updateDisplayConfigs(const DisplayModes& configs, HwcConfigIndexType currentConfig)
+ void updateDisplayConfigs(const DisplayModes& configs, DisplayModeId currentConfig)
EXCLUDES(mLock);
// Returns whether switching configs (refresh rate or resolution) is possible.
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 92786fd..588b83d 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -349,7 +349,7 @@
}
void Scheduler::onPrimaryDisplayConfigChanged(ConnectionHandle handle, PhysicalDisplayId displayId,
- HwcConfigIndexType configId, nsecs_t vsyncPeriod) {
+ DisplayModeId configId, nsecs_t vsyncPeriod) {
{
std::lock_guard<std::mutex> lock(mFeatureStateLock);
// Cache the last reported config for primary display.
@@ -389,7 +389,7 @@
void Scheduler::onNonPrimaryDisplayConfigChanged(ConnectionHandle handle,
PhysicalDisplayId displayId,
- HwcConfigIndexType configId, nsecs_t vsyncPeriod) {
+ DisplayModeId configId, nsecs_t vsyncPeriod) {
android::EventThread* thread;
{
std::lock_guard<std::mutex> lock(mConnectionsLock);
@@ -603,7 +603,7 @@
scheduler::LayerHistory::Summary summary = mLayerHistory->summarize(systemTime());
scheduler::RefreshRateConfigs::GlobalSignals consideredSignals;
- HwcConfigIndexType newConfigId;
+ DisplayModeId newConfigId;
bool frameRateChanged;
bool frameRateOverridesChanged;
{
@@ -789,7 +789,7 @@
template <class T>
bool Scheduler::handleTimerStateChanged(T* currentState, T newState) {
- HwcConfigIndexType newConfigId;
+ DisplayModeId newConfigId;
bool refreshRateChanged = false;
bool frameRateOverridesChanged;
scheduler::RefreshRateConfigs::GlobalSignals consideredSignals;
@@ -829,7 +829,7 @@
return consideredSignals.touch;
}
-HwcConfigIndexType Scheduler::calculateRefreshRateConfigIndexType(
+DisplayModeId Scheduler::calculateRefreshRateConfigIndexType(
scheduler::RefreshRateConfigs::GlobalSignals* consideredSignals) {
ATRACE_CALL();
if (consideredSignals) *consideredSignals = {};
@@ -851,7 +851,7 @@
.getConfigId();
}
-std::optional<HwcConfigIndexType> Scheduler::getPreferredConfigId() {
+std::optional<DisplayModeId> Scheduler::getPreferredConfigId() {
std::lock_guard<std::mutex> lock(mFeatureStateLock);
// Make sure that the default config ID is first updated, before returned.
if (mFeatures.configId.has_value()) {
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index cae3fe7..340ca8e 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -87,11 +87,10 @@
sp<EventThreadConnection> getEventConnection(ConnectionHandle);
void onHotplugReceived(ConnectionHandle, PhysicalDisplayId, bool connected);
- void onPrimaryDisplayConfigChanged(ConnectionHandle, PhysicalDisplayId,
- HwcConfigIndexType configId, nsecs_t vsyncPeriod)
- EXCLUDES(mFeatureStateLock);
+ void onPrimaryDisplayConfigChanged(ConnectionHandle, PhysicalDisplayId, DisplayModeId configId,
+ nsecs_t vsyncPeriod) EXCLUDES(mFeatureStateLock);
void onNonPrimaryDisplayConfigChanged(ConnectionHandle, PhysicalDisplayId,
- HwcConfigIndexType configId, nsecs_t vsyncPeriod);
+ DisplayModeId configId, nsecs_t vsyncPeriod);
void onScreenAcquired(ConnectionHandle);
void onScreenReleased(ConnectionHandle);
@@ -154,7 +153,7 @@
void dumpVsync(std::string&) const;
// Get the appropriate refresh for current conditions.
- std::optional<HwcConfigIndexType> getPreferredConfigId();
+ std::optional<DisplayModeId> getPreferredConfigId();
// Notifies the scheduler about a refresh rate timeline change.
void onNewVsyncPeriodChangeTimeline(const hal::VsyncPeriodChangeTimeline& timeline);
@@ -226,9 +225,9 @@
void setVsyncPeriod(nsecs_t period);
// This function checks whether individual features that are affecting the refresh rate
- // selection were initialized, prioritizes them, and calculates the HwcConfigIndexType
+ // selection were initialized, prioritizes them, and calculates the DisplayModeId
// for the suggested refresh rate.
- HwcConfigIndexType calculateRefreshRateConfigIndexType(
+ DisplayModeId calculateRefreshRateConfigIndexType(
scheduler::RefreshRateConfigs::GlobalSignals* consideredSignals = nullptr)
REQUIRES(mFeatureStateLock);
@@ -284,7 +283,7 @@
TouchState touch = TouchState::Inactive;
TimerState displayPowerTimer = TimerState::Expired;
- std::optional<HwcConfigIndexType> configId;
+ std::optional<DisplayModeId> configId;
LayerHistory::Summary contentRequirements;
bool isDisplayPowerStateNormal = true;
@@ -293,7 +292,7 @@
struct ConfigChangedParams {
ConnectionHandle handle;
PhysicalDisplayId displayId;
- HwcConfigIndexType configId;
+ DisplayModeId configId;
nsecs_t vsyncPeriod;
};