SF: Avoid allocation on hot path to IF
The number of layer stacks and listeners is small, and the predominant
operations are lookup and iteration respectively, so store them on the
stack contiguously to avoid hashing/allocation/indirection.
Preallocate the WindowInfo and DisplayInfo vectors, since reallocating
the former involves copying strings and fiddling with sp<> ref counts.
Bug: 185536303
Test: simpleperf
Test: WindowInfosListenerTest
Change-Id: I5d1d1fc3b2639a4ee5056697e1a3581c11174173
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 3cae30f..bf6b31a 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -174,9 +174,14 @@
return mDeviceProductInfo;
}
- // Get the DisplayInfo that will be sent to InputFlinger, and the display transform that should
- // be applied to all the input windows on the display.
- std::pair<gui::DisplayInfo, ui::Transform> getInputInfo() const;
+ struct InputInfo {
+ gui::DisplayInfo info;
+ ui::Transform transform;
+ bool receivesInput;
+ bool isSecure;
+ };
+
+ InputInfo getInputInfo() const;
/* ------------------------------------------------------------------------
* Display power mode management.