Filter DisplayDevices that don't receive input when finding transform
Input refers to displays by displayId (layerStack id). When looking for
the display transform to use for input, skip the DisplayDevices that
cannot receive input, such as mirrored displays that have the same
layerStack id.
After filtering, there should be only one DisplayDevice per layerStack
that can recieve input.
Bug: 179274888
Test: Presubmit
Test: atest WMShellFlickerTests
Change-Id: If880b9b7ead73cc168fafb23cad25005489ececc
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 81f20ed..aa92a6f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3103,13 +3103,22 @@
void SurfaceFlinger::notifyWindowInfos() {
std::vector<WindowInfo> windowInfos;
std::vector<DisplayInfo> displayInfos;
- std::unordered_map<const DisplayDevice*, const ui::Transform> displayTransforms;
+ std::unordered_map<uint32_t /*layerStackId*/, const ui::Transform> displayTransforms;
if (enablePerWindowInputRotation()) {
for (const auto& [_, display] : ON_MAIN_THREAD(mDisplays)) {
+ if (!display->receivesInput()) {
+ continue;
+ }
+ const uint32_t layerStackId = display->getLayerStack().id;
const auto& [info, transform] = display->getInputInfo();
+ const auto& [it, emplaced] = displayTransforms.try_emplace(layerStackId, transform);
+ if (!emplaced) {
+ ALOGE("Multiple displays claim to accept input for the same layer stack: %u",
+ layerStackId);
+ continue;
+ }
displayInfos.emplace_back(info);
- displayTransforms.emplace(display.get(), transform);
}
}
@@ -3119,10 +3128,10 @@
const DisplayDevice* display = ON_MAIN_THREAD(getDisplayWithInputByLayer(layer)).get();
ui::Transform displayTransform = ui::Transform();
- if (enablePerWindowInputRotation()) {
+ if (enablePerWindowInputRotation() && display != nullptr) {
// When calculating the screen bounds we ignore the transparent region since it may
// result in an unwanted offset.
- const auto it = displayTransforms.find(display);
+ const auto it = displayTransforms.find(display->getLayerStack().id);
if (it != displayTransforms.end()) {
displayTransform = it->second;
}