Loading services/surfaceflinger/RegionSamplingThread.cpp +10 −13 Original line number Diff line number Diff line Loading @@ -21,15 +21,18 @@ #include "RegionSamplingThread.h" #include <compositionengine/Display.h> #include <compositionengine/impl/OutputCompositionState.h> #include <cutils/properties.h> #include <gui/IRegionSamplingListener.h> #include <ui/DisplayStatInfo.h> #include <utils/Trace.h> #include <string> #include <compositionengine/Display.h> #include <compositionengine/impl/OutputCompositionState.h> #include "DisplayDevice.h" #include "Layer.h" #include "Scheduler/DispSync.h" #include "SurfaceFlinger.h" namespace android { Loading Loading @@ -105,9 +108,8 @@ struct SamplingOffsetCallback : DispSync::Callback { if (mVsyncListening) return; mPhaseIntervalSetting = Phase::ZERO; mScheduler.withPrimaryDispSync([this](android::DispSync& sync) { sync.addEventListener("SamplingThreadDispSyncListener", 0, this, mLastCallbackTime); }); mScheduler.getPrimaryDispSync().addEventListener("SamplingThreadDispSyncListener", 0, this, mLastCallbackTime); mVsyncListening = true; } Loading @@ -120,9 +122,7 @@ private: void stopVsyncListenerLocked() /*REQUIRES(mMutex)*/ { if (!mVsyncListening) return; mScheduler.withPrimaryDispSync([this](android::DispSync& sync) { sync.removeEventListener(this, &mLastCallbackTime); }); mScheduler.getPrimaryDispSync().removeEventListener(this, &mLastCallbackTime); mVsyncListening = false; } Loading @@ -132,16 +132,13 @@ private: if (mPhaseIntervalSetting == Phase::ZERO) { ATRACE_INT(lumaSamplingStepTag, static_cast<int>(samplingStep::waitForSamplePhase)); mPhaseIntervalSetting = Phase::SAMPLING; mScheduler.withPrimaryDispSync([this](android::DispSync& sync) { sync.changePhaseOffset(this, mTargetSamplingOffset.count()); }); mScheduler.getPrimaryDispSync().changePhaseOffset(this, mTargetSamplingOffset.count()); return; } if (mPhaseIntervalSetting == Phase::SAMPLING) { mPhaseIntervalSetting = Phase::ZERO; mScheduler.withPrimaryDispSync( [this](android::DispSync& sync) { sync.changePhaseOffset(this, 0); }); mScheduler.getPrimaryDispSync().changePhaseOffset(this, 0); stopVsyncListenerLocked(); lock.unlock(); mRegionSamplingThread.notifySamplingOffset(); Loading services/surfaceflinger/Scheduler/DispSync.cpp +8 −11 Original line number Diff line number Diff line Loading @@ -462,22 +462,14 @@ private: TracedOrdinal<bool> mParity; }; DispSync::DispSync(const char* name) : mName(name), mRefreshSkipCount(0) { DispSync::DispSync(const char* name, bool hasSyncFramework) : mName(name), mIgnorePresentFences(!hasSyncFramework) { // This flag offers the ability to turn on systrace logging from the shell. char value[PROPERTY_VALUE_MAX]; property_get("debug.sf.dispsync_trace_detailed_info", value, "0"); mTraceDetailedInfo = atoi(value); mThread = new DispSyncThread(name, mTraceDetailedInfo); } DispSync::~DispSync() { mThread->stop(); mThread->requestExitAndWait(); } void DispSync::init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset) { mIgnorePresentFences = !hasSyncFramework; mPresentTimeOffset = dispSyncPresentTimeOffset; mThread = new DispSyncThread(name, mTraceDetailedInfo); mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE); // set DispSync to SCHED_FIFO to minimize jitter Loading @@ -495,6 +487,11 @@ void DispSync::init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset) { } } DispSync::~DispSync() { mThread->stop(); mThread->requestExitAndWait(); } void DispSync::reset() { Mutex::Autolock lock(mMutex); resetLocked(); Loading services/surfaceflinger/Scheduler/DispSync.h +3 −8 Original line number Diff line number Diff line Loading @@ -88,11 +88,10 @@ class DispSyncThread; // needed. class DispSync : public android::DispSync { public: explicit DispSync(const char* name); // hasSyncFramework specifies whether the platform supports present fences. DispSync(const char* name, bool hasSyncFramework); ~DispSync() override; void init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset); // reset clears the resync samples and error value. void reset() override; Loading Loading @@ -252,7 +251,7 @@ private: std::shared_ptr<FenceTime> mPresentFences[NUM_PRESENT_SAMPLES]{FenceTime::NO_FENCE}; size_t mPresentSampleOffset; int mRefreshSkipCount; int mRefreshSkipCount = 0; // mThread is the thread from which all the callbacks are called. sp<DispSyncThread> mThread; Loading @@ -260,10 +259,6 @@ private: // mMutex is used to protect access to all member variables. mutable Mutex mMutex; // This is the offset from the present fence timestamps to the corresponding // vsync event. int64_t mPresentTimeOffset; // Ignore present (retire) fences if the device doesn't have support for the // sync framework bool mIgnorePresentFences; Loading services/surfaceflinger/Scheduler/EventControlThread.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ EventControlThread::~EventControlThread() = default; namespace impl { EventControlThread::EventControlThread(EventControlThread::SetVSyncEnabledFunction function) : mSetVSyncEnabled(function) { : mSetVSyncEnabled(std::move(function)) { pthread_setname_np(mThread.native_handle(), "EventControlThread"); pid_t tid = pthread_gettid_np(mThread.native_handle()); Loading services/surfaceflinger/Scheduler/OneShotTimer.h +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ public: const TimeoutCallback& timeoutCallback); ~OneShotTimer(); const Interval& interval() const { return mInterval; } // Initializes and turns on the idle timer. void start(); // Stops the idle timer and any held resources. Loading Loading
services/surfaceflinger/RegionSamplingThread.cpp +10 −13 Original line number Diff line number Diff line Loading @@ -21,15 +21,18 @@ #include "RegionSamplingThread.h" #include <compositionengine/Display.h> #include <compositionengine/impl/OutputCompositionState.h> #include <cutils/properties.h> #include <gui/IRegionSamplingListener.h> #include <ui/DisplayStatInfo.h> #include <utils/Trace.h> #include <string> #include <compositionengine/Display.h> #include <compositionengine/impl/OutputCompositionState.h> #include "DisplayDevice.h" #include "Layer.h" #include "Scheduler/DispSync.h" #include "SurfaceFlinger.h" namespace android { Loading Loading @@ -105,9 +108,8 @@ struct SamplingOffsetCallback : DispSync::Callback { if (mVsyncListening) return; mPhaseIntervalSetting = Phase::ZERO; mScheduler.withPrimaryDispSync([this](android::DispSync& sync) { sync.addEventListener("SamplingThreadDispSyncListener", 0, this, mLastCallbackTime); }); mScheduler.getPrimaryDispSync().addEventListener("SamplingThreadDispSyncListener", 0, this, mLastCallbackTime); mVsyncListening = true; } Loading @@ -120,9 +122,7 @@ private: void stopVsyncListenerLocked() /*REQUIRES(mMutex)*/ { if (!mVsyncListening) return; mScheduler.withPrimaryDispSync([this](android::DispSync& sync) { sync.removeEventListener(this, &mLastCallbackTime); }); mScheduler.getPrimaryDispSync().removeEventListener(this, &mLastCallbackTime); mVsyncListening = false; } Loading @@ -132,16 +132,13 @@ private: if (mPhaseIntervalSetting == Phase::ZERO) { ATRACE_INT(lumaSamplingStepTag, static_cast<int>(samplingStep::waitForSamplePhase)); mPhaseIntervalSetting = Phase::SAMPLING; mScheduler.withPrimaryDispSync([this](android::DispSync& sync) { sync.changePhaseOffset(this, mTargetSamplingOffset.count()); }); mScheduler.getPrimaryDispSync().changePhaseOffset(this, mTargetSamplingOffset.count()); return; } if (mPhaseIntervalSetting == Phase::SAMPLING) { mPhaseIntervalSetting = Phase::ZERO; mScheduler.withPrimaryDispSync( [this](android::DispSync& sync) { sync.changePhaseOffset(this, 0); }); mScheduler.getPrimaryDispSync().changePhaseOffset(this, 0); stopVsyncListenerLocked(); lock.unlock(); mRegionSamplingThread.notifySamplingOffset(); Loading
services/surfaceflinger/Scheduler/DispSync.cpp +8 −11 Original line number Diff line number Diff line Loading @@ -462,22 +462,14 @@ private: TracedOrdinal<bool> mParity; }; DispSync::DispSync(const char* name) : mName(name), mRefreshSkipCount(0) { DispSync::DispSync(const char* name, bool hasSyncFramework) : mName(name), mIgnorePresentFences(!hasSyncFramework) { // This flag offers the ability to turn on systrace logging from the shell. char value[PROPERTY_VALUE_MAX]; property_get("debug.sf.dispsync_trace_detailed_info", value, "0"); mTraceDetailedInfo = atoi(value); mThread = new DispSyncThread(name, mTraceDetailedInfo); } DispSync::~DispSync() { mThread->stop(); mThread->requestExitAndWait(); } void DispSync::init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset) { mIgnorePresentFences = !hasSyncFramework; mPresentTimeOffset = dispSyncPresentTimeOffset; mThread = new DispSyncThread(name, mTraceDetailedInfo); mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE); // set DispSync to SCHED_FIFO to minimize jitter Loading @@ -495,6 +487,11 @@ void DispSync::init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset) { } } DispSync::~DispSync() { mThread->stop(); mThread->requestExitAndWait(); } void DispSync::reset() { Mutex::Autolock lock(mMutex); resetLocked(); Loading
services/surfaceflinger/Scheduler/DispSync.h +3 −8 Original line number Diff line number Diff line Loading @@ -88,11 +88,10 @@ class DispSyncThread; // needed. class DispSync : public android::DispSync { public: explicit DispSync(const char* name); // hasSyncFramework specifies whether the platform supports present fences. DispSync(const char* name, bool hasSyncFramework); ~DispSync() override; void init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset); // reset clears the resync samples and error value. void reset() override; Loading Loading @@ -252,7 +251,7 @@ private: std::shared_ptr<FenceTime> mPresentFences[NUM_PRESENT_SAMPLES]{FenceTime::NO_FENCE}; size_t mPresentSampleOffset; int mRefreshSkipCount; int mRefreshSkipCount = 0; // mThread is the thread from which all the callbacks are called. sp<DispSyncThread> mThread; Loading @@ -260,10 +259,6 @@ private: // mMutex is used to protect access to all member variables. mutable Mutex mMutex; // This is the offset from the present fence timestamps to the corresponding // vsync event. int64_t mPresentTimeOffset; // Ignore present (retire) fences if the device doesn't have support for the // sync framework bool mIgnorePresentFences; Loading
services/surfaceflinger/Scheduler/EventControlThread.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ EventControlThread::~EventControlThread() = default; namespace impl { EventControlThread::EventControlThread(EventControlThread::SetVSyncEnabledFunction function) : mSetVSyncEnabled(function) { : mSetVSyncEnabled(std::move(function)) { pthread_setname_np(mThread.native_handle(), "EventControlThread"); pid_t tid = pthread_gettid_np(mThread.native_handle()); Loading
services/surfaceflinger/Scheduler/OneShotTimer.h +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ public: const TimeoutCallback& timeoutCallback); ~OneShotTimer(); const Interval& interval() const { return mInterval; } // Initializes and turns on the idle timer. void start(); // Stops the idle timer and any held resources. Loading