Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d56066b9 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Pass MotionEvent by reference" into main

parents a7a98560 1dcef1b4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public:
    explicit VelocityTrackerState(const VelocityTracker::Strategy strategy);

    void clear();
    void addMovement(const MotionEvent* event);
    void addMovement(const MotionEvent& event);
    // TODO(b/32830165): consider supporting an overload that supports computing velocity only for
    // a subset of the supported axes.
    void computeCurrentVelocity(int32_t units, float maxVelocity);
@@ -57,7 +57,7 @@ void VelocityTrackerState::clear() {
    mVelocityTracker.clear();
}

void VelocityTrackerState::addMovement(const MotionEvent* event) {
void VelocityTrackerState::addMovement(const MotionEvent& event) {
    mVelocityTracker.addMovement(event);
}

@@ -102,13 +102,13 @@ static void android_view_VelocityTracker_nativeClear(JNIEnv* env, jclass clazz,
static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass clazz, jlong ptr,
        jobject eventObj) {
    const MotionEvent* event = android_view_MotionEvent_getNativePtr(env, eventObj);
    if (!event) {
    if (event == nullptr) {
        LOG(WARNING) << "nativeAddMovement failed because MotionEvent was finalized.";
        return;
    }

    VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
    state->addMovement(event);
    state->addMovement(*event);
}

static void android_view_VelocityTracker_nativeComputeCurrentVelocity(JNIEnv* env, jclass clazz,