diff options
author | 2020-07-22 21:16:18 -0700 | |
---|---|---|
committer | 2020-08-24 18:12:07 -0700 | |
commit | 9c53ee710ecfe4657d08ce58f1609dfb0350237d (patch) | |
tree | c15ad8836a90a15e8b0649680f7aed2bda0d8cd1 /services/surfaceflinger/SurfaceFlinger.cpp | |
parent | 60bc00c11df600575e85b4c3276027bcd6069c9b (diff) |
SurfaceFlinger: use duration instead of offset
This change is using the duration given to sf/app without
converting them back to the legacy offset. This allows us to get
the expected vsync associated with a wakeup event.
This change also required some refactoring:
- Move the periodic callback interface out of DispSync and in
to DispSyncSource
- Translate legacy offsets to duration in case that duration
is not specified in the build files
- Add support to VSD to expose the deadline timestamp of when
a frame needs to be ready by
Bug: 162888874
Test: SF unit tests
Test: examine systraces
Change-Id: I87a53cc7dea931d3c195eab6842e003ca4516885
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 2b642a2590..b30b0ec18f 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1452,7 +1452,11 @@ status_t SurfaceFlinger::enableVSyncInjections(bool enable) { status_t SurfaceFlinger::injectVSync(nsecs_t when) { Mutex::Autolock lock(mStateLock); - return mScheduler->injectVSync(when, calculateExpectedPresentTime(when)) ? NO_ERROR : BAD_VALUE; + const auto expectedPresent = calculateExpectedPresentTime(when); + return mScheduler->injectVSync(when, /*expectedVSyncTime=*/expectedPresent, + /*deadlineTimestamp=*/expectedPresent) + ? NO_ERROR + : BAD_VALUE; } status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) { @@ -2984,14 +2988,16 @@ void SurfaceFlinger::initScheduler(PhysicalDisplayId primaryDisplayId) { // start the EventThread mScheduler = getFactory().createScheduler(*mRefreshRateConfigs, *this); + const auto configs = mVsyncConfiguration->getCurrentConfigs(); mAppConnectionHandle = mScheduler->createConnection("app", - mVsyncConfiguration->getCurrentConfigs().late.appOffset, + /*workDuration=*/configs.late.appWorkDuration, + /*readyDuration=*/configs.late.sfWorkDuration, impl::EventThread::InterceptVSyncsCallback()); mSfConnectionHandle = mScheduler->createConnection("sf", - mVsyncConfiguration->getCurrentConfigs().late.sfOffset, - [this](nsecs_t timestamp) { + /*workDuration=*/configs.late.sfWorkDuration, + /*readyDuration=*/0ns, [this](nsecs_t timestamp) { mInterceptor->saveVSyncEvent(timestamp); }); @@ -3024,8 +3030,12 @@ void SurfaceFlinger::updatePhaseConfiguration(const RefreshRate& refreshRate) { } void SurfaceFlinger::setVsyncConfig(const VsyncModulator::VsyncConfig& config) { - mScheduler->setPhaseOffset(mAppConnectionHandle, config.appOffset); - mScheduler->setPhaseOffset(mSfConnectionHandle, config.sfOffset); + mScheduler->setDuration(mAppConnectionHandle, + /*workDuration=*/config.appWorkDuration, + /*readyDuration=*/config.sfWorkDuration); + mScheduler->setDuration(mSfConnectionHandle, + /*workDuration=*/config.sfWorkDuration, + /*readyDuration=*/0ns); } void SurfaceFlinger::commitTransaction() { @@ -5170,14 +5180,14 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r mForceFullDamage = n != 0; return NO_ERROR; } - case 1018: { // Modify Choreographer's phase offset + case 1018: { // Modify Choreographer's duration n = data.readInt32(); - mScheduler->setPhaseOffset(mAppConnectionHandle, static_cast<nsecs_t>(n)); + mScheduler->setDuration(mAppConnectionHandle, std::chrono::nanoseconds(n), 0ns); return NO_ERROR; } - case 1019: { // Modify SurfaceFlinger's phase offset + case 1019: { // Modify SurfaceFlinger's duration n = data.readInt32(); - mScheduler->setPhaseOffset(mSfConnectionHandle, static_cast<nsecs_t>(n)); + mScheduler->setDuration(mSfConnectionHandle, std::chrono::nanoseconds(n), 0ns); return NO_ERROR; } case 1020: { // Layer updates interceptor |