Report gui::DisplayInfo to clients with window info changes
InputFlinger needs to know specifications about displays such as
orientation and projection from SurfaceFlinger to support the
MotionEvent#getRaw API, which returns coordinates in logical display
space at the moment.
Since dispatcher gets window information from SF, we need to send the
display information that affects input dispatching at the same time as
updating window information to ensure those two pieces of information
remain in sync.
Instead of sending display information along with each window, we
attempt to reduce the amount of information sent through binder by
sending DisplayInfo separately to WindowInfos. The newly added
DisplayInfo struct should only be used by InputFlinger to support raw
coordinates for now, with the goal of removing it altogether in the
future.
Bug: 179274888
Test: atest libgui_test inputflinger_tests
Test: manual, ensure input works
Change-Id: I87429ca4ced5f105f49a117c676cba29f8a5c4da
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 804cf9a..2376b83 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2131,7 +2131,7 @@
if (traceFlags & SurfaceTracing::TRACE_INPUT) {
WindowInfo info;
if (useDrawing) {
- info = fillInputInfo(nullptr);
+ info = fillInputInfo(ui::Transform());
} else {
info = state.inputInfo;
}
@@ -2265,7 +2265,7 @@
}
}
-WindowInfo Layer::fillInputInfo(const DisplayDevice* display) {
+WindowInfo Layer::fillInputInfo(const ui::Transform& displayTransform) {
if (!hasInputInfo()) {
mDrawingState.inputInfo.name = getName();
mDrawingState.inputInfo.ownerUid = mOwnerUid;
@@ -2279,35 +2279,6 @@
info.id = sequence;
info.displayId = getLayerStack().id;
- // Transform that maps from LayerStack space to display space, e.g. rotated to non-rotated.
- // Used when InputFlinger operates in display space.
- ui::Transform displayTransform;
- if (display) {
- // The physical orientation is set when the orientation of the display panel is different
- // than the default orientation of the device. Other services like InputFlinger do not know
- // about this, so we do not need to expose the physical orientation of the panel outside of
- // SurfaceFlinger.
- const ui::Rotation inversePhysicalOrientation =
- ui::ROTATION_0 - display->getPhysicalOrientation();
- auto width = display->getWidth();
- auto height = display->getHeight();
- if (inversePhysicalOrientation == ui::ROTATION_90 ||
- inversePhysicalOrientation == ui::ROTATION_270) {
- std::swap(width, height);
- }
- const ui::Transform undoPhysicalOrientation(ui::Transform::toRotationFlags(
- inversePhysicalOrientation),
- width, height);
- displayTransform = undoPhysicalOrientation * display->getTransform();
-
- // Send the inverse of the display orientation so that input can transform points back to
- // the rotated display space.
- const ui::Rotation inverseOrientation = ui::ROTATION_0 - display->getOrientation();
- info.displayOrientation = ui::Transform::toRotationFlags(inverseOrientation);
-
- info.displayWidth = width;
- info.displayHeight = height;
- }
fillInputFrameInfo(info, displayTransform);
// For compatibility reasons we let layers which can receive input