Move TARGET_DISABLE_TRIPLE_BUFFERING to property
As part of the migration to Soong, Android.mk environment variables
must be moved to property which are checked at runtime.
Tests: Angler and Sailfish
Change-Id: I7c620656c6778b36fea78c3087fbd5d33cea96f8
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 4987a18..fcc9241 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -69,10 +69,6 @@
LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY
endif
-ifeq ($(TARGET_DISABLE_TRIPLE_BUFFERING),true)
- LOCAL_CFLAGS += -DTARGET_DISABLE_TRIPLE_BUFFERING
-endif
-
ifeq ($(TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS),true)
LOCAL_CFLAGS += -DFORCE_HWC_COPY_FOR_VIRTUAL_DISPLAYS
endif
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 22d01ae..9eaf57b 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -165,9 +165,9 @@
mSurfaceFlingerConsumer->setContentsChangedListener(this);
mSurfaceFlingerConsumer->setName(mName);
-#ifndef TARGET_DISABLE_TRIPLE_BUFFERING
- mProducer->setMaxDequeuedBufferCount(2);
-#endif
+ if (mFlinger->isLayerTripleBufferingDisabled()) {
+ mProducer->setMaxDequeuedBufferCount(2);
+ }
const sp<const DisplayDevice> hw(mFlinger->getDefaultDisplayDevice());
updateTransformHint(hw);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f096134..5173a45 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -189,6 +189,10 @@
property_get("debug.sf.disable_hwc_vds", value, "0");
mUseHwcVirtualDisplays = !atoi(value);
ALOGI_IF(!mUseHwcVirtualDisplays, "Disabling HWC virtual displays");
+
+ property_get("ro.sf.disable_triple_buffer", value, "0");
+ mLayerTripleBufferingDisabled = !atoi(value);
+ ALOGI_IF(mLayerTripleBufferingDisabled, "Disabling Triple Buffering");
}
void SurfaceFlinger::onFirstRef()
@@ -2952,21 +2956,19 @@
mAnimFrameTracker.logAndResetStats(String8("<win-anim>"));
}
-/*static*/ void SurfaceFlinger::appendSfConfigString(String8& result)
+void SurfaceFlinger::appendSfConfigString(String8& result) const
{
- static const char* config =
- " [sf"
+ result.append(" [sf");
#ifdef HAS_CONTEXT_PRIORITY
- " HAS_CONTEXT_PRIORITY"
+ result.append(" HAS_CONTEXT_PRIORITY");
#endif
#ifdef NEVER_DEFAULT_TO_ASYNC_MODE
- " NEVER_DEFAULT_TO_ASYNC_MODE"
+ result.append(" NEVER_DEFAULT_TO_ASYNC_MODE");
#endif
-#ifdef TARGET_DISABLE_TRIPLE_BUFFERING
- " TARGET_DISABLE_TRIPLE_BUFFERING"
+ if (isLayerTripleBufferingDisabled())
+ result.append(" DISABLE_TRIPLE_BUFFERING");
#endif
- "]";
- result.append(config);
+ result.append("]");
}
void SurfaceFlinger::dumpStaticScreenStats(String8& result) const
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 2d6f9f6..f7f9ef5 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -438,7 +438,7 @@
void clearStatsLocked(const Vector<String16>& args, size_t& index, String8& result);
void dumpAllLocked(const Vector<String16>& args, size_t& index, String8& result) const;
bool startDdmConnection();
- static void appendSfConfigString(String8& result);
+ void appendSfConfigString(String8& result) const;
void checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr,
const sp<const DisplayDevice>& hw,
uint32_t minLayerZ, uint32_t maxLayerZ);
@@ -453,6 +453,9 @@
std::vector<OccupancyTracker::Segment>&& history);
void dumpBufferingStats(String8& result) const;
+ bool isLayerTripleBufferingDisabled() const {
+ return this->mLayerTripleBufferingDisabled;
+ }
/* ------------------------------------------------------------------------
* Attributes
*/
@@ -526,6 +529,9 @@
SurfaceInterceptor mInterceptor;
bool mUseHwcVirtualDisplays = true;
+ // Restrict layers to use two buffers in their bufferqueues.
+ bool mLayerTripleBufferingDisabled = false;
+
// these are thread safe
mutable MessageQueue mEventQueue;
FrameTracker mAnimFrameTracker;
diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
index 76680e0..5c42450 100644
--- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
@@ -164,7 +164,6 @@
{
ALOGI("SurfaceFlinger is starting");
- // debugging stuff...
char value[PROPERTY_VALUE_MAX];
property_get("ro.bq.gpu_to_cpu_unsupported", value, "0");
@@ -187,6 +186,10 @@
property_get("debug.sf.disable_hwc_vds", value, "0");
mUseHwcVirtualDisplays = !atoi(value);
ALOGI_IF(!mUseHwcVirtualDisplays, "Disabling HWC virtual displays");
+
+ property_get("ro.sf.disable_triple_buffer", value, "0");
+ mLayerTripleBufferingDisabled = !atoi(value);
+ ALOGI_IF(mLayerTripleBufferingDisabled, "Disabling Triple Buffering");
}
void SurfaceFlinger::onFirstRef()
@@ -2859,21 +2862,18 @@
mAnimFrameTracker.logAndResetStats(String8("<win-anim>"));
}
-/*static*/ void SurfaceFlinger::appendSfConfigString(String8& result)
+void SurfaceFlinger::appendSfConfigString(String8& result) const
{
- static const char* config =
- " [sf"
+ result.append(" [sf");
#ifdef HAS_CONTEXT_PRIORITY
- " HAS_CONTEXT_PRIORITY"
+ result.append(" HAS_CONTEXT_PRIORITY");
#endif
#ifdef NEVER_DEFAULT_TO_ASYNC_MODE
- " NEVER_DEFAULT_TO_ASYNC_MODE"
+ result.append(" NEVER_DEFAULT_TO_ASYNC_MODE");
#endif
-#ifdef TARGET_DISABLE_TRIPLE_BUFFERING
- " TARGET_DISABLE_TRIPLE_BUFFERING"
-#endif
- "]";
- result.append(config);
+ if (isLayerTripleBufferingDisabled())
+ result.append(" DISABLE_TRIPLE_BUFFERING");
+ result.append("]");
}
void SurfaceFlinger::dumpStaticScreenStats(String8& result) const