SF Tracing: Provide a valid starting bounds
When generating layer bounds, we start with scaled display bounds
to set a crop on boundless layers (layers that scale to the display).
This breaks for layer trace generator since there are no displays
when recreating the trace. To fix this, we provide a valid display
bounds when starting the layer bounds calculations.
Test: sh $ANDROID_BUILD_TOP/frameworks/native/services/surfaceflinger/Tracing/tools/run.sh
Bug: 200284593
Change-Id: I54dde9f5e2f73b3b135b8997d6bfdbe394116e3a
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 416725b..2c593a7 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2603,6 +2603,13 @@
// Find the largest width and height among all the displays.
int32_t maxDisplayWidth = 0;
int32_t maxDisplayHeight = 0;
+
+ // If there are no displays, set a valid display bounds so we can still compute a valid layer
+ // bounds.
+ if (ON_MAIN_THREAD(mDisplays.size()) == 0) {
+ maxDisplayWidth = maxDisplayHeight = 5000;
+ }
+
for (const auto& pair : ON_MAIN_THREAD(mDisplays)) {
const auto& displayDevice = pair.second;
int32_t width = displayDevice->getWidth();