Use hasSyncFramework value from configStore
Change-Id: I41c6b1a26001eb6ba08cbc419dc8a683f5722aa3
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 1b13ea9..a6ea750 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -69,10 +69,6 @@
LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS)
endif
-ifeq ($(TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK),true)
- LOCAL_CFLAGS += -DRUNNING_WITHOUT_SYNC_FRAMEWORK
-endif
-
LOCAL_CFLAGS += -fvisibility=hidden -Werror=format
LOCAL_HEADER_LIBRARIES := \
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index d7654f1..bd9b8aa 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -216,7 +216,8 @@
return BAD_VALUE;
}
- // This method is only here to handle the kIgnorePresentFences case.
+ // This method is only here to handle the !SurfaceFlinger::hasSyncFramework
+ // case.
bool hasAnyEventListeners() {
if (kTraceDetailedInfo) ATRACE_CALL();
Mutex::Autolock lock(mMutex);
@@ -376,7 +377,8 @@
DispSync::DispSync(const char* name) :
mName(name),
mRefreshSkipCount(0),
- mThread(new DispSyncThread(name)) {
+ mThread(new DispSyncThread(name)),
+ mIgnorePresentFences(!SurfaceFlinger::hasSyncFramework){
mPresentTimeOffset = SurfaceFlinger::dispSyncPresentTimeOffset;
mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
@@ -397,7 +399,7 @@
// Even if we're just ignoring the fences, the zero-phase tracing is
// not needed because any time there is an event registered we will
// turn on the HW vsync events.
- if (!kIgnorePresentFences && kEnableZeroPhaseTracer) {
+ if (!mIgnorePresentFences && kEnableZeroPhaseTracer) {
addEventListener("ZeroPhaseTracer", 0, new ZeroPhaseTracer());
}
}
@@ -476,7 +478,7 @@
resetErrorLocked();
}
- if (kIgnorePresentFences) {
+ if (mIgnorePresentFences) {
// If we don't have the sync framework we will never have
// addPresentFence called. This means we have no way to know whether
// or not we're synchronized with the HW vsyncs, so we just request
@@ -641,7 +643,7 @@
void DispSync::dump(String8& result) const {
Mutex::Autolock lock(mMutex);
result.appendFormat("present fences are %s\n",
- kIgnorePresentFences ? "ignored" : "used");
+ mIgnorePresentFences ? "ignored" : "used");
result.appendFormat("mPeriod: %" PRId64 " ns (%.3f fps; skipCount=%d)\n",
mPeriod, 1000000000.0 / mPeriod, mRefreshSkipCount);
result.appendFormat("mPhase: %" PRId64 " ns\n", mPhase);
diff --git a/services/surfaceflinger/DispSync.h b/services/surfaceflinger/DispSync.h
index 5b7083d..82ae795 100644
--- a/services/surfaceflinger/DispSync.h
+++ b/services/surfaceflinger/DispSync.h
@@ -25,15 +25,6 @@
namespace android {
-// Ignore present (retire) fences if the device doesn't have support for the
-// sync framework
-#if defined(RUNNING_WITHOUT_SYNC_FRAMEWORK)
-static const bool kIgnorePresentFences = true;
-#else
-static const bool kIgnorePresentFences = false;
-#endif
-
-
class String8;
class Fence;
class DispSyncThread;
@@ -186,6 +177,10 @@
// 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;
};
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index cfde375..ad3b340 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -117,6 +117,7 @@
int64_t SurfaceFlinger::dispSyncPresentTimeOffset;
bool SurfaceFlinger::useHwcForRgbToYuv;
uint64_t SurfaceFlinger::maxVirtualDisplaySize;
+bool SurfaceFlinger::hasSyncFramework;
SurfaceFlinger::SurfaceFlinger()
: BnSurfaceComposer(),
@@ -160,6 +161,7 @@
,mEnterVrMode(false)
#endif
{
+ ALOGI("SurfaceFlinger is starting");
vsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::vsyncEventPhaseOffsetNs>(1000000);
@@ -167,7 +169,8 @@
sfVsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs>(1000000);
- ALOGI("SurfaceFlinger is starting");
+ hasSyncFramework = getBool< ISurfaceFlingerConfigs,
+ &ISurfaceFlingerConfigs::hasSyncFramework>(true);
useContextPriority = getBool< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::useContextPriority>(false);
@@ -1515,7 +1518,7 @@
}
}
- if (kIgnorePresentFences) {
+ if (!hasSyncFramework) {
if (hw->isDisplayOn()) {
enableHardwareVsync();
}
@@ -3249,6 +3252,7 @@
result.appendFormat(" PRESENT_TIME_OFFSET=%" PRId64 , dispSyncPresentTimeOffset);
result.appendFormat(" FORCE_HWC_FOR_RBG_TO_YUV=%d", useHwcForRgbToYuv);
result.appendFormat(" MAX_VIRT_DISPLAY_DIM=%" PRIu64, maxVirtualDisplaySize);
+ result.appendFormat(" RUNNING_WITHOUT_SYNC_FRAMEWORK=%d", !hasSyncFramework);
result.append("]");
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 85b6f2a..0085cb2 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -128,6 +128,9 @@
static int64_t vsyncPhaseOffsetNs;
static int64_t sfVsyncPhaseOffsetNs;
+ // If fences from sync Framework are supported.
+ static bool hasSyncFramework;
+
// Instruct the Render Engine to use EGL_IMG_context_priority is available.
static bool useContextPriority;
diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
index c184cd2..38304f5 100644
--- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
@@ -115,6 +115,7 @@
int64_t SurfaceFlinger::dispSyncPresentTimeOffset;
bool SurfaceFlinger::useHwcForRgbToYuv;
uint64_t SurfaceFlinger::maxVirtualDisplaySize;
+bool SurfaceFlinger::hasSyncFramework;
SurfaceFlinger::SurfaceFlinger()
: BnSurfaceComposer(),
@@ -151,7 +152,6 @@
mLastSwapTime(0),
mNumLayers(0)
{
-
ALOGI("SurfaceFlinger is starting");
vsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs,
@@ -163,6 +163,9 @@
maxVirtualDisplaySize = getUInt64<ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::maxVirtualDisplaySize>(0);
+ hasSyncFramework = getBool< ISurfaceFlingerConfigs,
+ &ISurfaceFlingerConfigs::hasSyncFramework>(true);
+
useContextPriority = getBool< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::useContextPriority>(false);
@@ -1285,7 +1288,7 @@
}
}
- if (kIgnorePresentFences) {
+ if (!hasSyncFramework) {
if (hw->isDisplayOn()) {
enableHardwareVsync();
}
@@ -3021,6 +3024,7 @@
result.appendFormat(" PRESENT_TIME_OFFSET=%" PRId64, dispSyncPresentTimeOffset);
result.appendFormat(" FORCE_HWC_FOR_RBG_TO_YUV=%d", useHwcForRgbToYuv);
result.appendFormat(" MAX_VIRT_DISPLAY_DIM=%" PRIu64, maxVirtualDisplaySize);
+ result.appendFormat(" RUNNING_WITHOUT_SYNC_FRAMEWORK=%d", !hasSyncFramework);
result.append("]");
}