TouchInputMapper: Perform physical frame hit test in rotated display space
The physical frame is specified in DisplayViewport in the rotated
display space. The frame is not symmetric along the X or Y axes because
the right and bottom edges are outside of the frame. For example, for a
physical frame with bounds [left, top, right, bottom], any point with an
x value of `right` or y value of `bottom` is outside the frame, whereas
points in the frame could contain an x value of `left` and a y value of
`top`.
To address this asymmetry, we must perform any hit tests in the intended
coordinate space, which in this case is that of the rotated display.
This logic is tested again in following CLs.
Bug: 236798672
Bug: 257118693
Test: atest inputflinger_tests
Change-Id: I403a686c437aa53cb808910b296a7251e0e96321
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index 45a4962..1a583c0 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -410,9 +410,9 @@
// Always starts at (0, 0).
ui::Size mDisplayBounds{ui::kInvalidSize};
- // The physical frame is the rectangle in the natural display's coordinate space that maps to
+ // The physical frame is the rectangle in the rotated display's coordinate space that maps to
// the logical display frame.
- Rect mPhysicalFrameInDisplay{Rect::INVALID_RECT};
+ Rect mPhysicalFrameInRotatedDisplay{Rect::INVALID_RECT};
// The orientation of the input device relative to that of the display panel. It specifies
// the rotation of the input device coordinates required to produce the display panel
@@ -423,6 +423,11 @@
// coordinate space. InputReader generates events in the un-rotated display's coordinate space.
ui::Transform mRawToDisplay;
+ // The transform that maps the input device's raw coordinate space to the rotated display's
+ // coordinate space. This used to perform hit-testing of raw events with the physical frame in
+ // the rotated coordinate space. See mPhysicalFrameInRotatedDisplay.
+ ui::Transform mRawToRotatedDisplay;
+
// Translation and scaling factors, orientation-independent.
float mXScale;
float mXPrecision;
@@ -817,7 +822,7 @@
static void assignPointerIds(const RawState& last, RawState& current);
- ui::Transform computeInputTransform() const;
+ void computeInputTransforms();
void configureDeviceType();
};