Loading services/surfaceflinger/Scheduler/Scheduler.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -190,9 +190,15 @@ void Scheduler::disableHardwareVsync(bool makeUnavailable) { } void Scheduler::setVsyncPeriod(const nsecs_t period) { std::lock_guard<std::mutex> lock(mHWVsyncLock); mPrimaryDispSync->reset(); mPrimaryDispSync->setPeriod(period); enableHardwareVsync(); if (!mPrimaryHWVsyncEnabled) { mPrimaryDispSync->beginResync(); mEventControlThread->setVsyncEnabled(true); mPrimaryHWVsyncEnabled = true; } } void Scheduler::addResyncSample(const nsecs_t timestamp) { Loading Loading @@ -228,10 +234,19 @@ void Scheduler::makeHWSyncAvailable(bool makeAvailable) { mHWVsyncAvailable = makeAvailable; } bool Scheduler::getHWSyncAvailable() { std::lock_guard<std::mutex> lock(mHWVsyncLock); return mHWVsyncAvailable; } nsecs_t Scheduler::expectedPresentTime() { return mPrimaryDispSync->expectedPresentTime(); } void Scheduler::dumpPrimaryDispSync(std::string& result) const { mPrimaryDispSync->dump(result); } void Scheduler::addFramePresentTimeForLayer(const nsecs_t framePresentTime, bool isAutoTimestamp, const std::string layerName) { // This is V1 logic. It calculates the average FPS based on the timestamp frequency Loading services/surfaceflinger/Scheduler/Scheduler.h +5 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ public: void addPresentFence(const std::shared_ptr<FenceTime>& fenceTime); void setIgnorePresentFences(bool ignore); void makeHWSyncAvailable(bool makeAvailable); // returns HWSyncAvailable flag to SF would enable HW vsync based on this bool getHWSyncAvailable(); nsecs_t expectedPresentTime(); // Adds the present time for given layer to the history of present times. void addFramePresentTimeForLayer(const nsecs_t framePresentTime, bool isAutoTimestamp, Loading @@ -122,6 +124,9 @@ public: // Returns relevant information about Scheduler for dumpsys purposes. std::string doDump(); // calls DispSync::dump() on primary disp sync void dumpPrimaryDispSync(std::string& result) const; protected: virtual std::unique_ptr<EventThread> makeEventThread( const char* connectionName, DispSync* dispSync, int64_t phaseOffsetNs, Loading services/surfaceflinger/Scheduler/VSyncModulator.h +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ private: changed = true; } if (desired.app != current.app) { if (mSfConnectionHandle != nullptr) { if (mAppConnectionHandle != nullptr) { mScheduler->setPhaseOffset(mAppConnectionHandle, desired.app); } else { mAppEventThread->setPhaseOffset(desired.app); Loading services/surfaceflinger/SurfaceFlinger.cpp +24 −12 Original line number Diff line number Diff line Loading @@ -636,11 +636,11 @@ void SurfaceFlinger::init() { scheduler::RefreshRateConfigs::RefreshRateType::PERFORMANCE); mAppConnectionHandle = mScheduler->createConnection("appConnection", mPhaseOffsets->getCurrentAppOffset(), mScheduler->createConnection("app", mPhaseOffsets->getCurrentAppOffset(), resyncCallback, impl::EventThread::InterceptVSyncsCallback()); mSfConnectionHandle = mScheduler->createConnection("sfConnection", mPhaseOffsets->getCurrentSfOffset(), mScheduler->createConnection("sf", mPhaseOffsets->getCurrentSfOffset(), resyncCallback, [this](nsecs_t timestamp) { mInterceptor->saveVSyncEvent(timestamp); }); Loading Loading @@ -1419,18 +1419,24 @@ void SurfaceFlinger::enableHardwareVsync() { void SurfaceFlinger::resyncToHardwareVsync(bool makeAvailable, nsecs_t period) { Mutex::Autolock _l(mHWVsyncLock); if (makeAvailable) { mHWVsyncAvailable = true; // TODO(b/113612090): This is silly, but necessary evil until we turn on the flag for good. if (mUseScheduler) { if (makeAvailable) { mScheduler->makeHWSyncAvailable(true); } else if (!mScheduler->getHWSyncAvailable()) { // Hardware vsync is not currently available, so abort the resync // attempt for now return; } } else { if (makeAvailable) { mHWVsyncAvailable = true; } else if (!mHWVsyncAvailable) { // Hardware vsync is not currently available, so abort the resync // attempt for now return; } } if (period <= 0) { return; Loading Loading @@ -4545,7 +4551,13 @@ status_t SurfaceFlinger::doDump(int fd, const DumpArgs& args, {"--clear-layer-stats"s, dumper([this](std::string&) { mLayerStats.clear(); })}, {"--disable-layer-stats"s, dumper([this](std::string&) { mLayerStats.disable(); })}, {"--display-id"s, dumper(&SurfaceFlinger::dumpDisplayIdentificationData)}, {"--dispsync"s, dumper([this](std::string& s) { mPrimaryDispSync->dump(s); })}, {"--dispsync"s, dumper([this](std::string& s) { if (mUseScheduler) { mScheduler->dumpPrimaryDispSync(s); } else { mPrimaryDispSync->dump(s); } })}, {"--dump-layer-stats"s, dumper([this](std::string& s) { mLayerStats.dump(s); })}, {"--enable-layer-stats"s, dumper([this](std::string&) { mLayerStats.enable(); })}, {"--frame-composition"s, dumper(&SurfaceFlinger::dumpFrameCompositionInfo)}, Loading Loading
services/surfaceflinger/Scheduler/Scheduler.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -190,9 +190,15 @@ void Scheduler::disableHardwareVsync(bool makeUnavailable) { } void Scheduler::setVsyncPeriod(const nsecs_t period) { std::lock_guard<std::mutex> lock(mHWVsyncLock); mPrimaryDispSync->reset(); mPrimaryDispSync->setPeriod(period); enableHardwareVsync(); if (!mPrimaryHWVsyncEnabled) { mPrimaryDispSync->beginResync(); mEventControlThread->setVsyncEnabled(true); mPrimaryHWVsyncEnabled = true; } } void Scheduler::addResyncSample(const nsecs_t timestamp) { Loading Loading @@ -228,10 +234,19 @@ void Scheduler::makeHWSyncAvailable(bool makeAvailable) { mHWVsyncAvailable = makeAvailable; } bool Scheduler::getHWSyncAvailable() { std::lock_guard<std::mutex> lock(mHWVsyncLock); return mHWVsyncAvailable; } nsecs_t Scheduler::expectedPresentTime() { return mPrimaryDispSync->expectedPresentTime(); } void Scheduler::dumpPrimaryDispSync(std::string& result) const { mPrimaryDispSync->dump(result); } void Scheduler::addFramePresentTimeForLayer(const nsecs_t framePresentTime, bool isAutoTimestamp, const std::string layerName) { // This is V1 logic. It calculates the average FPS based on the timestamp frequency Loading
services/surfaceflinger/Scheduler/Scheduler.h +5 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,8 @@ public: void addPresentFence(const std::shared_ptr<FenceTime>& fenceTime); void setIgnorePresentFences(bool ignore); void makeHWSyncAvailable(bool makeAvailable); // returns HWSyncAvailable flag to SF would enable HW vsync based on this bool getHWSyncAvailable(); nsecs_t expectedPresentTime(); // Adds the present time for given layer to the history of present times. void addFramePresentTimeForLayer(const nsecs_t framePresentTime, bool isAutoTimestamp, Loading @@ -122,6 +124,9 @@ public: // Returns relevant information about Scheduler for dumpsys purposes. std::string doDump(); // calls DispSync::dump() on primary disp sync void dumpPrimaryDispSync(std::string& result) const; protected: virtual std::unique_ptr<EventThread> makeEventThread( const char* connectionName, DispSync* dispSync, int64_t phaseOffsetNs, Loading
services/surfaceflinger/Scheduler/VSyncModulator.h +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ private: changed = true; } if (desired.app != current.app) { if (mSfConnectionHandle != nullptr) { if (mAppConnectionHandle != nullptr) { mScheduler->setPhaseOffset(mAppConnectionHandle, desired.app); } else { mAppEventThread->setPhaseOffset(desired.app); Loading
services/surfaceflinger/SurfaceFlinger.cpp +24 −12 Original line number Diff line number Diff line Loading @@ -636,11 +636,11 @@ void SurfaceFlinger::init() { scheduler::RefreshRateConfigs::RefreshRateType::PERFORMANCE); mAppConnectionHandle = mScheduler->createConnection("appConnection", mPhaseOffsets->getCurrentAppOffset(), mScheduler->createConnection("app", mPhaseOffsets->getCurrentAppOffset(), resyncCallback, impl::EventThread::InterceptVSyncsCallback()); mSfConnectionHandle = mScheduler->createConnection("sfConnection", mPhaseOffsets->getCurrentSfOffset(), mScheduler->createConnection("sf", mPhaseOffsets->getCurrentSfOffset(), resyncCallback, [this](nsecs_t timestamp) { mInterceptor->saveVSyncEvent(timestamp); }); Loading Loading @@ -1419,18 +1419,24 @@ void SurfaceFlinger::enableHardwareVsync() { void SurfaceFlinger::resyncToHardwareVsync(bool makeAvailable, nsecs_t period) { Mutex::Autolock _l(mHWVsyncLock); if (makeAvailable) { mHWVsyncAvailable = true; // TODO(b/113612090): This is silly, but necessary evil until we turn on the flag for good. if (mUseScheduler) { if (makeAvailable) { mScheduler->makeHWSyncAvailable(true); } else if (!mScheduler->getHWSyncAvailable()) { // Hardware vsync is not currently available, so abort the resync // attempt for now return; } } else { if (makeAvailable) { mHWVsyncAvailable = true; } else if (!mHWVsyncAvailable) { // Hardware vsync is not currently available, so abort the resync // attempt for now return; } } if (period <= 0) { return; Loading Loading @@ -4545,7 +4551,13 @@ status_t SurfaceFlinger::doDump(int fd, const DumpArgs& args, {"--clear-layer-stats"s, dumper([this](std::string&) { mLayerStats.clear(); })}, {"--disable-layer-stats"s, dumper([this](std::string&) { mLayerStats.disable(); })}, {"--display-id"s, dumper(&SurfaceFlinger::dumpDisplayIdentificationData)}, {"--dispsync"s, dumper([this](std::string& s) { mPrimaryDispSync->dump(s); })}, {"--dispsync"s, dumper([this](std::string& s) { if (mUseScheduler) { mScheduler->dumpPrimaryDispSync(s); } else { mPrimaryDispSync->dump(s); } })}, {"--dump-layer-stats"s, dumper([this](std::string& s) { mLayerStats.dump(s); })}, {"--enable-layer-stats"s, dumper([this](std::string&) { mLayerStats.enable(); })}, {"--frame-composition"s, dumper(&SurfaceFlinger::dumpFrameCompositionInfo)}, Loading