diff options
author | 2017-03-14 13:24:22 -0700 | |
---|---|---|
committer | 2017-03-15 16:29:06 -0700 | |
commit | c45a7d9dfdefa07512c5acc07bcbee5362b34e3d (patch) | |
tree | 9df3b7be1fad7b748c33ef2a66f07b8d4cb72618 | |
parent | b7074a6b6c5dce6c5d29b79f546f4f7f31604d72 (diff) |
[SF] Use presentTimeOffset from configStore
Change-Id: If9c872c565e68e8abe552ee11d2c7d48f44aec4b
-rw-r--r-- | services/surfaceflinger/Android.mk | 6 | ||||
-rw-r--r-- | services/surfaceflinger/DispSync.cpp | 8 | ||||
-rw-r--r-- | services/surfaceflinger/DispSync.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 10 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlingerConsumer.cpp | 2 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 9 |
7 files changed, 27 insertions, 16 deletions
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 5ea3445c10..75144f7d72 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -77,12 +77,6 @@ ifeq ($(TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK),true) LOCAL_CFLAGS += -DRUNNING_WITHOUT_SYNC_FRAMEWORK endif -ifneq ($(PRESENT_TIME_OFFSET_FROM_VSYNC_NS),) - LOCAL_CFLAGS += -DPRESENT_TIME_OFFSET_FROM_VSYNC_NS=$(PRESENT_TIME_OFFSET_FROM_VSYNC_NS) -else - LOCAL_CFLAGS += -DPRESENT_TIME_OFFSET_FROM_VSYNC_NS=0 -endif - ifneq ($(MAX_VIRTUAL_DISPLAY_DIMENSION),) LOCAL_CFLAGS += -DMAX_VIRTUAL_DISPLAY_DIMENSION=$(MAX_VIRTUAL_DISPLAY_DIMENSION) else diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp index 86cf17d61a..d7654f1034 100644 --- a/services/surfaceflinger/DispSync.cpp +++ b/services/surfaceflinger/DispSync.cpp @@ -33,6 +33,7 @@ #include <ui/Fence.h> #include "DispSync.h" +#include "SurfaceFlinger.h" #include "EventLog/EventLog.h" using std::max; @@ -54,10 +55,6 @@ static const bool kEnableZeroPhaseTracer = false; // present time and the nearest software-predicted vsync. static const nsecs_t kErrorThreshold = 160000000000; // 400 usec squared -// This is the offset from the present fence timestamps to the corresponding -// vsync event. -static const int64_t kPresentTimeOffset = PRESENT_TIME_OFFSET_FROM_VSYNC_NS; - #undef LOG_TAG #define LOG_TAG "DispSyncThread" class DispSyncThread: public Thread { @@ -381,6 +378,7 @@ DispSync::DispSync(const char* name) : mRefreshSkipCount(0), mThread(new DispSyncThread(name)) { + mPresentTimeOffset = SurfaceFlinger::dispSyncPresentTimeOffset; mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE); // set DispSync to SCHED_FIFO to minimize jitter struct sched_param param = {0}; @@ -433,7 +431,7 @@ bool DispSync::addPresentFence(const sp<Fence>& fence) { nsecs_t t = f->getSignalTime(); if (t < INT64_MAX) { mPresentFences[i].clear(); - mPresentTimes[i] = t + kPresentTimeOffset; + mPresentTimes[i] = t + mPresentTimeOffset; } } } diff --git a/services/surfaceflinger/DispSync.h b/services/surfaceflinger/DispSync.h index 2763e59559..5b7083d987 100644 --- a/services/surfaceflinger/DispSync.h +++ b/services/surfaceflinger/DispSync.h @@ -182,6 +182,10 @@ 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; }; } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index b93de7e310..2eb880af22 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -113,6 +113,7 @@ const String16 sDump("android.permission.DUMP"); int64_t SurfaceFlinger::vsyncPhaseOffsetNs; int64_t SurfaceFlinger::sfVsyncPhaseOffsetNs; bool SurfaceFlinger::useContextPriority; +int64_t SurfaceFlinger::dispSyncPresentTimeOffset; SurfaceFlinger::SurfaceFlinger() : BnSurfaceComposer(), @@ -168,6 +169,9 @@ SurfaceFlinger::SurfaceFlinger() useContextPriority = getBool< ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::useContextPriority>(false); + dispSyncPresentTimeOffset = getInt64< ISurfaceFlingerConfigs, + &ISurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs>(0); + // debugging stuff... char value[PROPERTY_VALUE_MAX]; @@ -3232,6 +3236,8 @@ void SurfaceFlinger::appendSfConfigString(String8& result) const if (isLayerTripleBufferingDisabled()) result.append(" DISABLE_TRIPLE_BUFFERING"); + + result.appendFormat(" PRESENT_TIME_OFFSET=%" PRId64 , dispSyncPresentTimeOffset); result.append("]"); } @@ -3358,9 +3364,9 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index, result.append("DispSync configuration: "); colorizer.reset(result); result.appendFormat("app phase %" PRId64 " ns, sf phase %" PRId64 " ns, " - "present offset %d ns (refresh %" PRId64 " ns)", + "present offset %" PRId64 " ns (refresh %" PRId64 " ns)", vsyncPhaseOffsetNs, sfVsyncPhaseOffsetNs, - PRESENT_TIME_OFFSET_FROM_VSYNC_NS, activeConfig->getVsyncPeriod()); + dispSyncPresentTimeOffset, activeConfig->getVsyncPeriod()); result.append("\n"); // Dump static screen stats diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index bfe0c9c597..0b4be4a2ad 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -132,6 +132,10 @@ public: // Instruct the Render Engine to use EGL_IMG_context_priority is available. static bool useContextPriority; + // The offset in nanoseconds to use when DispSync timestamps present fence + // signaling time. + static int64_t dispSyncPresentTimeOffset; + static char const* getServiceName() ANDROID_API { return "SurfaceFlinger"; } diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.cpp b/services/surfaceflinger/SurfaceFlingerConsumer.cpp index 01226e0abd..1d2b485164 100644 --- a/services/surfaceflinger/SurfaceFlingerConsumer.cpp +++ b/services/surfaceflinger/SurfaceFlingerConsumer.cpp @@ -179,7 +179,7 @@ nsecs_t SurfaceFlingerConsumer::computeExpectedPresent(const DispSync& dispSync) const nsecs_t nextRefresh = dispSync.computeNextRefresh(hwcLatency); // The DispSync time is already adjusted for the difference between - // vsync and reported-vsync (PRESENT_TIME_OFFSET_FROM_VSYNC_NS), so + // vsync and reported-vsync (SurfaceFlinger::dispSyncPresentTimeOffset), so // we don't need to factor that in here. Pad a little to avoid // weird effects if apps might be requesting times right on the edge. nsecs_t extraPadding = 0; diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp index c567e61661..eee0a46b61 100644 --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp @@ -112,6 +112,7 @@ const String16 sDump("android.permission.DUMP"); int64_t SurfaceFlinger::vsyncPhaseOffsetNs; int64_t SurfaceFlinger::sfVsyncPhaseOffsetNs; bool SurfaceFlinger::useContextPriority; +int64_t SurfaceFlinger::dispSyncPresentTimeOffset; SurfaceFlinger::SurfaceFlinger() : BnSurfaceComposer(), @@ -159,6 +160,9 @@ SurfaceFlinger::SurfaceFlinger() useContextPriority = getBool< ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::useContextPriority>(false); + dispSyncPresentTimeOffset = getInt64< ISurfaceFlingerConfigs, + &ISurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs>(0); + char value[PROPERTY_VALUE_MAX]; property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); @@ -3004,6 +3008,7 @@ void SurfaceFlinger::appendSfConfigString(String8& result) const if (isLayerTripleBufferingDisabled()) result.append(" DISABLE_TRIPLE_BUFFERING"); + result.appendFormat(" PRESENT_TIME_OFFSET=%" PRId64, dispSyncPresentTimeOffset); result.append("]"); } @@ -3127,8 +3132,8 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index, result.append("DispSync configuration: "); colorizer.reset(result); result.appendFormat("app phase %" PRId64 " ns, sf phase %" PRId64 " ns, " - "present offset %d ns (refresh %" PRId64 " ns)", - vsyncPhaseOffsetNs, sfVsyncPhaseOffsetNs, PRESENT_TIME_OFFSET_FROM_VSYNC_NS, + "present offset %" PRId64 " ns (refresh %" PRId64 " ns)", + vsyncPhaseOffsetNs, sfVsyncPhaseOffsetNs, dispSyncPresentTimeOffset, mHwc->getRefreshPeriod(HWC_DISPLAY_PRIMARY)); result.append("\n"); |