Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b20c2ee authored by Jiyong Park's avatar Jiyong Park
Browse files

configstore: remove build flags from surfaceflinger

This change removes build flags used in building surfaceflinger.
Instead, surfaceflinger uses android.hardware.configstore HAL to get
values for the build flags at runtime.

As a first attempt, a build flag VSYNC_VENT_PHASE_OFFSET_NS is converted
to a hwbinder call to vsyncEventPhaseoffsetNs() function in
android.hardware.configstore@1.0 package.

Note that VSYNC_EVENT_PHASE_OFFSET_NS still remains in Android.mk
for non-treble targets.

Design doc: go/design-confighal
Bug: 34314793
Test: build, run, log message "Phase offset NS: ..." should be seen.

Change-Id: I43862d4df5abd3e9275ec9c0e2e0b568d8b48347
parent f70d82da
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ endif
# [1] https://developer.android.com/studio/profile/systrace.html
# [2] https://developer.android.com/training/testing/performance.html

# These are left just for non-treble devices
ifneq ($(VSYNC_EVENT_PHASE_OFFSET_NS),)
    LOCAL_CFLAGS += -DVSYNC_EVENT_PHASE_OFFSET_NS=$(VSYNC_EVENT_PHASE_OFFSET_NS)
else
@@ -131,6 +132,7 @@ LOCAL_STATIC_LIBRARIES := libhwcomposer-command-buffer libtrace_proto libvkjson
LOCAL_SHARED_LIBRARIES := \
    android.hardware.graphics.allocator@2.0 \
    android.hardware.graphics.composer@2.1 \
    android.hardware.configstore@1.0 \
    libcutils \
    liblog \
    libdl \
+22 −2
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@
#include "RenderEngine/RenderEngine.h"
#include <cutils/compiler.h>

#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>

#define DISPLAY_COUNT       1

/*
@@ -93,6 +95,22 @@ EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint na

namespace android {

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
@@ -113,7 +131,7 @@ namespace android {
// 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 const int64_t vsyncPhaseOffsetNs = VSYNC_EVENT_PHASE_OFFSET_NS;
static int64_t vsyncPhaseOffsetNs = getVsyncEventPhaseOffsetNs();

// This is the phase offset at which SurfaceFlinger's composition runs.
static const int64_t sfVsyncPhaseOffsetNs = SF_VSYNC_EVENT_PHASE_OFFSET_NS;
@@ -484,6 +502,8 @@ void SurfaceFlinger::init() {
    ALOGI(  "SurfaceFlinger's main thread ready to run. "
            "Initializing graphics H/W...");

    ALOGI("Phase offest NS: %" PRId64 "", vsyncPhaseOffsetNs);

    { // Autolock scope
        Mutex::Autolock _l(mStateLock);

@@ -664,7 +684,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
        info.xdpi = xdpi;
        info.ydpi = ydpi;
        info.fps = 1e9 / hwConfig->getVsyncPeriod();
        info.appVsyncOffset = VSYNC_EVENT_PHASE_OFFSET_NS;
        info.appVsyncOffset = vsyncPhaseOffsetNs;

        // This is how far in advance a buffer must be queued for
        // presentation at a given time.  If you want a buffer to appear