diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 2e00ca8939..10bdf942a5 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -226,7 +226,7 @@ struct SCOPED_CAPABILITY UnnecessaryLock { ~UnnecessaryLock() RELEASE() {} }; -// TODO(b/141333600): Consolidate with HWC2::Display::Config::Builder::getDefaultDensity. +// TODO(b/141333600): Consolidate with DisplayMode::Builder::getDefaultDensity. constexpr float FALLBACK_DENSITY = ACONFIGURATION_DENSITY_TV; float getDensityFromProperty(const char* property, bool required) { @@ -904,14 +904,14 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, configs->clear(); - for (const auto& hwConfig : getHwComposer().getConfigs(*displayId)) { + for (const auto& mode : getHwComposer().getModes(*displayId)) { DisplayConfig config; - auto width = hwConfig->getWidth(); - auto height = hwConfig->getHeight(); + auto width = mode->getWidth(); + auto height = mode->getHeight(); - auto xDpi = hwConfig->getDpiX(); - auto yDpi = hwConfig->getDpiY(); + auto xDpi = mode->getDpiX(); + auto yDpi = mode->getDpiY(); if (isInternal && (internalDisplayOrientation == ui::ROTATION_90 || @@ -930,14 +930,14 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, config.yDpi = yDpi; } - const nsecs_t period = hwConfig->getVsyncPeriod(); + const nsecs_t period = mode->getVsyncPeriod(); config.refreshRate = Fps::fromPeriodNsecs(period).getValue(); const auto vsyncConfigSet = mVsyncConfiguration->getConfigsForRefreshRate(Fps(config.refreshRate)); config.appVsyncOffset = vsyncConfigSet.late.appOffset; config.sfVsyncOffset = vsyncConfigSet.late.sfOffset; - config.configGroup = hwConfig->getConfigGroup(); + config.configGroup = mode->getConfigGroup(); // This is how far in advance a buffer must be queued for // presentation at a given time. If you want a buffer to appear @@ -1128,7 +1128,7 @@ void SurfaceFlinger::performSetActiveConfig() { auto refreshRate = mRefreshRateConfigs->getRefreshRateFromConfigId(desiredActiveConfig->configId); - ALOGV("performSetActiveConfig changing active config to %d(%s)", + ALOGV("performSetActiveConfig changing active config to %zu(%s)", refreshRate.getConfigId().value(), refreshRate.getName().c_str()); const auto display = getDefaultDisplayDeviceLocked(); if (!display || display->getActiveConfig() == desiredActiveConfig->configId) { @@ -1158,13 +1158,12 @@ void SurfaceFlinger::performSetActiveConfig() { hal::VsyncPeriodChangeTimeline outTimeline; auto status = - getHwComposer().setActiveConfigWithConstraints(displayId, - mUpcomingActiveConfig.configId.value(), - constraints, &outTimeline); + getHwComposer().setActiveModeWithConstraints(displayId, mUpcomingActiveConfig.configId, + constraints, &outTimeline); if (status != NO_ERROR) { - // setActiveConfigWithConstraints may fail if a hotplug event is just about + // setActiveModeWithConstraints may fail if a hotplug event is just about // to be sent. We just log the error in this case. - ALOGW("setActiveConfigWithConstraints failed: %d", status); + ALOGW("setActiveModeWithConstraints failed: %d", status); return; } @@ -1618,7 +1617,7 @@ void SurfaceFlinger::changeRefreshRateLocked(const RefreshRate& refreshRate, // Don't do any updating if the current fps is the same as the new one. if (!isDisplayConfigAllowed(refreshRate.getConfigId())) { - ALOGV("Skipping config %d as it is not part of allowed configs", + ALOGV("Skipping config %zu as it is not part of allowed configs", refreshRate.getConfigId().value()); return; } @@ -1663,7 +1662,7 @@ void SurfaceFlinger::onVsyncPeriodTimingChangedReceived( } void SurfaceFlinger::onSeamlessPossible(int32_t /*sequenceId*/, hal::HWDisplayId /*display*/) { - // TODO(b/142753666): use constraints when calling to setActiveConfigWithConstrains and + // TODO(b/142753666): use constraints when calling to setActiveModeWithConstraints and // use this callback to know when to retry in case of SEAMLESS_NOT_POSSIBLE. } @@ -2472,7 +2471,7 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal( Dataspace::UNKNOWN}); if (!state.isVirtual()) { const auto physicalId = display->getPhysicalId(); - auto activeConfigId = HwcConfigIndexType(getHwComposer().getActiveConfigIndex(physicalId)); + auto activeConfigId = getHwComposer().getActiveMode(physicalId)->getId(); display->setActiveConfig(activeConfigId); display->setDeviceProductInfo(state.physical->deviceProductInfo); } @@ -2492,7 +2491,7 @@ void SurfaceFlinger::processDisplayAdded(const wp<IBinder>& displayToken, ui::PixelFormat pixelFormat = static_cast<ui::PixelFormat>(PIXEL_FORMAT_UNKNOWN); if (state.physical) { const auto& activeConfig = - getCompositionEngine().getHwComposer().getActiveConfig(state.physical->id); + getCompositionEngine().getHwComposer().getActiveMode(state.physical->id); width = activeConfig->getWidth(); height = activeConfig->getHeight(); pixelFormat = static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888); @@ -2619,9 +2618,9 @@ void SurfaceFlinger::processDisplayChanged(const wp<IBinder>& displayToken, // TODO(b/175678251) Call a listener instead. if (currentState.physical->hwcDisplayId == getHwComposer().getInternalHwcDisplayId()) { const auto displayId = currentState.physical->id; - const auto configs = getHwComposer().getConfigs(displayId); - const auto currentConfig = - HwcConfigIndexType(getHwComposer().getActiveConfigIndex(displayId)); + const auto configs = getHwComposer().getModes(displayId); + const auto currentConfig = getHwComposer().getActiveMode(displayId)->getId(); + // TODO(b/175678215) Handle the case when currentConfig is not in configs mRefreshRateConfigs->updateDisplayConfigs(configs, currentConfig); mVsyncConfiguration->reset(); updatePhaseConfiguration(mRefreshRateConfigs->getCurrentRefreshRate()); @@ -2907,11 +2906,9 @@ void SurfaceFlinger::initScheduler(PhysicalDisplayId primaryDisplayId) { return; } - auto currentConfig = HwcConfigIndexType(getHwComposer().getActiveConfigIndex(primaryDisplayId)); - mRefreshRateConfigs = - std::make_unique<scheduler::RefreshRateConfigs>(getHwComposer().getConfigs( - primaryDisplayId), - currentConfig); + auto currentConfig = getHwComposer().getActiveMode(primaryDisplayId)->getId(); + const auto modes = getHwComposer().getModes(primaryDisplayId); + mRefreshRateConfigs = std::make_unique<scheduler::RefreshRateConfigs>(modes, currentConfig); const auto& currRefreshRate = mRefreshRateConfigs->getRefreshRateFromConfigId(currentConfig); mRefreshRateStats = std::make_unique<scheduler::RefreshRateStats>(*mTimeStats, currRefreshRate.getFps(), @@ -4797,7 +4794,7 @@ void SurfaceFlinger::dumpAllLocked(const DumpArgs& args, std::string& result) co if (const auto displayId = getInternalDisplayIdLocked(); displayId && getHwComposer().isConnected(*displayId)) { - const auto activeConfig = getHwComposer().getActiveConfig(*displayId); + const auto activeConfig = getHwComposer().getActiveMode(*displayId); std::string fps, xDpi, yDpi; if (activeConfig) { const auto vsyncPeriod = getHwComposer().getDisplayVsyncPeriod(*displayId); @@ -5327,7 +5324,7 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r ALOGE("No internal display found."); return NO_ERROR; } - const auto numConfigs = getHwComposer().getConfigs(*displayId).size(); + const auto numConfigs = getHwComposer().getModes(*displayId).size(); if (newConfigId >= 0 && newConfigId < numConfigs) { const auto displayToken = getInternalDisplayToken(); status_t result = setActiveConfig(displayToken, newConfigId); @@ -6017,7 +6014,7 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( if (!display->isPrimary()) { // TODO(b/144711714): For non-primary displays we should be able to set an active config - // as well. For now, just call directly to setActiveConfigWithConstraints but ideally + // as well. For now, just call directly to setActiveModeWithConstraints but ideally // it should go thru setDesiredActiveConfig, similar to primary display. ALOGV("setAllowedDisplayConfigsInternal for non-primary display"); const auto displayId = display->getPhysicalId(); @@ -6027,8 +6024,8 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( constraints.seamlessRequired = false; hal::VsyncPeriodChangeTimeline timeline = {0, 0, 0}; - if (getHwComposer().setActiveConfigWithConstraints(displayId, policy->defaultConfig.value(), - constraints, &timeline) < 0) { + if (getHwComposer().setActiveModeWithConstraints(displayId, policy->defaultConfig, + constraints, &timeline) < 0) { return BAD_VALUE; } if (timeline.refreshRequired) { @@ -6037,7 +6034,7 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( display->setActiveConfig(policy->defaultConfig); const nsecs_t vsyncPeriod = getHwComposer() - .getConfigs(displayId)[policy->defaultConfig.value()] + .getModes(displayId)[policy->defaultConfig.value()] ->getVsyncPeriod(); mScheduler->onNonPrimaryDisplayConfigChanged(mAppConnectionHandle, displayId, policy->defaultConfig, vsyncPeriod); @@ -6077,16 +6074,16 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( ? mRefreshRateConfigs->getRefreshRateFromConfigId(*configId) // NOTE: Choose the default config ID, if Scheduler doesn't have one in mind. : mRefreshRateConfigs->getRefreshRateFromConfigId(currentPolicy.defaultConfig); - ALOGV("trying to switch to Scheduler preferred config %d (%s)", + ALOGV("trying to switch to Scheduler preferred config %zu (%s)", preferredRefreshRate.getConfigId().value(), preferredRefreshRate.getName().c_str()); if (isDisplayConfigAllowed(preferredRefreshRate.getConfigId())) { - ALOGV("switching to Scheduler preferred config %d", + ALOGV("switching to Scheduler preferred config %zu", preferredRefreshRate.getConfigId().value()); setDesiredActiveConfig( {preferredRefreshRate.getConfigId(), Scheduler::ConfigEvent::Changed}); } else { - LOG_ALWAYS_FATAL("Desired config not allowed: %d", + LOG_ALWAYS_FATAL("Desired config not allowed: %zu", preferredRefreshRate.getConfigId().value()); } @@ -6158,9 +6155,10 @@ status_t SurfaceFlinger::getDesiredDisplayConfigSpecs( return INVALID_OPERATION; } else { const auto displayId = display->getPhysicalId(); - *outDefaultConfig = getHwComposer().getActiveConfigIndex(displayId); + const auto activeMode = getHwComposer().getActiveMode(displayId); + *outDefaultConfig = activeMode->getId().value(); *outAllowGroupSwitching = false; - auto vsyncPeriod = getHwComposer().getActiveConfig(displayId)->getVsyncPeriod(); + auto vsyncPeriod = activeMode->getVsyncPeriod(); *outPrimaryRefreshRateMin = Fps::fromPeriodNsecs(vsyncPeriod).getValue(); *outPrimaryRefreshRateMax = Fps::fromPeriodNsecs(vsyncPeriod).getValue(); *outAppRequestRefreshRateMin = Fps::fromPeriodNsecs(vsyncPeriod).getValue(); |