summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/DisplayDevice.cpp
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2021-08-26 14:05:36 -0700
committer Prabir Pradhan <prabirmsp@google.com> 2021-09-15 06:22:07 -0700
commit48f8cb998c61fcad3db9ca7bbebc9e424844e6e2 (patch)
treeab5f0d6a3648c074116a8ffe31c70306f893c5ab /services/surfaceflinger/DisplayDevice.cpp
parent945bf5fad1cfe1dc50e8033fa46bf2f42171366d (diff)
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
Diffstat (limited to 'services/surfaceflinger/DisplayDevice.cpp')
-rw-r--r--services/surfaceflinger/DisplayDevice.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 802a17d981..fd93b2d8f7 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -139,6 +139,34 @@ uint32_t DisplayDevice::getPageFlipCount() const {
return mCompositionDisplay->getRenderSurface()->getPageFlipCount();
}
+std::pair<gui::DisplayInfo, ui::Transform> DisplayDevice::getInputInfo() const {
+ gui::DisplayInfo info;
+ info.displayId = getLayerStack().id;
+
+ // 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 - mPhysicalOrientation;
+ auto width = getWidth();
+ auto height = getHeight();
+ if (inversePhysicalOrientation == ui::ROTATION_90 ||
+ inversePhysicalOrientation == ui::ROTATION_270) {
+ std::swap(width, height);
+ }
+ const ui::Transform undoPhysicalOrientation(ui::Transform::toRotationFlags(
+ inversePhysicalOrientation),
+ width, height);
+ const auto& displayTransform = undoPhysicalOrientation * getTransform();
+ // Send the inverse display transform to input so it can convert display coordinates to
+ // logical display.
+ info.transform = displayTransform.inverse();
+
+ info.logicalWidth = getLayerStackSpaceRect().width();
+ info.logicalHeight = getLayerStackSpaceRect().height();
+ return {info, displayTransform};
+}
+
// ----------------------------------------------------------------------------
void DisplayDevice::setPowerMode(hal::PowerMode mode) {
mPowerMode = mode;