From 2ffa36b70412a84873e67a6d31123bafdafc9b78 Mon Sep 17 00:00:00 2001 From: Melody Hsu Date: Wed, 8 May 2024 03:51:46 +0000 Subject: Refactor RenderAreaFuture to use RenderAreaBuilder Cleans up renderArea logic and allows all the work that needs to be done on the main thread in the same place. This will aid in the effort to reduce the number of hops to the SF main thread during screenshots. Bug: b/294936197 Test: atest SurfaceFlinger_test Test: presubmit Change-Id: I4234b49638aaecceb8d1fcff7f5cd43698b6c47f --- services/surfaceflinger/RegionSamplingThread.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'services/surfaceflinger/RegionSamplingThread.cpp') diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp index 2ec20ad5c2..2b4e234604 100644 --- a/services/surfaceflinger/RegionSamplingThread.cpp +++ b/services/surfaceflinger/RegionSamplingThread.cpp @@ -279,14 +279,6 @@ void RegionSamplingThread::captureSample() { const Rect sampledBounds = sampleRegion.bounds(); constexpr bool kHintForSeamlessTransition = false; - SurfaceFlinger::RenderAreaFuture renderAreaFuture = ftl::defer([=] { - DisplayRenderAreaBuilder displayRenderArea(sampledBounds, sampledBounds.getSize(), - ui::Dataspace::V0_SRGB, - kHintForSeamlessTransition, - true /* captureSecureLayers */, displayWeak); - return displayRenderArea.build(); - }); - std::unordered_set, SpHash> listeners; auto layerFilterFn = [&](const char* layerName, uint32_t layerId, const Rect& bounds, @@ -381,8 +373,14 @@ void RegionSamplingThread::captureSample() { constexpr bool kIsProtected = false; if (const auto fenceResult = - mFlinger.captureScreenshot(std::move(renderAreaFuture), getLayerSnapshots, buffer, - kRegionSampling, kGrayscale, kIsProtected, nullptr) + mFlinger.captureScreenshot(SurfaceFlinger::RenderAreaBuilderVariant( + std::in_place_type, + sampledBounds, sampledBounds.getSize(), + ui::Dataspace::V0_SRGB, + kHintForSeamlessTransition, + true /* captureSecureLayers */, displayWeak), + getLayerSnapshots, buffer, kRegionSampling, kGrayscale, + kIsProtected, nullptr) .get(); fenceResult.ok()) { fenceResult.value()->waitForever(LOG_TAG); -- cgit v1.2.3-59-g8ed1b