Merge "AArch64: Use long for pointers in VelocityTracker class"
This commit is contained in:
@@ -34,17 +34,17 @@ public final class VelocityTracker {
|
|||||||
|
|
||||||
private static final int ACTIVE_POINTER_ID = -1;
|
private static final int ACTIVE_POINTER_ID = -1;
|
||||||
|
|
||||||
private int mPtr;
|
private long mPtr;
|
||||||
private final String mStrategy;
|
private final String mStrategy;
|
||||||
|
|
||||||
private static native int nativeInitialize(String strategy);
|
private static native long nativeInitialize(String strategy);
|
||||||
private static native void nativeDispose(int ptr);
|
private static native void nativeDispose(long ptr);
|
||||||
private static native void nativeClear(int ptr);
|
private static native void nativeClear(long ptr);
|
||||||
private static native void nativeAddMovement(int ptr, MotionEvent event);
|
private static native void nativeAddMovement(long ptr, MotionEvent event);
|
||||||
private static native void nativeComputeCurrentVelocity(int ptr, int units, float maxVelocity);
|
private static native void nativeComputeCurrentVelocity(long ptr, int units, float maxVelocity);
|
||||||
private static native float nativeGetXVelocity(int ptr, int id);
|
private static native float nativeGetXVelocity(long ptr, int id);
|
||||||
private static native float nativeGetYVelocity(int ptr, int id);
|
private static native float nativeGetYVelocity(long ptr, int id);
|
||||||
private static native boolean nativeGetEstimator(int ptr, int id, Estimator outEstimator);
|
private static native boolean nativeGetEstimator(long ptr, int id, Estimator outEstimator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a new VelocityTracker object to watch the velocity of a
|
* Retrieve a new VelocityTracker object to watch the velocity of a
|
||||||
|
|||||||
@@ -138,26 +138,26 @@ bool VelocityTrackerState::getEstimator(int32_t id, VelocityTracker::Estimator*
|
|||||||
|
|
||||||
// --- JNI Methods ---
|
// --- JNI Methods ---
|
||||||
|
|
||||||
static jint android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz,
|
static jlong android_view_VelocityTracker_nativeInitialize(JNIEnv* env, jclass clazz,
|
||||||
jstring strategyStr) {
|
jstring strategyStr) {
|
||||||
if (strategyStr) {
|
if (strategyStr) {
|
||||||
ScopedUtfChars strategy(env, strategyStr);
|
ScopedUtfChars strategy(env, strategyStr);
|
||||||
return reinterpret_cast<jint>(new VelocityTrackerState(strategy.c_str()));
|
return reinterpret_cast<jlong>(new VelocityTrackerState(strategy.c_str()));
|
||||||
}
|
}
|
||||||
return reinterpret_cast<jint>(new VelocityTrackerState(NULL));
|
return reinterpret_cast<jlong>(new VelocityTrackerState(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_view_VelocityTracker_nativeDispose(JNIEnv* env, jclass clazz, jint ptr) {
|
static void android_view_VelocityTracker_nativeDispose(JNIEnv* env, jclass clazz, jlong ptr) {
|
||||||
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_view_VelocityTracker_nativeClear(JNIEnv* env, jclass clazz, jint ptr) {
|
static void android_view_VelocityTracker_nativeClear(JNIEnv* env, jclass clazz, jlong ptr) {
|
||||||
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
||||||
state->clear();
|
state->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass clazz, jint ptr,
|
static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass clazz, jlong ptr,
|
||||||
jobject eventObj) {
|
jobject eventObj) {
|
||||||
const MotionEvent* event = android_view_MotionEvent_getNativePtr(env, eventObj);
|
const MotionEvent* event = android_view_MotionEvent_getNativePtr(env, eventObj);
|
||||||
if (!event) {
|
if (!event) {
|
||||||
@@ -170,13 +170,13 @@ static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass c
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void android_view_VelocityTracker_nativeComputeCurrentVelocity(JNIEnv* env, jclass clazz,
|
static void android_view_VelocityTracker_nativeComputeCurrentVelocity(JNIEnv* env, jclass clazz,
|
||||||
jint ptr, jint units, jfloat maxVelocity) {
|
jlong ptr, jint units, jfloat maxVelocity) {
|
||||||
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
||||||
state->computeCurrentVelocity(units, maxVelocity);
|
state->computeCurrentVelocity(units, maxVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jfloat android_view_VelocityTracker_nativeGetXVelocity(JNIEnv* env, jclass clazz,
|
static jfloat android_view_VelocityTracker_nativeGetXVelocity(JNIEnv* env, jclass clazz,
|
||||||
jint ptr, jint id) {
|
jlong ptr, jint id) {
|
||||||
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
||||||
float vx;
|
float vx;
|
||||||
state->getVelocity(id, &vx, NULL);
|
state->getVelocity(id, &vx, NULL);
|
||||||
@@ -184,7 +184,7 @@ static jfloat android_view_VelocityTracker_nativeGetXVelocity(JNIEnv* env, jclas
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jfloat android_view_VelocityTracker_nativeGetYVelocity(JNIEnv* env, jclass clazz,
|
static jfloat android_view_VelocityTracker_nativeGetYVelocity(JNIEnv* env, jclass clazz,
|
||||||
jint ptr, jint id) {
|
jlong ptr, jint id) {
|
||||||
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
||||||
float vy;
|
float vy;
|
||||||
state->getVelocity(id, NULL, &vy);
|
state->getVelocity(id, NULL, &vy);
|
||||||
@@ -192,7 +192,7 @@ static jfloat android_view_VelocityTracker_nativeGetYVelocity(JNIEnv* env, jclas
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jclass clazz,
|
static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jclass clazz,
|
||||||
jint ptr, jint id, jobject outEstimatorObj) {
|
jlong ptr, jint id, jobject outEstimatorObj) {
|
||||||
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
|
||||||
VelocityTracker::Estimator estimator;
|
VelocityTracker::Estimator estimator;
|
||||||
bool result = state->getEstimator(id, &estimator);
|
bool result = state->getEstimator(id, &estimator);
|
||||||
@@ -217,28 +217,28 @@ static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jcl
|
|||||||
static JNINativeMethod gVelocityTrackerMethods[] = {
|
static JNINativeMethod gVelocityTrackerMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{ "nativeInitialize",
|
{ "nativeInitialize",
|
||||||
"(Ljava/lang/String;)I",
|
"(Ljava/lang/String;)J",
|
||||||
(void*)android_view_VelocityTracker_nativeInitialize },
|
(void*)android_view_VelocityTracker_nativeInitialize },
|
||||||
{ "nativeDispose",
|
{ "nativeDispose",
|
||||||
"(I)V",
|
"(J)V",
|
||||||
(void*)android_view_VelocityTracker_nativeDispose },
|
(void*)android_view_VelocityTracker_nativeDispose },
|
||||||
{ "nativeClear",
|
{ "nativeClear",
|
||||||
"(I)V",
|
"(J)V",
|
||||||
(void*)android_view_VelocityTracker_nativeClear },
|
(void*)android_view_VelocityTracker_nativeClear },
|
||||||
{ "nativeAddMovement",
|
{ "nativeAddMovement",
|
||||||
"(ILandroid/view/MotionEvent;)V",
|
"(JLandroid/view/MotionEvent;)V",
|
||||||
(void*)android_view_VelocityTracker_nativeAddMovement },
|
(void*)android_view_VelocityTracker_nativeAddMovement },
|
||||||
{ "nativeComputeCurrentVelocity",
|
{ "nativeComputeCurrentVelocity",
|
||||||
"(IIF)V",
|
"(JIF)V",
|
||||||
(void*)android_view_VelocityTracker_nativeComputeCurrentVelocity },
|
(void*)android_view_VelocityTracker_nativeComputeCurrentVelocity },
|
||||||
{ "nativeGetXVelocity",
|
{ "nativeGetXVelocity",
|
||||||
"(II)F",
|
"(JI)F",
|
||||||
(void*)android_view_VelocityTracker_nativeGetXVelocity },
|
(void*)android_view_VelocityTracker_nativeGetXVelocity },
|
||||||
{ "nativeGetYVelocity",
|
{ "nativeGetYVelocity",
|
||||||
"(II)F",
|
"(JI)F",
|
||||||
(void*)android_view_VelocityTracker_nativeGetYVelocity },
|
(void*)android_view_VelocityTracker_nativeGetYVelocity },
|
||||||
{ "nativeGetEstimator",
|
{ "nativeGetEstimator",
|
||||||
"(IILandroid/view/VelocityTracker$Estimator;)Z",
|
"(JILandroid/view/VelocityTracker$Estimator;)Z",
|
||||||
(void*)android_view_VelocityTracker_nativeGetEstimator },
|
(void*)android_view_VelocityTracker_nativeGetEstimator },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user