diff options
author | 2017-07-13 10:45:07 -0700 | |
---|---|---|
committer | 2017-07-19 10:15:24 -0700 | |
commit | f41745301d5ecfa680dcef3a1948a8a321f80509 (patch) | |
tree | ff8f46802b81d7fc089d359caf210dc1878c6de6 | |
parent | 75b8f3ccf94d87417786c7e6ab698418226718ff (diff) |
sf: Defer DispSync initialization
Some DispSync members are initialized based on uninitialized static
members of sf, that are in turn initialized in sf constructor. Fix
the sequence by deferring DispSync initialization.
Current sequence:
sf constructor|-> DispSync constructor -> Access static sf members
|-> Initialize sf static members
New sequence:
sf constructor|-> DispSync constructor
|-> Initialize sf static members
|-> DispSync init -> Access static sf members
Bug: 63671437
Test: "present fences are ignored" not present in SF dumpsys
Change-Id: I618d2bbbbd4e39fc382e67f85dd8d637dd82cf38
-rw-r--r-- | services/surfaceflinger/DispSync.cpp | 14 | ||||
-rw-r--r-- | services/surfaceflinger/DispSync.h | 2 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp index ac8aa04e9d..bef12ea50f 100644 --- a/services/surfaceflinger/DispSync.cpp +++ b/services/surfaceflinger/DispSync.cpp @@ -377,11 +377,16 @@ private: DispSync::DispSync(const char* name) : mName(name), mRefreshSkipCount(0), - mThread(new DispSyncThread(name)), - mIgnorePresentFences(!SurfaceFlinger::hasSyncFramework){ + mThread(new DispSyncThread(name)) { +} + +DispSync::~DispSync() {} - mPresentTimeOffset = SurfaceFlinger::dispSyncPresentTimeOffset; +void DispSync::init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset) { + mIgnorePresentFences = !hasSyncFramework; + mPresentTimeOffset = dispSyncPresentTimeOffset; mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE); + // set DispSync to SCHED_FIFO to minimize jitter struct sched_param param = {0}; param.sched_priority = 2; @@ -389,7 +394,6 @@ DispSync::DispSync(const char* name) : ALOGE("Couldn't set SCHED_FIFO for DispSyncThread"); } - reset(); beginResync(); @@ -405,8 +409,6 @@ DispSync::DispSync(const char* name) : } } -DispSync::~DispSync() {} - void DispSync::reset() { Mutex::Autolock lock(mMutex); diff --git a/services/surfaceflinger/DispSync.h b/services/surfaceflinger/DispSync.h index c9f3b0481e..880a24d6ad 100644 --- a/services/surfaceflinger/DispSync.h +++ b/services/surfaceflinger/DispSync.h @@ -59,6 +59,8 @@ public: explicit DispSync(const char* name); ~DispSync(); + void init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset); + // reset clears the resync samples and error value. void reset(); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 7fb315865f..fe0fa2b0ff 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -195,6 +195,8 @@ SurfaceFlinger::SurfaceFlinger() hasWideColorDisplay = getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasWideColorDisplay>(false); + mPrimaryDispSync.init(hasSyncFramework, dispSyncPresentTimeOffset); + // debugging stuff... char value[PROPERTY_VALUE_MAX]; |