diff options
| author | 2012-04-08 15:01:31 -0700 | |
|---|---|---|
| committer | 2012-04-08 15:01:31 -0700 | |
| commit | d94d3b890ac3d5731bd0397874d32aa4bc74bd61 (patch) | |
| tree | 90de381d8275418335600145d034639db90f8036 /services/surfaceflinger/EventThread.cpp | |
| parent | c522a6a5bfb5a6082dac8aa1694786390dc7c17a (diff) | |
avoid turning vsync off/on at each frame
always keep vsync active for an extra frame before
deciding if it should be turned off.
Change-Id: I55b03265b7851b33a595e46a013f2ab55e66c964
Diffstat (limited to 'services/surfaceflinger/EventThread.cpp')
| -rw-r--r-- | services/surfaceflinger/EventThread.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp index b05b7c281b..016d7acf1f 100644 --- a/services/surfaceflinger/EventThread.cpp +++ b/services/surfaceflinger/EventThread.cpp @@ -123,13 +123,9 @@ bool EventThread::threadLoop() { Mutex::Autolock _l(mLock); do { - // check if we have received a VSYNC event - if (mVSyncTimestamp) { - // we have a VSYNC event pending - timestamp = mVSyncTimestamp; - mVSyncTimestamp = 0; - break; - } + // latch VSYNC event if any + timestamp = mVSyncTimestamp; + mVSyncTimestamp = 0; // check if we should be waiting for VSYNC events bool waitForNextVsync = false; @@ -144,9 +140,27 @@ bool EventThread::threadLoop() { } } - // enable or disable VSYNC events - mHw.getHwComposer().eventControl( - HWComposer::EVENT_VSYNC, waitForNextVsync); + if (timestamp) { + if (!waitForNextVsync) { + // we received a VSYNC but we have no clients + // don't report it, and disable VSYNC events + mHw.getHwComposer().eventControl( + HWComposer::EVENT_VSYNC, false); + } else { + // report VSYNC event + break; + } + } else { + // never disable VSYNC events immediately, instead + // we'll wait to receive the event and we'll + // reevaluate whether we need to dispatch it and/or + // disable VSYNC events then. + if (waitForNextVsync) { + // enable + mHw.getHwComposer().eventControl( + HWComposer::EVENT_VSYNC, true); + } + } // wait for something to happen mCondition.wait(mLock); |