Loading services/surfaceflinger/RegionSamplingThread.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -356,8 +356,7 @@ void RegionSamplingThread::captureSample() { if (FlagManager::getInstance().single_hop_screenshot() && FlagManager::getInstance().ce_fence_promise()) { std::vector<sp<LayerFE>> layerFEs; auto displayState = mFlinger.getDisplayAndLayerSnapshotsFromMainThread(renderAreaBuilder, auto displayState = mFlinger.getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs); fenceResult = mFlinger.captureScreenshot(renderAreaBuilder, buffer, kRegionSampling, kGrayscale, Loading services/surfaceflinger/SurfaceFlinger.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -2907,6 +2907,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite( } } ATRACE_NAME("postComposition"); mTimeStats->recordFrameDuration(pacesetterTarget.frameBeginTime().ns(), systemTime()); // Send a power hint after presentation is finished. Loading Loading @@ -8161,12 +8162,12 @@ bool SurfaceFlinger::layersHasProtectedLayer(const std::vector<sp<LayerFE>>& lay // Accessing display requires mStateLock, and contention for this lock // is reduced when grabbed from the main thread, thus also reducing // risk of deadlocks. std::optional<SurfaceFlinger::OutputCompositionState> SurfaceFlinger::getDisplayAndLayerSnapshotsFromMainThread( std::optional<SurfaceFlinger::OutputCompositionState> SurfaceFlinger::getSnapshotsFromMainThread( RenderAreaBuilderVariant& renderAreaBuilder, GetLayerSnapshotsFunction getLayerSnapshotsFn, std::vector<sp<LayerFE>>& layerFEs) { return mScheduler ->schedule([=, this, &renderAreaBuilder, &layerFEs]() REQUIRES(kMainThreadContext) { ATRACE_NAME("getSnapshotsFromMainThread"); auto layers = getLayerSnapshotsFn(); for (auto& [layer, layerFE] : layers) { attachReleaseFenceFutureToLayer(layer, layerFE.get(), ui::INVALID_LAYER_STACK); Loading Loading @@ -8196,8 +8197,7 @@ void SurfaceFlinger::captureScreenCommon(RenderAreaBuilderVariant renderAreaBuil FlagManager::getInstance().ce_fence_promise()) { std::vector<sp<LayerFE>> layerFEs; auto displayState = getDisplayAndLayerSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs); getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs); const bool supportsProtected = getRenderEngine().supportsProtectedContent(); bool hasProtectedLayer = false; Loading services/surfaceflinger/SurfaceFlinger.h +1 −1 Original line number Diff line number Diff line Loading @@ -896,7 +896,7 @@ private: using OutputCompositionState = compositionengine::impl::OutputCompositionState; std::optional<OutputCompositionState> getDisplayAndLayerSnapshotsFromMainThread( std::optional<OutputCompositionState> getSnapshotsFromMainThread( RenderAreaBuilderVariant& renderAreaBuilder, GetLayerSnapshotsFunction getLayerSnapshotsFn, std::vector<sp<LayerFE>>& layerFEs); Loading services/surfaceflinger/TransactionCallbackInvoker.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "TransactionCallbackInvoker.h" #include "BackgroundExecutor.h" #include "Utils/FenceUtils.h" #include "utils/Trace.h" #include <cinttypes> Loading Loading @@ -164,7 +165,7 @@ void TransactionCallbackInvoker::addPresentFence(sp<Fence> presentFence) { void TransactionCallbackInvoker::sendCallbacks(bool onCommitOnly) { // For each listener auto completedTransactionsItr = mCompletedTransactions.begin(); BackgroundExecutor::Callbacks callbacks; ftl::SmallVector<ListenerStats, 10> listenerStatsToSend; while (completedTransactionsItr != mCompletedTransactions.end()) { auto& [listener, transactionStatsDeque] = *completedTransactionsItr; ListenerStats listenerStats; Loading Loading @@ -199,10 +200,7 @@ void TransactionCallbackInvoker::sendCallbacks(bool onCommitOnly) { // keep it as an IBinder due to consistency reasons: if we // interface_cast at the IPC boundary when reading a Parcel, // we get pointers that compare unequal in the SF process. callbacks.emplace_back([stats = std::move(listenerStats)]() { interface_cast<ITransactionCompletedListener>(stats.listener) ->onTransactionCompleted(stats); }); listenerStatsToSend.emplace_back(std::move(listenerStats)); } } completedTransactionsItr++; Loading @@ -212,7 +210,14 @@ void TransactionCallbackInvoker::sendCallbacks(bool onCommitOnly) { mPresentFence.clear(); } BackgroundExecutor::getInstance().sendCallbacks(std::move(callbacks)); BackgroundExecutor::getInstance().sendCallbacks( {[listenerStatsToSend = std::move(listenerStatsToSend)]() { ATRACE_NAME("TransactionCallbackInvoker::sendCallbacks"); for (auto& stats : listenerStatsToSend) { interface_cast<ITransactionCompletedListener>(stats.listener) ->onTransactionCompleted(stats); } }}); } // ----------------------------------------------------------------------- Loading Loading
services/surfaceflinger/RegionSamplingThread.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -356,8 +356,7 @@ void RegionSamplingThread::captureSample() { if (FlagManager::getInstance().single_hop_screenshot() && FlagManager::getInstance().ce_fence_promise()) { std::vector<sp<LayerFE>> layerFEs; auto displayState = mFlinger.getDisplayAndLayerSnapshotsFromMainThread(renderAreaBuilder, auto displayState = mFlinger.getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs); fenceResult = mFlinger.captureScreenshot(renderAreaBuilder, buffer, kRegionSampling, kGrayscale, Loading
services/surfaceflinger/SurfaceFlinger.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -2907,6 +2907,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite( } } ATRACE_NAME("postComposition"); mTimeStats->recordFrameDuration(pacesetterTarget.frameBeginTime().ns(), systemTime()); // Send a power hint after presentation is finished. Loading Loading @@ -8161,12 +8162,12 @@ bool SurfaceFlinger::layersHasProtectedLayer(const std::vector<sp<LayerFE>>& lay // Accessing display requires mStateLock, and contention for this lock // is reduced when grabbed from the main thread, thus also reducing // risk of deadlocks. std::optional<SurfaceFlinger::OutputCompositionState> SurfaceFlinger::getDisplayAndLayerSnapshotsFromMainThread( std::optional<SurfaceFlinger::OutputCompositionState> SurfaceFlinger::getSnapshotsFromMainThread( RenderAreaBuilderVariant& renderAreaBuilder, GetLayerSnapshotsFunction getLayerSnapshotsFn, std::vector<sp<LayerFE>>& layerFEs) { return mScheduler ->schedule([=, this, &renderAreaBuilder, &layerFEs]() REQUIRES(kMainThreadContext) { ATRACE_NAME("getSnapshotsFromMainThread"); auto layers = getLayerSnapshotsFn(); for (auto& [layer, layerFE] : layers) { attachReleaseFenceFutureToLayer(layer, layerFE.get(), ui::INVALID_LAYER_STACK); Loading Loading @@ -8196,8 +8197,7 @@ void SurfaceFlinger::captureScreenCommon(RenderAreaBuilderVariant renderAreaBuil FlagManager::getInstance().ce_fence_promise()) { std::vector<sp<LayerFE>> layerFEs; auto displayState = getDisplayAndLayerSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs); getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs); const bool supportsProtected = getRenderEngine().supportsProtectedContent(); bool hasProtectedLayer = false; Loading
services/surfaceflinger/SurfaceFlinger.h +1 −1 Original line number Diff line number Diff line Loading @@ -896,7 +896,7 @@ private: using OutputCompositionState = compositionengine::impl::OutputCompositionState; std::optional<OutputCompositionState> getDisplayAndLayerSnapshotsFromMainThread( std::optional<OutputCompositionState> getSnapshotsFromMainThread( RenderAreaBuilderVariant& renderAreaBuilder, GetLayerSnapshotsFunction getLayerSnapshotsFn, std::vector<sp<LayerFE>>& layerFEs); Loading
services/surfaceflinger/TransactionCallbackInvoker.cpp +11 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "TransactionCallbackInvoker.h" #include "BackgroundExecutor.h" #include "Utils/FenceUtils.h" #include "utils/Trace.h" #include <cinttypes> Loading Loading @@ -164,7 +165,7 @@ void TransactionCallbackInvoker::addPresentFence(sp<Fence> presentFence) { void TransactionCallbackInvoker::sendCallbacks(bool onCommitOnly) { // For each listener auto completedTransactionsItr = mCompletedTransactions.begin(); BackgroundExecutor::Callbacks callbacks; ftl::SmallVector<ListenerStats, 10> listenerStatsToSend; while (completedTransactionsItr != mCompletedTransactions.end()) { auto& [listener, transactionStatsDeque] = *completedTransactionsItr; ListenerStats listenerStats; Loading Loading @@ -199,10 +200,7 @@ void TransactionCallbackInvoker::sendCallbacks(bool onCommitOnly) { // keep it as an IBinder due to consistency reasons: if we // interface_cast at the IPC boundary when reading a Parcel, // we get pointers that compare unequal in the SF process. callbacks.emplace_back([stats = std::move(listenerStats)]() { interface_cast<ITransactionCompletedListener>(stats.listener) ->onTransactionCompleted(stats); }); listenerStatsToSend.emplace_back(std::move(listenerStats)); } } completedTransactionsItr++; Loading @@ -212,7 +210,14 @@ void TransactionCallbackInvoker::sendCallbacks(bool onCommitOnly) { mPresentFence.clear(); } BackgroundExecutor::getInstance().sendCallbacks(std::move(callbacks)); BackgroundExecutor::getInstance().sendCallbacks( {[listenerStatsToSend = std::move(listenerStatsToSend)]() { ATRACE_NAME("TransactionCallbackInvoker::sendCallbacks"); for (auto& stats : listenerStatsToSend) { interface_cast<ITransactionCompletedListener>(stats.listener) ->onTransactionCompleted(stats); } }}); } // ----------------------------------------------------------------------- Loading