diff options
-rw-r--r-- | services/surfaceflinger/Android.mk | 1 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayDevice.cpp | 17 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 20 |
3 files changed, 20 insertions, 18 deletions
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index aa8f189f60..9e81a8c95e 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -133,6 +133,7 @@ LOCAL_CFLAGS += -fvisibility=hidden -Werror=format LOCAL_STATIC_LIBRARIES := \ libhwcomposer-command-buffer \ + android.hardware.configstore-utils \ libtrace_proto \ libvkjson \ libvr_manager \ diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 6c18ef7389..9af4402802 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -47,6 +47,9 @@ #include "SurfaceFlinger.h" #include "Layer.h" +#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> +#include <configstore/Utils.h> + // ---------------------------------------------------------------------------- using namespace android; // ---------------------------------------------------------------------------- @@ -57,6 +60,14 @@ static constexpr bool kEGLAndroidSwapRectangle = true; static constexpr bool kEGLAndroidSwapRectangle = false; #endif +// retrieve triple buffer setting from configstore +using namespace android::hardware::configstore; +using namespace android::hardware::configstore::V1_0; + +static bool useTripleFramebuffer = getBool< + ISurfaceFlingerConfigs, + &ISurfaceFlingerConfigs::useTripleFramebuffer>(false); + #if !defined(EGL_EGLEXT_PROTOTYPES) || !defined(EGL_ANDROID_swap_rectangle) // Dummy implementation in case it is missing. inline void eglSetSwapRectangleANDROID (EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint) { @@ -165,9 +176,9 @@ DisplayDevice::DisplayDevice( // initialize the display orientation transform. setProjection(DisplayState::eOrientationDefault, mViewport, mFrame); -#ifdef NUM_FRAMEBUFFER_SURFACE_BUFFERS - surface->allocateBuffers(); -#endif + if (useTripleFramebuffer) { + surface->allocateBuffers(); + } } DisplayDevice::~DisplayDevice() { diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index d2dddba27d..c21c81676b 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -87,6 +87,7 @@ #include <cutils/compiler.h> #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> +#include <configstore/Utils.h> #define DISPLAY_COUNT 1 @@ -100,22 +101,9 @@ EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint na namespace android { +using namespace android::hardware::configstore; using namespace android::hardware::configstore::V1_0; -static sp<ISurfaceFlingerConfigs> getConfigs() { - static sp<ISurfaceFlingerConfigs> configs - = ISurfaceFlingerConfigs::getService(); - return configs; -} - -static int64_t getVsyncEventPhaseOffsetNs() { - int64_t ret = 1000000; // default value - getConfigs()->vsyncEventPhaseOffsetNs([&](OptionalInt64 value) { - if (value.specified) ret = value.value; - }); - return ret; -} - // This is the phase offset in nanoseconds of the software vsync event // relative to the vsync event reported by HWComposer. The software vsync // event is when SurfaceFlinger and Choreographer-based applications run each @@ -136,7 +124,9 @@ static int64_t getVsyncEventPhaseOffsetNs() { // the latency will end up being an additional vsync period, and animations // will hiccup. Therefore, this latency should be tuned somewhat // conservatively (or at least with awareness of the trade-off being made). -static int64_t vsyncPhaseOffsetNs = getVsyncEventPhaseOffsetNs(); +static int64_t vsyncPhaseOffsetNs = getInt64< + ISurfaceFlingerConfigs, + &ISurfaceFlingerConfigs::vsyncEventPhaseOffsetNs>(1000000); // This is the phase offset at which SurfaceFlinger's composition runs. static constexpr int64_t sfVsyncPhaseOffsetNs = SF_VSYNC_EVENT_PHASE_OFFSET_NS; |