diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 85c98a58fb..23ddf0a4ba 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3273,14 +3273,16 @@ bool SurfaceFlinger::transactionFlushNeeded() { bool SurfaceFlinger::transactionIsReadyToBeApplied(int64_t desiredPresentTime, - const Vector<ComposerState>& states) { + const Vector<ComposerState>& states, + bool updateTransactionCounters) { const nsecs_t expectedPresentTime = mExpectedPresentTime.load(); + bool ready = true; // Do not present if the desiredPresentTime has not passed unless it is more than one second // in the future. We ignore timestamps more than 1 second in the future for stability reasons. if (desiredPresentTime >= 0 && desiredPresentTime >= expectedPresentTime && desiredPresentTime < expectedPresentTime + s2ns(1)) { - return false; + ready = false; } for (const ComposerState& state : states) { @@ -3289,10 +3291,22 @@ bool SurfaceFlinger::transactionIsReadyToBeApplied(int64_t desiredPresentTime, continue; } if (s.acquireFence && s.acquireFence->getStatus() == Fence::Status::Unsignaled) { - return false; + ready = false; + } + if (updateTransactionCounters) { + sp<Layer> layer = nullptr; + if (s.surface) { + layer = fromHandleLocked(s.surface).promote(); + } else { + ALOGW("Transaction with buffer, but no Layer?"); + continue; + } + // See BufferStateLayer::mPendingBufferTransactions + if (layer) layer->incrementPendingBufferCount(); + } } - return true; + return ready; } status_t SurfaceFlinger::setTransactionState( @@ -3336,7 +3350,7 @@ status_t SurfaceFlinger::setTransactionState( const int originPid = ipc->getCallingPid(); const int originUid = ipc->getCallingUid(); - if (pendingTransactions || !transactionIsReadyToBeApplied(desiredPresentTime, states)) { + if (pendingTransactions || !transactionIsReadyToBeApplied(desiredPresentTime, states, true)) { mTransactionQueues[applyToken].emplace(frameTimelineVsyncId, states, displays, flags, desiredPresentTime, uncacheBuffer, postTime, privileged, hasListenerCallbacks, listenerCallbacks, |