Loading include/input/Input.h +2 −2 Original line number Diff line number Diff line Loading @@ -488,8 +488,6 @@ struct PointerCoords { // axes, however the window scaling will not. void scale(float globalScale, float windowXScale, float windowYScale); void transform(const ui::Transform& transform, int32_t motionEventFlags); inline float getX() const { return getAxisValue(AMOTION_EVENT_AXIS_X); } Loading Loading @@ -958,6 +956,8 @@ public: static vec2 calculateTransformedXY(uint32_t source, const ui::Transform&, const vec2& xy); static float calculateTransformedAxisValue(int32_t axis, uint32_t source, int32_t flags, const ui::Transform&, const PointerCoords&); static void calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source, int32_t flags, const ui::Transform&); static PointerCoords calculateTransformedCoords(uint32_t source, int32_t flags, const ui::Transform&, const PointerCoords&); // The rounding precision for transformed motion events. Loading libs/input/Input.cpp +18 −33 Original line number Diff line number Diff line Loading @@ -548,26 +548,6 @@ bool PointerCoords::operator==(const PointerCoords& other) const { return true; } void PointerCoords::transform(const ui::Transform& transform, int32_t motionEventFlags) { const vec2 xy = transform.transform(getXYValue()); setAxisValue(AMOTION_EVENT_AXIS_X, xy.x); setAxisValue(AMOTION_EVENT_AXIS_Y, xy.y); if (BitSet64::hasBit(bits, AMOTION_EVENT_AXIS_RELATIVE_X) || BitSet64::hasBit(bits, AMOTION_EVENT_AXIS_RELATIVE_Y)) { const ui::Transform rotation(transform.getOrientation()); const vec2 relativeXy = rotation.transform(getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y)); setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, relativeXy.x); setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, relativeXy.y); } if ((motionEventFlags & AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION) != 0) { setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, transformOrientation(transform, *this, motionEventFlags)); } } // --- MotionEvent --- void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source, Loading Loading @@ -804,8 +784,9 @@ void MotionEvent::applyTransform(const std::array<float, 9>& matrix) { transform.set(matrix); // Apply the transformation to all samples. std::for_each(mSamplePointerCoords.begin(), mSamplePointerCoords.end(), [&](PointerCoords& c) { c.transform(transform, mFlags); }); std::for_each(mSamplePointerCoords.begin(), mSamplePointerCoords.end(), [&](PointerCoords& c) { calculateTransformedCoordsInPlace(c, mSource, mFlags, transform); }); if (mRawXCursorPosition != AMOTION_EVENT_INVALID_CURSOR_POSITION && mRawYCursorPosition != AMOTION_EVENT_INVALID_CURSOR_POSITION) { Loading Loading @@ -1107,28 +1088,32 @@ float MotionEvent::calculateTransformedAxisValue(int32_t axis, uint32_t source, // Keep in sync with calculateTransformedAxisValue. This is an optimization of // calculateTransformedAxisValue for all PointerCoords axes. PointerCoords MotionEvent::calculateTransformedCoords(uint32_t source, int32_t flags, const ui::Transform& transform, const PointerCoords& coords) { void MotionEvent::calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source, int32_t flags, const ui::Transform& transform) { if (shouldDisregardTransformation(source)) { return coords; return; } PointerCoords out = coords; const vec2 xy = calculateTransformedXYUnchecked(source, transform, coords.getXYValue()); out.setAxisValue(AMOTION_EVENT_AXIS_X, xy.x); out.setAxisValue(AMOTION_EVENT_AXIS_Y, xy.y); coords.setAxisValue(AMOTION_EVENT_AXIS_X, xy.x); coords.setAxisValue(AMOTION_EVENT_AXIS_Y, xy.y); const vec2 relativeXy = transformWithoutTranslation(transform, {coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y)}); out.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, relativeXy.x); out.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, relativeXy.y); coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, relativeXy.x); coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, relativeXy.y); out.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, coords.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, transformOrientation(transform, coords, flags)); } PointerCoords MotionEvent::calculateTransformedCoords(uint32_t source, int32_t flags, const ui::Transform& transform, const PointerCoords& coords) { PointerCoords out = coords; calculateTransformedCoordsInPlace(out, source, flags, transform); return out; } Loading services/inputflinger/dispatcher/InputDispatcher.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -444,10 +444,12 @@ std::unique_ptr<DispatchEntry> createDispatchEntry(const IdGenerator& idGenerato newCoords.copyFrom(motionEntry.pointerCoords[i]); // First, apply the current pointer's transform to update the coordinates into // window space. newCoords.transform(currTransform, motionEntry.flags); MotionEvent::calculateTransformedCoordsInPlace(newCoords, motionEntry.source, motionEntry.flags, currTransform); // Next, apply the inverse transform of the normalized coordinates so the // current coordinates are transformed into the normalized coordinate space. newCoords.transform(inverseTransform, motionEntry.flags); MotionEvent::calculateTransformedCoordsInPlace(newCoords, motionEntry.source, motionEntry.flags, inverseTransform); } } Loading Loading
include/input/Input.h +2 −2 Original line number Diff line number Diff line Loading @@ -488,8 +488,6 @@ struct PointerCoords { // axes, however the window scaling will not. void scale(float globalScale, float windowXScale, float windowYScale); void transform(const ui::Transform& transform, int32_t motionEventFlags); inline float getX() const { return getAxisValue(AMOTION_EVENT_AXIS_X); } Loading Loading @@ -958,6 +956,8 @@ public: static vec2 calculateTransformedXY(uint32_t source, const ui::Transform&, const vec2& xy); static float calculateTransformedAxisValue(int32_t axis, uint32_t source, int32_t flags, const ui::Transform&, const PointerCoords&); static void calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source, int32_t flags, const ui::Transform&); static PointerCoords calculateTransformedCoords(uint32_t source, int32_t flags, const ui::Transform&, const PointerCoords&); // The rounding precision for transformed motion events. Loading
libs/input/Input.cpp +18 −33 Original line number Diff line number Diff line Loading @@ -548,26 +548,6 @@ bool PointerCoords::operator==(const PointerCoords& other) const { return true; } void PointerCoords::transform(const ui::Transform& transform, int32_t motionEventFlags) { const vec2 xy = transform.transform(getXYValue()); setAxisValue(AMOTION_EVENT_AXIS_X, xy.x); setAxisValue(AMOTION_EVENT_AXIS_Y, xy.y); if (BitSet64::hasBit(bits, AMOTION_EVENT_AXIS_RELATIVE_X) || BitSet64::hasBit(bits, AMOTION_EVENT_AXIS_RELATIVE_Y)) { const ui::Transform rotation(transform.getOrientation()); const vec2 relativeXy = rotation.transform(getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y)); setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, relativeXy.x); setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, relativeXy.y); } if ((motionEventFlags & AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION) != 0) { setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, transformOrientation(transform, *this, motionEventFlags)); } } // --- MotionEvent --- void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source, Loading Loading @@ -804,8 +784,9 @@ void MotionEvent::applyTransform(const std::array<float, 9>& matrix) { transform.set(matrix); // Apply the transformation to all samples. std::for_each(mSamplePointerCoords.begin(), mSamplePointerCoords.end(), [&](PointerCoords& c) { c.transform(transform, mFlags); }); std::for_each(mSamplePointerCoords.begin(), mSamplePointerCoords.end(), [&](PointerCoords& c) { calculateTransformedCoordsInPlace(c, mSource, mFlags, transform); }); if (mRawXCursorPosition != AMOTION_EVENT_INVALID_CURSOR_POSITION && mRawYCursorPosition != AMOTION_EVENT_INVALID_CURSOR_POSITION) { Loading Loading @@ -1107,28 +1088,32 @@ float MotionEvent::calculateTransformedAxisValue(int32_t axis, uint32_t source, // Keep in sync with calculateTransformedAxisValue. This is an optimization of // calculateTransformedAxisValue for all PointerCoords axes. PointerCoords MotionEvent::calculateTransformedCoords(uint32_t source, int32_t flags, const ui::Transform& transform, const PointerCoords& coords) { void MotionEvent::calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source, int32_t flags, const ui::Transform& transform) { if (shouldDisregardTransformation(source)) { return coords; return; } PointerCoords out = coords; const vec2 xy = calculateTransformedXYUnchecked(source, transform, coords.getXYValue()); out.setAxisValue(AMOTION_EVENT_AXIS_X, xy.x); out.setAxisValue(AMOTION_EVENT_AXIS_Y, xy.y); coords.setAxisValue(AMOTION_EVENT_AXIS_X, xy.x); coords.setAxisValue(AMOTION_EVENT_AXIS_Y, xy.y); const vec2 relativeXy = transformWithoutTranslation(transform, {coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X), coords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y)}); out.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, relativeXy.x); out.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, relativeXy.y); coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, relativeXy.x); coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, relativeXy.y); out.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, coords.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, transformOrientation(transform, coords, flags)); } PointerCoords MotionEvent::calculateTransformedCoords(uint32_t source, int32_t flags, const ui::Transform& transform, const PointerCoords& coords) { PointerCoords out = coords; calculateTransformedCoordsInPlace(out, source, flags, transform); return out; } Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -444,10 +444,12 @@ std::unique_ptr<DispatchEntry> createDispatchEntry(const IdGenerator& idGenerato newCoords.copyFrom(motionEntry.pointerCoords[i]); // First, apply the current pointer's transform to update the coordinates into // window space. newCoords.transform(currTransform, motionEntry.flags); MotionEvent::calculateTransformedCoordsInPlace(newCoords, motionEntry.source, motionEntry.flags, currTransform); // Next, apply the inverse transform of the normalized coordinates so the // current coordinates are transformed into the normalized coordinate space. newCoords.transform(inverseTransform, motionEntry.flags); MotionEvent::calculateTransformedCoordsInPlace(newCoords, motionEntry.source, motionEntry.flags, inverseTransform); } } Loading