summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2019-10-28 16:18:59 -0700
committer Alec Mouri <alecmouri@google.com> 2019-12-26 10:28:47 -0800
commit60aee1c46b52852e140f05748f69e38f4e3de36e (patch)
tree7a29657039f1f8911fdef5689aa39e7fd4f3f6bd /services/surfaceflinger/SurfaceFlinger.cpp
parent516de508aa52a0907a496890dc191501481bca7b (diff)
[AChoreographer] Add refresh rate callback.
This will augment the NDK to respond to display events where the display refresh rate changes. Consumers of this api will include: * HWUI, for implementing a policy for determining whether to use render-ahead, * Swappy, to potentially replace jumping into Java from native code to respond to display evnets there. * Any other native app that would rely on the up-to-date display refresh rate. Currently however this is not yet exposed to NDK as CTS is not yet written. Once CTS is written then this will be formally exposed to NDK. For now we'll leave these as APEX apis to represent incremental progress. Bug: 136262896 Test: builds Change-Id: I66d393f93eb5d681547411e330ef1b8950a35c5d
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index fed2395fc6..6e827ac4bb 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -956,8 +956,11 @@ void SurfaceFlinger::setActiveConfigInternal() {
ATRACE_INT("ActiveConfigFPS", refreshRate.fps);
if (mUpcomingActiveConfig.event != Scheduler::ConfigEvent::None) {
+ const nsecs_t vsyncPeriod =
+ mRefreshRateConfigs->getRefreshRateFromConfigId(mUpcomingActiveConfig.configId)
+ .vsyncPeriod;
mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value,
- mUpcomingActiveConfig.configId);
+ mUpcomingActiveConfig.configId, vsyncPeriod);
}
}
@@ -2614,6 +2617,17 @@ void SurfaceFlinger::initScheduler(DisplayId primaryDisplayId) {
mRegionSamplingThread =
new RegionSamplingThread(*this, *mScheduler,
RegionSamplingThread::EnvironmentTimingTunables());
+ // Dispatch a config change request for the primary display on scheduler
+ // initialization, so that the EventThreads always contain a reference to a
+ // prior configuration.
+ //
+ // This is a bit hacky, but this avoids a back-pointer into the main SF
+ // classes from EventThread, and there should be no run-time binder cost
+ // anyway since there are no connected apps at this point.
+ const nsecs_t vsyncPeriod =
+ mRefreshRateConfigs->getRefreshRateFromConfigId(currentConfig).vsyncPeriod;
+ mScheduler->onConfigChanged(mAppConnectionHandle, primaryDisplayId.value, currentConfig,
+ vsyncPeriod);
}
void SurfaceFlinger::commitTransaction()
@@ -5499,7 +5513,10 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal(const sp<DisplayDe
auto configId = HwcConfigIndexType(defaultConfig);
display->setActiveConfig(configId);
- mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value, configId);
+ const nsecs_t vsyncPeriod =
+ mRefreshRateConfigs->getRefreshRateFromConfigId(configId).vsyncPeriod;
+ mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value, configId,
+ vsyncPeriod);
return NO_ERROR;
}
@@ -5523,8 +5540,10 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal(const sp<DisplayDe
// TODO(b/140204874): This hack triggers a notification that something has changed, so
// that listeners that care about a change in allowed configs can get the notification.
// Giving current ActiveConfig so that most other listeners would just drop the event
+ const nsecs_t vsyncPeriod =
+ mRefreshRateConfigs->getRefreshRateFromConfigId(display->getActiveConfig()).vsyncPeriod;
mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value,
- display->getActiveConfig());
+ display->getActiveConfig(), vsyncPeriod);
if (mRefreshRateConfigs->refreshRateSwitchingSupported()) {
auto configId = mScheduler->getPreferredConfigId();