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

Commit ade61bb3 authored by Omprakash Dhyade's avatar Omprakash Dhyade Committed by Linux Build Service Account
Browse files

surfaceflinger: Use only one EventThread when phase offsets are same

SurfaceFlinger uses two event-threads to support phase-offsets
for application and SurfaceFlinger itself. Extra thread may
cause scheduling issues and wake-up latency for either
SurfaceFlinger or Application, depending on scheduling, even
when running at higher priority as these threads have low-load
and qualify for task-packing.
Use single event-thread when phase offsets are same.
Debug runtime service call behavior change when same phase-offset:
1018 (set phase offset for Application): will change both
Application and SurfaceFlinger phase offsets.
1019 (set phase offset for SurfaceFlinger): Will be a no-op.

Change-Id: I2514b4ff6249e9bce3eb19f60b1dfe0de12b86d9
parent 3b580fcd
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -456,6 +456,7 @@ void SurfaceFlinger::init() {
    eglInitialize(mEGLDisplay, NULL, NULL);

    // start the EventThread
    if (vsyncPhaseOffsetNs != sfVsyncPhaseOffsetNs) {
        sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
                vsyncPhaseOffsetNs, true, "app");
        mEventThread = new EventThread(vsyncSrc, *this);
@@ -463,6 +464,12 @@ void SurfaceFlinger::init() {
                sfVsyncPhaseOffsetNs, true, "sf");
        mSFEventThread = new EventThread(sfVsyncSrc, *this);
        mEventQueue.setEventThread(mSFEventThread);
    } else {
        sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
                         vsyncPhaseOffsetNs, true, "sf-app");
        mEventThread = new EventThread(vsyncSrc, *this);
        mEventQueue.setEventThread(mEventThread);
    }

    // Initialize the H/W composer object.  There may or may not be an
    // actual hardware composer underneath.
@@ -3130,11 +3137,13 @@ status_t SurfaceFlinger::onTransact(
            }
            case 1018: { // Modify Choreographer's phase offset
                n = data.readInt32();
                if (mEventThread != NULL)
                    mEventThread->setPhaseOffset(static_cast<nsecs_t>(n));
                return NO_ERROR;
            }
            case 1019: { // Modify SurfaceFlinger's phase offset
                n = data.readInt32();
                if (mSFEventThread != NULL)
                    mSFEventThread->setPhaseOffset(static_cast<nsecs_t>(n));
                return NO_ERROR;
            }