Refactor obtaining display in SF main thread
Getting the display requires the SF state lock, and this can
cause deadlocks if this work is done on a binder thread. The
eventual goal is to place all the work in renderScreenImpl on the
binder thread, so reshuffling where we get the display to an area
where we already go onto the main thread will reduce lock contention.
Additional cleanups to remove overloaded renderScreenImpl for
testable SF suite.
Bug: b/294936197
Test: atest SurfaceFlinger_test
Test: atest CompositionTest
Test: presubmit
Change-Id: I95697a2508a9d936ac9689430d9060c49ed3f039
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 8a39016..209d9bc 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -898,25 +898,26 @@
ui::Size bufferSize, ui::PixelFormat, bool allowProtected,
bool grayscale, const sp<IScreenCaptureListener>&);
+ using OutputCompositionState = compositionengine::impl::OutputCompositionState;
+
+ const sp<const DisplayDevice> getRenderAreaDisplay(RenderAreaBuilderVariant& renderAreaBuilder,
+ OutputCompositionState& state)
+ REQUIRES(kMainThreadContext);
+
+ std::vector<std::pair<Layer*, sp<android::LayerFE>>> getLayerSnapshotsFromMainThread(
+ GetLayerSnapshotsFunction getLayerSnapshotsFn) REQUIRES(kMainThreadContext);
+
ftl::SharedFuture<FenceResult> captureScreenshot(
RenderAreaBuilderVariant, GetLayerSnapshotsFunction,
const std::shared_ptr<renderengine::ExternalTexture>&, bool regionSampling,
bool grayscale, bool isProtected, const sp<IScreenCaptureListener>&);
- // Overloaded version of renderScreenImpl that is used when layer snapshots have
- // not yet been captured, and thus cannot yet be passed in as a parameter.
- // Needed for TestableSurfaceFlinger.
- ftl::SharedFuture<FenceResult> renderScreenImpl(
- std::unique_ptr<const RenderArea>, GetLayerSnapshotsFunction,
- const std::shared_ptr<renderengine::ExternalTexture>&, bool regionSampling,
- bool grayscale, bool isProtected, ScreenCaptureResults&) EXCLUDES(mStateLock)
- REQUIRES(kMainThreadContext);
-
ftl::SharedFuture<FenceResult> renderScreenImpl(
std::unique_ptr<const RenderArea>,
const std::shared_ptr<renderengine::ExternalTexture>&, bool regionSampling,
bool grayscale, bool isProtected, ScreenCaptureResults&,
- std::vector<std::pair<Layer*, sp<android::LayerFE>>>& layers) EXCLUDES(mStateLock)
+ const sp<const DisplayDevice> display, const OutputCompositionState& state,
+ std::vector<std::pair<Layer*, sp<android::LayerFE>>>& layers)
REQUIRES(kMainThreadContext);
// If the uid provided is not UNSET_UID, the traverse will skip any layers that don't have a