diff options
| author | 2019-04-11 00:12:02 +0000 | |
|---|---|---|
| committer | 2019-04-11 00:12:02 +0000 | |
| commit | e5fa4b1d943624d184e0e41d215e1fab47acb3ad (patch) | |
| tree | 905df7bba437ae930c9deea19bb8e95c8e5ae0fe | |
| parent | 2dada69853262884ed0d1baaf0e873894d2d7464 (diff) | |
| parent | 7e3aa764499562f69e624e3e8240eab3707c7dda (diff) | |
Merge "Fix early firing when adding event listeners" into qt-dev
| -rw-r--r-- | services/surfaceflinger/Scheduler/DispSync.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/services/surfaceflinger/Scheduler/DispSync.cpp b/services/surfaceflinger/Scheduler/DispSync.cpp index 0738c6d236..871f556988 100644 --- a/services/surfaceflinger/Scheduler/DispSync.cpp +++ b/services/surfaceflinger/Scheduler/DispSync.cpp @@ -212,11 +212,14 @@ public: const nsecs_t predictedReference = mReferenceTime + numPeriodsSinceReference * mPeriod; listener.mLastEventTime = predictedReference + mPhase + listener.mPhase; // If we're very close in time to the predicted last event time, + // and we're not very close to the next predicted last event time // then we need to back up the last event time so that we can // attempt to fire an event immediately. // - // Otherwise, keep the last event time that we predicted. - if (isShorterThanPeriod(now - listener.mLastEventTime)) { + // Otherwise, keep the last event time that we predicted so that + // we don't wake up early. + if (isShorterThanPeriod(now - listener.mLastEventTime) && + !isShorterThanPeriod(listener.mLastEventTime + mPeriod - now)) { listener.mLastEventTime -= mPeriod; } } else { |