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
This commit is contained in:
Omprakash Dhyade 2016-02-05 14:54:08 -08:00 committed by Steve Kondik
parent b0cda680c2
commit 9e3751980f

View File

@ -453,13 +453,20 @@ void SurfaceFlinger::init() {
eglInitialize(mEGLDisplay, NULL, NULL); eglInitialize(mEGLDisplay, NULL, NULL);
// start the EventThread // start the EventThread
sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync, if (vsyncPhaseOffsetNs != sfVsyncPhaseOffsetNs) {
vsyncPhaseOffsetNs, true, "app"); sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
mEventThread = new EventThread(vsyncSrc); vsyncPhaseOffsetNs, true, "app");
sp<VSyncSource> sfVsyncSrc = new DispSyncSource(&mPrimaryDispSync, mEventThread = new EventThread(vsyncSrc);
sfVsyncPhaseOffsetNs, true, "sf"); sp<VSyncSource> sfVsyncSrc = new DispSyncSource(&mPrimaryDispSync,
mSFEventThread = new EventThread(sfVsyncSrc); sfVsyncPhaseOffsetNs, true, "sf");
mEventQueue.setEventThread(mSFEventThread); mSFEventThread = new EventThread(sfVsyncSrc);
mEventQueue.setEventThread(mSFEventThread);
} else {
sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
vsyncPhaseOffsetNs, true, "sf-app");
mEventThread = new EventThread(vsyncSrc);
mEventQueue.setEventThread(mEventThread);
}
// Initialize the H/W composer object. There may or may not be an // Initialize the H/W composer object. There may or may not be an
// actual hardware composer underneath. // actual hardware composer underneath.
@ -3137,12 +3144,14 @@ status_t SurfaceFlinger::onTransact(
} }
case 1018: { // Modify Choreographer's phase offset case 1018: { // Modify Choreographer's phase offset
n = data.readInt32(); n = data.readInt32();
mEventThread->setPhaseOffset(static_cast<nsecs_t>(n)); if (mEventThread != NULL)
mEventThread->setPhaseOffset(static_cast<nsecs_t>(n));
return NO_ERROR; return NO_ERROR;
} }
case 1019: { // Modify SurfaceFlinger's phase offset case 1019: { // Modify SurfaceFlinger's phase offset
n = data.readInt32(); n = data.readInt32();
mSFEventThread->setPhaseOffset(static_cast<nsecs_t>(n)); if (mSFEventThread != NULL)
mSFEventThread->setPhaseOffset(static_cast<nsecs_t>(n));
return NO_ERROR; return NO_ERROR;
} }
} }