diff options
author | Andy McFadden <fadden@android.com> | 2013-06-28 13:52:40 -0700 |
---|---|---|
committer | Andy McFadden <fadden@android.com> | 2013-07-10 15:38:40 -0700 |
commit | 1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd (patch) | |
tree | 42299de67a0088fb4416dba825e40f5b6a22312a /services/surfaceflinger/Layer.cpp | |
parent | 06b6aed2f158d48ae04c4854d2a8832777ac942e (diff) | |
download | frameworks_native-1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd.zip frameworks_native-1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd.tar.gz frameworks_native-1585c4d9fbbba3ba70ae625923b85cd02cb8a0fd.tar.bz2 |
Pay attention to buffer timestamps
When acquiring a buffer, SurfaceFlinger now computes the expected
presentation time and passes it to the BufferQueue acquireBuffer()
method. If it's not yet time to display the buffer, acquireBuffer()
returns PRESENT_LATER instead of a buffer.
The current implementation of the expected-present-time computation
uses approximations and guesswork.
Bug 7900302
Change-Id: If9345611c5983a11a811935aaf27d6388a5036f1
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index b08b8d1..31a11ce 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -1051,11 +1051,6 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions) const bool oldOpacity = isOpaque(); sp<GraphicBuffer> oldActiveBuffer = mActiveBuffer; - // signal another event if we have more frames pending - if (android_atomic_dec(&mQueuedFrames) > 1) { - mFlinger->signalLayerUpdate(); - } - struct Reject : public SurfaceFlingerConsumer::BufferRejecter { Layer::State& front; Layer::State& current; @@ -1161,7 +1156,21 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions) Reject r(mDrawingState, getCurrentState(), recomputeVisibleRegions); - if (mSurfaceFlingerConsumer->updateTexImage(&r) != NO_ERROR) { + status_t updateResult = mSurfaceFlingerConsumer->updateTexImage(&r); + if (updateResult == BufferQueue::PRESENT_LATER) { + // Producer doesn't want buffer to be displayed yet. Signal a + // layer update so we check again at the next opportunity. + mFlinger->signalLayerUpdate(); + return outDirtyRegion; + } + + // Decrement the queued-frames count. Signal another event if we + // have more frames pending. + if (android_atomic_dec(&mQueuedFrames) > 1) { + mFlinger->signalLayerUpdate(); + } + + if (updateResult != NO_ERROR) { // something happened! recomputeVisibleRegions = true; return outDirtyRegion; |