Refactor to replace FloatPoint by vec2
Using FloatPoint requires unnecessory conversion between vec2 and
FloatPoint, which is inefficient.
This CL replaces FloatPoint by vec2 everywhere.
Test: atest inputflinger_tests
Bug: 245989146
Flag: EXEMPT refactor
Change-Id: I61e64e43f6bbe643eb22e758a2934294037d8a5b
diff --git a/services/inputflinger/PointerChoreographer.h b/services/inputflinger/PointerChoreographer.h
index 4ca7323..939529f 100644
--- a/services/inputflinger/PointerChoreographer.h
+++ b/services/inputflinger/PointerChoreographer.h
@@ -59,7 +59,7 @@
virtual void setDisplayViewports(const std::vector<DisplayViewport>& viewports) = 0;
virtual std::optional<DisplayViewport> getViewportForPointerDevice(
ui::LogicalDisplayId associatedDisplayId = ui::LogicalDisplayId::INVALID) = 0;
- virtual FloatPoint getMouseCursorPosition(ui::LogicalDisplayId displayId) = 0;
+ virtual vec2 getMouseCursorPosition(ui::LogicalDisplayId displayId) = 0;
virtual void setShowTouchesEnabled(bool enabled) = 0;
virtual void setStylusPointerIconEnabled(bool enabled) = 0;
/**
@@ -96,7 +96,7 @@
void setDisplayViewports(const std::vector<DisplayViewport>& viewports) override;
std::optional<DisplayViewport> getViewportForPointerDevice(
ui::LogicalDisplayId associatedDisplayId) override;
- FloatPoint getMouseCursorPosition(ui::LogicalDisplayId displayId) override;
+ vec2 getMouseCursorPosition(ui::LogicalDisplayId displayId) override;
void setShowTouchesEnabled(bool enabled) override;
void setStylusPointerIconEnabled(bool enabled) override;
bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon,
@@ -134,8 +134,8 @@
void dump(std::string& dump) override;
private:
- using PointerDisplayChange = std::optional<
- std::tuple<ui::LogicalDisplayId /*displayId*/, FloatPoint /*cursorPosition*/>>;
+ using PointerDisplayChange =
+ std::optional<std::tuple<ui::LogicalDisplayId /*displayId*/, vec2 /*cursorPosition*/>>;
// PointerChoreographer's DisplayInfoListener can outlive the PointerChoreographer because when
// the listener is registered and called from display thread, a strong pointer to the listener
@@ -171,8 +171,8 @@
const std::unordered_set<ui::LogicalDisplayId>& privacySensitiveDisplays)
REQUIRES(getLock());
- void handleUnconsumedDeltaLocked(PointerControllerInterface& pc,
- const FloatPoint& unconsumedDelta) REQUIRES(getLock());
+ void handleUnconsumedDeltaLocked(PointerControllerInterface& pc, const vec2& unconsumedDelta)
+ REQUIRES(getLock());
void populateFakeDisplayTopologyLocked(const std::vector<gui::DisplayInfo>& displayInfos)
REQUIRES(getLock());