diff options
author | 2023-07-06 18:07:21 -0700 | |
---|---|---|
committer | 2023-07-07 16:08:34 +0000 | |
commit | 73e6d3788d4e904b927b1185cb7a299160a0268e (patch) | |
tree | a2a30a1217fda4d0cfb706a003d8beafad956b5c | |
parent | 7a039af79c5d04cd97385182ed93e59c794204c6 (diff) |
Remove PointerProperties::copyFrom
Remove copyFrom in favor of default-generated operator=.
Bug: 271455682
Test: m checkinput
Change-Id: Ie00d027bcbf0a994e04e6b79a107c32077c3a3d8
-rw-r--r-- | include/input/Input.h | 4 | ||||
-rw-r--r-- | libs/input/Input.cpp | 13 | ||||
-rw-r--r-- | libs/input/InputTransport.cpp | 14 | ||||
-rw-r--r-- | services/inputflinger/NotifyArgs.cpp | 4 | ||||
-rw-r--r-- | services/inputflinger/dispatcher/Entry.cpp | 4 | ||||
-rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 6 | ||||
-rw-r--r-- | services/inputflinger/dispatcher/InputState.cpp | 21 | ||||
-rw-r--r-- | services/inputflinger/reader/mapper/TouchInputMapper.cpp | 29 |
8 files changed, 39 insertions, 56 deletions
diff --git a/include/input/Input.h b/include/input/Input.h index ea856c8f43..1fc9cb1207 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -493,12 +493,12 @@ struct PointerProperties { toolType = ToolType::UNKNOWN; } - bool operator==(const PointerProperties& other) const; + bool operator==(const PointerProperties& other) const = default; inline bool operator!=(const PointerProperties& other) const { return !(*this == other); } - void copyFrom(const PointerProperties& other); + PointerProperties& operator=(const PointerProperties&) = default; }; /* diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index 00925ba555..c1274110d3 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -497,19 +497,6 @@ void PointerCoords::transform(const ui::Transform& transform) { } } -// --- PointerProperties --- - -bool PointerProperties::operator==(const PointerProperties& other) const { - return id == other.id - && toolType == other.toolType; -} - -void PointerProperties::copyFrom(const PointerProperties& other) { - id = other.id; - toolType = other.toolType; -} - - // --- MotionEvent --- void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source, int32_t displayId, diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp index 0b0309e27b..d9b7700f4f 100644 --- a/libs/input/InputTransport.cpp +++ b/libs/input/InputTransport.cpp @@ -692,8 +692,8 @@ status_t InputPublisher::publishMotionEvent( msg.body.motion.eventTime = eventTime; msg.body.motion.pointerCount = pointerCount; for (uint32_t i = 0; i < pointerCount; i++) { - msg.body.motion.pointers[i].properties.copyFrom(pointerProperties[i]); - msg.body.motion.pointers[i].coords.copyFrom(pointerCoords[i]); + msg.body.motion.pointers[i].properties = pointerProperties[i]; + msg.body.motion.pointers[i].coords = pointerCoords[i]; } return mChannel->sendMessage(&msg); @@ -1270,13 +1270,13 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event, // We know here that the coordinates for the pointer haven't changed because we // would've cleared the resampled bit in rewriteMessage if they had. We can't modify // lastResample in place becasue the mapping from pointer ID to index may have changed. - touchState.lastResample.pointers[i].copyFrom(oldLastResample.getPointerById(id)); + touchState.lastResample.pointers[i] = oldLastResample.getPointerById(id); continue; } PointerCoords& resampledCoords = touchState.lastResample.pointers[i]; const PointerCoords& currentCoords = current->getPointerById(id); - resampledCoords.copyFrom(currentCoords); + resampledCoords = currentCoords; if (other->idBits.hasBit(id) && shouldResampleTool(event->getToolType(i))) { const PointerCoords& otherCoords = other->getPointerById(id); resampledCoords.setAxisValue(AMOTION_EVENT_AXIS_X, @@ -1454,8 +1454,8 @@ void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage PointerProperties pointerProperties[pointerCount]; PointerCoords pointerCoords[pointerCount]; for (uint32_t i = 0; i < pointerCount; i++) { - pointerProperties[i].copyFrom(msg->body.motion.pointers[i].properties); - pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords); + pointerProperties[i] = msg->body.motion.pointers[i].properties; + pointerCoords[i] = msg->body.motion.pointers[i].coords; } ui::Transform transform; @@ -1484,7 +1484,7 @@ void InputConsumer::addSample(MotionEvent* event, const InputMessage* msg) { uint32_t pointerCount = msg->body.motion.pointerCount; PointerCoords pointerCoords[pointerCount]; for (uint32_t i = 0; i < pointerCount; i++) { - pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords); + pointerCoords[i] = msg->body.motion.pointers[i].coords; } event->setMetaState(event->getMetaState() | msg->body.motion.metaState); diff --git a/services/inputflinger/NotifyArgs.cpp b/services/inputflinger/NotifyArgs.cpp index 0fa47d1a7c..c34cd5346e 100644 --- a/services/inputflinger/NotifyArgs.cpp +++ b/services/inputflinger/NotifyArgs.cpp @@ -91,8 +91,8 @@ NotifyMotionArgs::NotifyMotionArgs( readTime(readTime), videoFrames(videoFrames) { for (uint32_t i = 0; i < pointerCount; i++) { - this->pointerProperties.push_back(pointerProperties[i]); - this->pointerCoords.push_back(pointerCoords[i]); + this->pointerProperties.emplace_back(pointerProperties[i]); + this->pointerCoords.emplace_back(pointerCoords[i]); } } diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp index a670ebe04e..a0f0dcb221 100644 --- a/services/inputflinger/dispatcher/Entry.cpp +++ b/services/inputflinger/dispatcher/Entry.cpp @@ -235,8 +235,8 @@ MotionEntry::MotionEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32 downTime(downTime), pointerCount(pointerCount) { for (uint32_t i = 0; i < pointerCount; i++) { - this->pointerProperties[i].copyFrom(pointerProperties[i]); - this->pointerCoords[i].copyFrom(pointerCoords[i]); + this->pointerProperties[i] = pointerProperties[i]; + this->pointerCoords[i] = pointerCoords[i]; } } diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index abb0610667..1d9c5b4228 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -4093,9 +4093,9 @@ std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent( uint32_t pointerId = uint32_t(pointerProperties.id); if (pointerIds.test(pointerId)) { splitPointerIndexMap[splitPointerCount] = originalPointerIndex; - splitPointerProperties[splitPointerCount].copyFrom(pointerProperties); - splitPointerCoords[splitPointerCount].copyFrom( - originalMotionEntry.pointerCoords[originalPointerIndex]); + splitPointerProperties[splitPointerCount] = pointerProperties; + splitPointerCoords[splitPointerCount] = + originalMotionEntry.pointerCoords[originalPointerIndex]; splitPointerCount += 1; } } diff --git a/services/inputflinger/dispatcher/InputState.cpp b/services/inputflinger/dispatcher/InputState.cpp index 2fcb89a731..fe0b89c025 100644 --- a/services/inputflinger/dispatcher/InputState.cpp +++ b/services/inputflinger/dispatcher/InputState.cpp @@ -240,8 +240,8 @@ void InputState::MotionMemento::setPointers(const MotionEntry& entry) { continue; } } - pointerProperties[pointerCount].copyFrom(entry.pointerProperties[i]); - pointerCoords[pointerCount].copyFrom(entry.pointerCoords[i]); + pointerProperties[pointerCount] = entry.pointerProperties[i]; + pointerCoords[pointerCount] = entry.pointerCoords[i]; pointerCount++; } } @@ -251,8 +251,8 @@ void InputState::MotionMemento::mergePointerStateTo(MotionMemento& other) const if (other.firstNewPointerIdx < 0) { other.firstNewPointerIdx = other.pointerCount; } - other.pointerProperties[other.pointerCount].copyFrom(pointerProperties[i]); - other.pointerCoords[other.pointerCount].copyFrom(pointerCoords[i]); + other.pointerProperties[other.pointerCount] = pointerProperties[i]; + other.pointerCoords[other.pointerCount] = pointerCoords[i]; other.pointerCount++; } } @@ -324,17 +324,16 @@ std::vector<std::unique_ptr<EventEntry>> InputState::synthesizePointerDownEvents // We will deliver all pointers the target already knows about for (uint32_t i = 0; i < static_cast<uint32_t>(memento.firstNewPointerIdx); i++) { - pointerProperties[i].copyFrom(memento.pointerProperties[i]); - pointerCoords[i].copyFrom(memento.pointerCoords[i]); + pointerProperties[i] = memento.pointerProperties[i]; + pointerCoords[i] = memento.pointerCoords[i]; pointerCount++; } // We will send explicit events for all pointers the target doesn't know about for (uint32_t i = static_cast<uint32_t>(memento.firstNewPointerIdx); i < memento.pointerCount; i++) { - - pointerProperties[i].copyFrom(memento.pointerProperties[i]); - pointerCoords[i].copyFrom(memento.pointerCoords[i]); + pointerProperties[i] = memento.pointerProperties[i]; + pointerCoords[i] = memento.pointerCoords[i]; pointerCount++; // Down only if the first pointer, pointer down otherwise @@ -370,8 +369,8 @@ std::vector<std::unique_ptr<MotionEntry>> InputState::synthesizeCancelationEvent std::vector<PointerCoords> pointerCoords(MAX_POINTERS); for (uint32_t pointerIdx = 0; pointerIdx < memento.pointerCount; pointerIdx++) { uint32_t pointerId = uint32_t(memento.pointerProperties[pointerIdx].id); - pointerProperties[pointerIdx].copyFrom(memento.pointerProperties[pointerIdx]); - pointerCoords[pointerIdx].copyFrom(memento.pointerCoords[pointerIdx]); + pointerProperties[pointerIdx] = memento.pointerProperties[pointerIdx]; + pointerCoords[pointerIdx] = memento.pointerCoords[pointerIdx]; if (pointerIds.test(pointerId)) { canceledPointerIndices.push_back(pointerIdx); } diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp index f48ff4cb00..b565454805 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp @@ -2009,12 +2009,12 @@ static bool updateMovedPointers(const PropertiesArray& inProperties, CoordsArray PointerCoords& curOutCoords = outCoords[outIndex]; if (curInProperties != curOutProperties) { - curOutProperties.copyFrom(curInProperties); + curOutProperties = curInProperties; changed = true; } if (curInCoords != curOutCoords) { - curOutCoords.copyFrom(curInCoords); + curOutCoords = curInCoords; changed = true; } } @@ -2756,10 +2756,9 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerGestures(nsecs_t when, ns for (BitSet32 idBits(mPointerGesture.currentGestureIdBits); !idBits.isEmpty();) { uint32_t id = idBits.clearFirstMarkedBit(); uint32_t index = mPointerGesture.currentGestureIdToIndex[id]; - mPointerGesture.lastGestureProperties[index].copyFrom( - mPointerGesture.currentGestureProperties[index]); - mPointerGesture.lastGestureCoords[index].copyFrom( - mPointerGesture.currentGestureCoords[index]); + mPointerGesture.lastGestureProperties[index] = + mPointerGesture.currentGestureProperties[index]; + mPointerGesture.lastGestureCoords[index] = mPointerGesture.currentGestureCoords[index]; mPointerGesture.lastGestureIdToIndex[id] = index; } } @@ -3543,8 +3542,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerStylus(nsecs_t when, nsec std::tie(x, y) = mPointerController->getPosition(); } - mPointerSimple.currentCoords.copyFrom( - mCurrentCookedState.cookedPointerData.pointerCoords[index]); + mPointerSimple.currentCoords = mCurrentCookedState.cookedPointerData.pointerCoords[index]; mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y); mPointerSimple.currentProperties.id = 0; @@ -3582,8 +3580,8 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerMouse(nsecs_t when, nsecs const auto [x, y] = mPointerController->getPosition(); const uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id]; - mPointerSimple.currentCoords.copyFrom( - mCurrentCookedState.cookedPointerData.pointerCoords[currentIndex]); + mPointerSimple.currentCoords = + mCurrentCookedState.cookedPointerData.pointerCoords[currentIndex]; mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y); mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, @@ -3723,8 +3721,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerSimple(nsecs_t when, nsec mWheelXVelocityControl.move(when, &hscroll, nullptr); // Send scroll. - PointerCoords pointerCoords; - pointerCoords.copyFrom(mPointerSimple.currentCoords); + PointerCoords pointerCoords = mPointerSimple.currentCoords; pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_VSCROLL, vscroll); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll); @@ -3740,8 +3737,8 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerSimple(nsecs_t when, nsec // Save state. if (down || hovering) { - mPointerSimple.lastCoords.copyFrom(mPointerSimple.currentCoords); - mPointerSimple.lastProperties.copyFrom(mPointerSimple.currentProperties); + mPointerSimple.lastCoords = mPointerSimple.currentCoords; + mPointerSimple.lastProperties = mPointerSimple.currentProperties; mPointerSimple.displayId = displayId; mPointerSimple.source = mSource; mPointerSimple.lastCursorX = cursorPosition.x; @@ -3795,8 +3792,8 @@ NotifyMotionArgs TouchInputMapper::dispatchMotion( while (!idBits.isEmpty()) { uint32_t id = idBits.clearFirstMarkedBit(); uint32_t index = idToIndex[id]; - pointerProperties[pointerCount].copyFrom(properties[index]); - pointerCoords[pointerCount].copyFrom(coords[index]); + pointerProperties[pointerCount] = properties[index]; + pointerCoords[pointerCount] = coords[index]; if (changedId >= 0 && id == uint32_t(changedId)) { action |= pointerCount << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; |