diff options
| author | 2019-11-06 09:37:31 -0800 | |
|---|---|---|
| committer | 2019-11-26 15:52:12 -0800 | |
| commit | d3b90d223824dbfe1f827d6e089d96902af08f8f (patch) | |
| tree | 17ae91bfe72ecf2675a0b4d9b4cf253f2c42878a /libs/gui/SurfaceComposerClient.cpp | |
| parent | d0d28e3183d55c4a23d87b59681ceac3e3cf133d (diff) | |
Adding triple buffering without wait
Bug: 141939236
Test: build, boot, libgui_test
Change-Id: Ibffe3f10f07493700c0ead97a96548bd13cae953
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
| -rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index a538e14dfc..2c8d4caae7 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -189,48 +189,49 @@ void TransactionCompletedListener::addSurfaceControlToCallbacks( } void TransactionCompletedListener::onTransactionCompleted(ListenerStats listenerStats) { - std::lock_guard<std::mutex> lock(mMutex); + std::unordered_map<CallbackId, CallbackTranslation> callbacksMap; + { + std::lock_guard<std::mutex> lock(mMutex); - /* This listener knows all the sp<IBinder> to sp<SurfaceControl> for all its registered - * callbackIds, except for when Transactions are merged together. This probably cannot be - * solved before this point because the Transactions could be merged together and applied in a - * different process. - * - * Fortunately, we get all the callbacks for this listener for the same frame together at the - * same time. This means if any Transactions were merged together, we will get their callbacks - * at the same time. We can combine all the sp<IBinder> to sp<SurfaceControl> maps for all the - * callbackIds to generate one super map that contains all the sp<IBinder> to sp<SurfaceControl> - * that could possibly exist for the callbacks. - */ - std::unordered_map<sp<IBinder>, sp<SurfaceControl>, SurfaceComposerClient::IBinderHash> - surfaceControls; - for (const auto& transactionStats : listenerStats.transactionStats) { - for (auto callbackId : transactionStats.callbackIds) { - auto& [callbackFunction, callbackSurfaceControls] = mCallbacks[callbackId]; - surfaceControls.insert(callbackSurfaceControls.begin(), callbackSurfaceControls.end()); + /* This listener knows all the sp<IBinder> to sp<SurfaceControl> for all its registered + * callbackIds, except for when Transactions are merged together. This probably cannot be + * solved before this point because the Transactions could be merged together and applied in + * a different process. + * + * Fortunately, we get all the callbacks for this listener for the same frame together at + * the same time. This means if any Transactions were merged together, we will get their + * callbacks at the same time. We can combine all the sp<IBinder> to sp<SurfaceControl> maps + * for all the callbackIds to generate one super map that contains all the sp<IBinder> to + * sp<SurfaceControl> that could possibly exist for the callbacks. + */ + callbacksMap = mCallbacks; + for (const auto& transactionStats : listenerStats.transactionStats) { + for (auto& callbackId : transactionStats.callbackIds) { + mCallbacks.erase(callbackId); + } } } - for (const auto& transactionStats : listenerStats.transactionStats) { for (auto callbackId : transactionStats.callbackIds) { - auto& [callbackFunction, callbackSurfaceControls] = mCallbacks[callbackId]; + auto& [callbackFunction, callbackSurfaceControls] = callbacksMap[callbackId]; if (!callbackFunction) { ALOGE("cannot call null callback function, skipping"); continue; } std::vector<SurfaceControlStats> surfaceControlStats; for (const auto& surfaceStats : transactionStats.surfaceStats) { - surfaceControlStats.emplace_back(surfaceControls[surfaceStats.surfaceControl], - surfaceStats.acquireTime, - surfaceStats.previousReleaseFence, - surfaceStats.transformHint); - surfaceControls[surfaceStats.surfaceControl]->setTransformHint( - surfaceStats.transformHint); + surfaceControlStats + .emplace_back(callbacksMap[callbackId] + .surfaceControls[surfaceStats.surfaceControl], + surfaceStats.acquireTime, surfaceStats.previousReleaseFence, + surfaceStats.transformHint); + callbacksMap[callbackId] + .surfaceControls[surfaceStats.surfaceControl] + ->setTransformHint(surfaceStats.transformHint); } callbackFunction(transactionStats.latchTime, transactionStats.presentFence, surfaceControlStats); - mCallbacks.erase(callbackId); } } } |