Loading services/surfaceflinger/Scheduler/VSyncPredictor.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ VSyncPredictor::VSyncPredictor(nsecs_t idealPeriod, size_t historySize, kMinimumSamplesForPrediction(minimumSamplesForPrediction), kOutlierTolerancePercent(std::min(outlierTolerancePercent, kMaxPercent)), mIdealPeriod(idealPeriod) { mRateMap[mIdealPeriod] = {idealPeriod, 0}; resetModel(); } inline size_t VSyncPredictor::next(int i) const { Loading Loading @@ -203,6 +203,10 @@ void VSyncPredictor::setPeriod(nsecs_t period) { mRateMap[mIdealPeriod] = {period, 0}; } clearTimestamps(); } void VSyncPredictor::clearTimestamps() { if (!timestamps.empty()) { mKnownTimestamp = *std::max_element(timestamps.begin(), timestamps.end()); timestamps.clear(); Loading @@ -227,6 +231,12 @@ bool VSyncPredictor::needsMoreSamples(nsecs_t now) const { return needsMoreSamples; } void VSyncPredictor::resetModel() { std::lock_guard<std::mutex> lk(mMutex); mRateMap[mIdealPeriod] = {mIdealPeriod, 0}; clearTimestamps(); } } // namespace android::scheduler // TODO(b/129481165): remove the #pragma below and fix conversion issues Loading services/surfaceflinger/Scheduler/VSyncPredictor.h +3 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ public: void addVsyncTimestamp(nsecs_t timestamp) final; nsecs_t nextAnticipatedVSyncTimeFrom(nsecs_t timePoint) const final; nsecs_t currentPeriod() const final; void resetModel() final; /* * Inform the model that the period is anticipated to change to a new value. Loading @@ -48,7 +49,7 @@ public: * * \param [in] period The new period that should be used. */ void setPeriod(nsecs_t period); void setPeriod(nsecs_t period) final; /* Query if the model is in need of more samples to make a prediction at timePoint. * \param [in] timePoint The timePoint to inquire of. Loading @@ -61,6 +62,7 @@ public: private: VSyncPredictor(VSyncPredictor const&) = delete; VSyncPredictor& operator=(VSyncPredictor const&) = delete; void clearTimestamps() REQUIRES(mMutex); size_t const kHistorySize; size_t const kMinimumSamplesForPrediction; Loading services/surfaceflinger/Scheduler/VSyncReactor.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -199,7 +199,9 @@ nsecs_t VSyncReactor::getPeriod() { return mTracker->currentPeriod(); } void VSyncReactor::beginResync() {} void VSyncReactor::beginResync() { mTracker->resetModel(); } void VSyncReactor::endResync() {} Loading services/surfaceflinger/Scheduler/VSyncTracker.h +3 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,9 @@ public: */ virtual void setPeriod(nsecs_t period) = 0; /* Inform the tracker that the samples it has are not accurate for prediction. */ virtual void resetModel() = 0; protected: VSyncTracker(VSyncTracker const&) = delete; VSyncTracker& operator=(VSyncTracker const&) = delete; Loading services/surfaceflinger/tests/unittests/VSyncDispatchRealtimeTest.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public: nsecs_t currentPeriod() const final { return mPeriod; } void setPeriod(nsecs_t) final {} void resetModel() final {} private: nsecs_t const mPeriod; Loading Loading @@ -83,6 +84,7 @@ public: } void setPeriod(nsecs_t) final {} void resetModel() final {} private: std::mutex mutable mMutex; Loading Loading
services/surfaceflinger/Scheduler/VSyncPredictor.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ VSyncPredictor::VSyncPredictor(nsecs_t idealPeriod, size_t historySize, kMinimumSamplesForPrediction(minimumSamplesForPrediction), kOutlierTolerancePercent(std::min(outlierTolerancePercent, kMaxPercent)), mIdealPeriod(idealPeriod) { mRateMap[mIdealPeriod] = {idealPeriod, 0}; resetModel(); } inline size_t VSyncPredictor::next(int i) const { Loading Loading @@ -203,6 +203,10 @@ void VSyncPredictor::setPeriod(nsecs_t period) { mRateMap[mIdealPeriod] = {period, 0}; } clearTimestamps(); } void VSyncPredictor::clearTimestamps() { if (!timestamps.empty()) { mKnownTimestamp = *std::max_element(timestamps.begin(), timestamps.end()); timestamps.clear(); Loading @@ -227,6 +231,12 @@ bool VSyncPredictor::needsMoreSamples(nsecs_t now) const { return needsMoreSamples; } void VSyncPredictor::resetModel() { std::lock_guard<std::mutex> lk(mMutex); mRateMap[mIdealPeriod] = {mIdealPeriod, 0}; clearTimestamps(); } } // namespace android::scheduler // TODO(b/129481165): remove the #pragma below and fix conversion issues Loading
services/surfaceflinger/Scheduler/VSyncPredictor.h +3 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ public: void addVsyncTimestamp(nsecs_t timestamp) final; nsecs_t nextAnticipatedVSyncTimeFrom(nsecs_t timePoint) const final; nsecs_t currentPeriod() const final; void resetModel() final; /* * Inform the model that the period is anticipated to change to a new value. Loading @@ -48,7 +49,7 @@ public: * * \param [in] period The new period that should be used. */ void setPeriod(nsecs_t period); void setPeriod(nsecs_t period) final; /* Query if the model is in need of more samples to make a prediction at timePoint. * \param [in] timePoint The timePoint to inquire of. Loading @@ -61,6 +62,7 @@ public: private: VSyncPredictor(VSyncPredictor const&) = delete; VSyncPredictor& operator=(VSyncPredictor const&) = delete; void clearTimestamps() REQUIRES(mMutex); size_t const kHistorySize; size_t const kMinimumSamplesForPrediction; Loading
services/surfaceflinger/Scheduler/VSyncReactor.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -199,7 +199,9 @@ nsecs_t VSyncReactor::getPeriod() { return mTracker->currentPeriod(); } void VSyncReactor::beginResync() {} void VSyncReactor::beginResync() { mTracker->resetModel(); } void VSyncReactor::endResync() {} Loading
services/surfaceflinger/Scheduler/VSyncTracker.h +3 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,9 @@ public: */ virtual void setPeriod(nsecs_t period) = 0; /* Inform the tracker that the samples it has are not accurate for prediction. */ virtual void resetModel() = 0; protected: VSyncTracker(VSyncTracker const&) = delete; VSyncTracker& operator=(VSyncTracker const&) = delete; Loading
services/surfaceflinger/tests/unittests/VSyncDispatchRealtimeTest.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public: nsecs_t currentPeriod() const final { return mPeriod; } void setPeriod(nsecs_t) final {} void resetModel() final {} private: nsecs_t const mPeriod; Loading Loading @@ -83,6 +84,7 @@ public: } void setPeriod(nsecs_t) final {} void resetModel() final {} private: std::mutex mutable mMutex; Loading