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.cpp b/services/surfaceflinger/DisplayDevice.cpp
index f542161..eef0052 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -141,7 +141,7 @@
return mCompositionDisplay->getRenderSurface()->getPageFlipCount();
}
-std::pair<gui::DisplayInfo, ui::Transform> DisplayDevice::getInputInfo() const {
+auto DisplayDevice::getInputInfo() const -> InputInfo {
gui::DisplayInfo info;
info.displayId = getLayerStack().id;
@@ -166,10 +166,13 @@
info.logicalWidth = getLayerStackSpaceRect().width();
info.logicalHeight = getLayerStackSpaceRect().height();
- return {info, displayTransform};
+
+ return {.info = info,
+ .transform = displayTransform,
+ .receivesInput = receivesInput(),
+ .isSecure = isSecure()};
}
-// ----------------------------------------------------------------------------
void DisplayDevice::setPowerMode(hal::PowerMode mode) {
mPowerMode = mode;
getCompositionDisplay()->setCompositionEnabled(mPowerMode != hal::PowerMode::OFF);