Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +1 −10 Original line number Original line Diff line number Diff line Loading @@ -499,12 +499,8 @@ RefreshRateConfigs::UidToFrameRateOverride RefreshRateConfigs::getFrameRateOverr // Now that we scored all the refresh rates we need to pick the one that got the highest // Now that we scored all the refresh rates we need to pick the one that got the highest // score. // score. const RefreshRate* bestRefreshRate = getBestRefreshRate(scores.begin(), scores.end()); const RefreshRate* bestRefreshRate = getBestRefreshRate(scores.begin(), scores.end()); // If the nest refresh rate is the current one, we don't have an override if (!bestRefreshRate->getFps().equalsWithMargin(displayFrameRate)) { frameRateOverrides.emplace(uid, bestRefreshRate->getFps()); frameRateOverrides.emplace(uid, bestRefreshRate->getFps()); } } } return frameRateOverrides; return frameRateOverrides; } } Loading Loading @@ -839,11 +835,6 @@ int RefreshRateConfigs::getFrameRateDivider(Fps displayFrameRate, Fps layerFrame return static_cast<int>(numPeriodsRounded); return static_cast<int>(numPeriodsRounded); } } int RefreshRateConfigs::getRefreshRateDivider(Fps frameRate) const { std::lock_guard lock(mLock); return getFrameRateDivider(mCurrentRefreshRate->getFps(), frameRate); } void RefreshRateConfigs::dump(std::string& result) const { void RefreshRateConfigs::dump(std::string& result) const { std::lock_guard lock(mLock); std::lock_guard lock(mLock); base::StringAppendF(&result, "DesiredDisplayModeSpecs (DisplayManager): %s\n\n", base::StringAppendF(&result, "DesiredDisplayModeSpecs (DisplayManager): %s\n\n", Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.h +4 −7 Original line number Original line Diff line number Diff line Loading @@ -324,8 +324,10 @@ public: bool supportsFrameRateOverride() const { return mSupportsFrameRateOverride; } bool supportsFrameRateOverride() const { return mSupportsFrameRateOverride; } // Returns a divider for the current refresh rate // Return the display refresh rate divider to match the layer int getRefreshRateDivider(Fps frameRate) const EXCLUDES(mLock); // frame rate, or 0 if the display refresh rate is not a multiple of the // layer refresh rate. static int getFrameRateDivider(Fps displayFrameRate, Fps layerFrameRate); using UidToFrameRateOverride = std::map<uid_t, Fps>; using UidToFrameRateOverride = std::map<uid_t, Fps>; // Returns the frame rate override for each uid. // Returns the frame rate override for each uid. Loading Loading @@ -373,11 +375,6 @@ private: const Policy* getCurrentPolicyLocked() const REQUIRES(mLock); const Policy* getCurrentPolicyLocked() const REQUIRES(mLock); bool isPolicyValidLocked(const Policy& policy) const REQUIRES(mLock); bool isPolicyValidLocked(const Policy& policy) const REQUIRES(mLock); // Return the display refresh rate divider to match the layer // frame rate, or 0 if the display refresh rate is not a multiple of the // layer refresh rate. static int getFrameRateDivider(Fps displayFrameRate, Fps layerFrameRate); // calculates a score for a layer. Used to determine the display refresh rate // calculates a score for a layer. Used to determine the display refresh rate // and the frame rate override for certains applications. // and the frame rate override for certains applications. float calculateLayerScoreLocked(const LayerRequirement&, const RefreshRate&, float calculateLayerScoreLocked(const LayerRequirement&, const RefreshRate&, Loading services/surfaceflinger/Scheduler/Scheduler.cpp +5 −6 Original line number Original line Diff line number Diff line Loading @@ -235,12 +235,7 @@ bool Scheduler::isVsyncValid(nsecs_t expectedVsyncTimestamp, uid_t uid) const { return true; return true; } } const auto divider = mRefreshRateConfigs.getRefreshRateDivider(*frameRate); return mVsyncSchedule.tracker->isVSyncInPhase(expectedVsyncTimestamp, *frameRate); if (divider <= 1) { return true; } return mVsyncSchedule.tracker->isVSyncInPhase(expectedVsyncTimestamp, divider); } } impl::EventThread::ThrottleVsyncCallback Scheduler::makeThrottleVsyncCallback() const { impl::EventThread::ThrottleVsyncCallback Scheduler::makeThrottleVsyncCallback() const { Loading Loading @@ -354,6 +349,10 @@ void Scheduler::onPrimaryDisplayModeChanged(ConnectionHandle handle, PhysicalDis std::lock_guard<std::mutex> lock(mFeatureStateLock); std::lock_guard<std::mutex> lock(mFeatureStateLock); // Cache the last reported modes for primary display. // Cache the last reported modes for primary display. mFeatures.cachedModeChangedParams = {handle, displayId, modeId, vsyncPeriod}; mFeatures.cachedModeChangedParams = {handle, displayId, modeId, vsyncPeriod}; // Invalidate content based refresh rate selection so it could be calculated // again for the new refresh rate. mFeatures.contentRequirements.clear(); } } onNonPrimaryDisplayModeChanged(handle, displayId, modeId, vsyncPeriod); onNonPrimaryDisplayModeChanged(handle, displayId, modeId, vsyncPeriod); } } Loading services/surfaceflinger/Scheduler/VSyncPredictor.cpp +11 −7 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <algorithm> #include <algorithm> #include <chrono> #include <chrono> #include <sstream> #include <sstream> #include "RefreshRateConfigs.h" #undef LOG_TAG #undef LOG_TAG #define LOG_TAG "VSyncPredictor" #define LOG_TAG "VSyncPredictor" Loading Loading @@ -225,13 +226,14 @@ nsecs_t VSyncPredictor::nextAnticipatedVSyncTimeFrom(nsecs_t timePoint) const { } } /* /* * Returns whether a given vsync timestamp is in phase with a vsync divider. * Returns whether a given vsync timestamp is in phase with a frame rate. * For example, if the vsync timestamps are (16,32,48,64): * If the frame rate is not a divider of the refresh rate, it is always considered in phase. * isVSyncInPhase(16, 2) = true * For example, if the vsync timestamps are (16.6,33.3,50.0,66.6): * isVSyncInPhase(32, 2) = false * isVSyncInPhase(16.6, 30) = true * isVSyncInPhase(48, 2) = true * isVSyncInPhase(33.3, 30) = false * isVSyncInPhase(50.0, 30) = true */ */ bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, int divider) const { bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, Fps frameRate) const { struct VsyncError { struct VsyncError { nsecs_t vsyncTimestamp; nsecs_t vsyncTimestamp; float error; float error; Loading @@ -239,11 +241,13 @@ bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, int divider) const { bool operator<(const VsyncError& other) const { return error < other.error; } bool operator<(const VsyncError& other) const { return error < other.error; } }; }; std::lock_guard lock(mMutex); const auto divider = RefreshRateConfigs::getFrameRateDivider(Fps::fromPeriodNsecs(mIdealPeriod), frameRate); if (divider <= 1 || timePoint == 0) { if (divider <= 1 || timePoint == 0) { return true; return true; } } std::lock_guard lock(mMutex); const nsecs_t period = mRateMap[mIdealPeriod].slope; const nsecs_t period = mRateMap[mIdealPeriod].slope; const nsecs_t justBeforeTimePoint = timePoint - period / 2; const nsecs_t justBeforeTimePoint = timePoint - period / 2; const nsecs_t dividedPeriod = mIdealPeriod / divider; const nsecs_t dividedPeriod = mIdealPeriod / divider; Loading services/surfaceflinger/Scheduler/VSyncPredictor.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -64,7 +64,7 @@ public: VSyncPredictor::Model getVSyncPredictionModel() const EXCLUDES(mMutex); VSyncPredictor::Model getVSyncPredictionModel() const EXCLUDES(mMutex); bool isVSyncInPhase(nsecs_t timePoint, int divider) const final EXCLUDES(mMutex); bool isVSyncInPhase(nsecs_t timePoint, Fps frameRate) const final EXCLUDES(mMutex); void dump(std::string& result) const final EXCLUDES(mMutex); void dump(std::string& result) const final EXCLUDES(mMutex); Loading Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +1 −10 Original line number Original line Diff line number Diff line Loading @@ -499,12 +499,8 @@ RefreshRateConfigs::UidToFrameRateOverride RefreshRateConfigs::getFrameRateOverr // Now that we scored all the refresh rates we need to pick the one that got the highest // Now that we scored all the refresh rates we need to pick the one that got the highest // score. // score. const RefreshRate* bestRefreshRate = getBestRefreshRate(scores.begin(), scores.end()); const RefreshRate* bestRefreshRate = getBestRefreshRate(scores.begin(), scores.end()); // If the nest refresh rate is the current one, we don't have an override if (!bestRefreshRate->getFps().equalsWithMargin(displayFrameRate)) { frameRateOverrides.emplace(uid, bestRefreshRate->getFps()); frameRateOverrides.emplace(uid, bestRefreshRate->getFps()); } } } return frameRateOverrides; return frameRateOverrides; } } Loading Loading @@ -839,11 +835,6 @@ int RefreshRateConfigs::getFrameRateDivider(Fps displayFrameRate, Fps layerFrame return static_cast<int>(numPeriodsRounded); return static_cast<int>(numPeriodsRounded); } } int RefreshRateConfigs::getRefreshRateDivider(Fps frameRate) const { std::lock_guard lock(mLock); return getFrameRateDivider(mCurrentRefreshRate->getFps(), frameRate); } void RefreshRateConfigs::dump(std::string& result) const { void RefreshRateConfigs::dump(std::string& result) const { std::lock_guard lock(mLock); std::lock_guard lock(mLock); base::StringAppendF(&result, "DesiredDisplayModeSpecs (DisplayManager): %s\n\n", base::StringAppendF(&result, "DesiredDisplayModeSpecs (DisplayManager): %s\n\n", Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.h +4 −7 Original line number Original line Diff line number Diff line Loading @@ -324,8 +324,10 @@ public: bool supportsFrameRateOverride() const { return mSupportsFrameRateOverride; } bool supportsFrameRateOverride() const { return mSupportsFrameRateOverride; } // Returns a divider for the current refresh rate // Return the display refresh rate divider to match the layer int getRefreshRateDivider(Fps frameRate) const EXCLUDES(mLock); // frame rate, or 0 if the display refresh rate is not a multiple of the // layer refresh rate. static int getFrameRateDivider(Fps displayFrameRate, Fps layerFrameRate); using UidToFrameRateOverride = std::map<uid_t, Fps>; using UidToFrameRateOverride = std::map<uid_t, Fps>; // Returns the frame rate override for each uid. // Returns the frame rate override for each uid. Loading Loading @@ -373,11 +375,6 @@ private: const Policy* getCurrentPolicyLocked() const REQUIRES(mLock); const Policy* getCurrentPolicyLocked() const REQUIRES(mLock); bool isPolicyValidLocked(const Policy& policy) const REQUIRES(mLock); bool isPolicyValidLocked(const Policy& policy) const REQUIRES(mLock); // Return the display refresh rate divider to match the layer // frame rate, or 0 if the display refresh rate is not a multiple of the // layer refresh rate. static int getFrameRateDivider(Fps displayFrameRate, Fps layerFrameRate); // calculates a score for a layer. Used to determine the display refresh rate // calculates a score for a layer. Used to determine the display refresh rate // and the frame rate override for certains applications. // and the frame rate override for certains applications. float calculateLayerScoreLocked(const LayerRequirement&, const RefreshRate&, float calculateLayerScoreLocked(const LayerRequirement&, const RefreshRate&, Loading
services/surfaceflinger/Scheduler/Scheduler.cpp +5 −6 Original line number Original line Diff line number Diff line Loading @@ -235,12 +235,7 @@ bool Scheduler::isVsyncValid(nsecs_t expectedVsyncTimestamp, uid_t uid) const { return true; return true; } } const auto divider = mRefreshRateConfigs.getRefreshRateDivider(*frameRate); return mVsyncSchedule.tracker->isVSyncInPhase(expectedVsyncTimestamp, *frameRate); if (divider <= 1) { return true; } return mVsyncSchedule.tracker->isVSyncInPhase(expectedVsyncTimestamp, divider); } } impl::EventThread::ThrottleVsyncCallback Scheduler::makeThrottleVsyncCallback() const { impl::EventThread::ThrottleVsyncCallback Scheduler::makeThrottleVsyncCallback() const { Loading Loading @@ -354,6 +349,10 @@ void Scheduler::onPrimaryDisplayModeChanged(ConnectionHandle handle, PhysicalDis std::lock_guard<std::mutex> lock(mFeatureStateLock); std::lock_guard<std::mutex> lock(mFeatureStateLock); // Cache the last reported modes for primary display. // Cache the last reported modes for primary display. mFeatures.cachedModeChangedParams = {handle, displayId, modeId, vsyncPeriod}; mFeatures.cachedModeChangedParams = {handle, displayId, modeId, vsyncPeriod}; // Invalidate content based refresh rate selection so it could be calculated // again for the new refresh rate. mFeatures.contentRequirements.clear(); } } onNonPrimaryDisplayModeChanged(handle, displayId, modeId, vsyncPeriod); onNonPrimaryDisplayModeChanged(handle, displayId, modeId, vsyncPeriod); } } Loading
services/surfaceflinger/Scheduler/VSyncPredictor.cpp +11 −7 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <algorithm> #include <algorithm> #include <chrono> #include <chrono> #include <sstream> #include <sstream> #include "RefreshRateConfigs.h" #undef LOG_TAG #undef LOG_TAG #define LOG_TAG "VSyncPredictor" #define LOG_TAG "VSyncPredictor" Loading Loading @@ -225,13 +226,14 @@ nsecs_t VSyncPredictor::nextAnticipatedVSyncTimeFrom(nsecs_t timePoint) const { } } /* /* * Returns whether a given vsync timestamp is in phase with a vsync divider. * Returns whether a given vsync timestamp is in phase with a frame rate. * For example, if the vsync timestamps are (16,32,48,64): * If the frame rate is not a divider of the refresh rate, it is always considered in phase. * isVSyncInPhase(16, 2) = true * For example, if the vsync timestamps are (16.6,33.3,50.0,66.6): * isVSyncInPhase(32, 2) = false * isVSyncInPhase(16.6, 30) = true * isVSyncInPhase(48, 2) = true * isVSyncInPhase(33.3, 30) = false * isVSyncInPhase(50.0, 30) = true */ */ bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, int divider) const { bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, Fps frameRate) const { struct VsyncError { struct VsyncError { nsecs_t vsyncTimestamp; nsecs_t vsyncTimestamp; float error; float error; Loading @@ -239,11 +241,13 @@ bool VSyncPredictor::isVSyncInPhase(nsecs_t timePoint, int divider) const { bool operator<(const VsyncError& other) const { return error < other.error; } bool operator<(const VsyncError& other) const { return error < other.error; } }; }; std::lock_guard lock(mMutex); const auto divider = RefreshRateConfigs::getFrameRateDivider(Fps::fromPeriodNsecs(mIdealPeriod), frameRate); if (divider <= 1 || timePoint == 0) { if (divider <= 1 || timePoint == 0) { return true; return true; } } std::lock_guard lock(mMutex); const nsecs_t period = mRateMap[mIdealPeriod].slope; const nsecs_t period = mRateMap[mIdealPeriod].slope; const nsecs_t justBeforeTimePoint = timePoint - period / 2; const nsecs_t justBeforeTimePoint = timePoint - period / 2; const nsecs_t dividedPeriod = mIdealPeriod / divider; const nsecs_t dividedPeriod = mIdealPeriod / divider; Loading
services/surfaceflinger/Scheduler/VSyncPredictor.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -64,7 +64,7 @@ public: VSyncPredictor::Model getVSyncPredictionModel() const EXCLUDES(mMutex); VSyncPredictor::Model getVSyncPredictionModel() const EXCLUDES(mMutex); bool isVSyncInPhase(nsecs_t timePoint, int divider) const final EXCLUDES(mMutex); bool isVSyncInPhase(nsecs_t timePoint, Fps frameRate) const final EXCLUDES(mMutex); void dump(std::string& result) const final EXCLUDES(mMutex); void dump(std::string& result) const final EXCLUDES(mMutex); Loading