From a2f9042f4eec167bad04ba8923723cd9458699b5 Mon Sep 17 00:00:00 2001 From: Ashok Bhat Date: Mon, 13 Jan 2014 20:45:30 +0000 Subject: AArch64: Use long for pointers in graphics/Interpolator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For storing pointers, long is used in android/graphics/Interpolator class, as native pointers can be 64-bit. In addition, some minor changes have been done to conform with standard JNI practice (e.g. use of jint instead of int in JNI function prototypes) Change-Id: I1e181476a4fe5273ff190cf34c4a7487aa1aecf4 Signed-off-by: Ashok Bhat Signed-off-by: Marcus Oakland Signed-off-by: Kévin PETIT --- core/jni/android/graphics/Interpolator.cpp | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'core') diff --git a/core/jni/android/graphics/Interpolator.cpp b/core/jni/android/graphics/Interpolator.cpp index aa33c3d..ca04dfe 100644 --- a/core/jni/android/graphics/Interpolator.cpp +++ b/core/jni/android/graphics/Interpolator.cpp @@ -5,23 +5,26 @@ #include "SkInterpolator.h" #include "SkTemplates.h" -static SkInterpolator* Interpolator_constructor(JNIEnv* env, jobject clazz, int valueCount, int frameCount) +static jlong Interpolator_constructor(JNIEnv* env, jobject clazz, jint valueCount, jint frameCount) { - return new SkInterpolator(valueCount, frameCount); + return reinterpret_cast(new SkInterpolator(valueCount, frameCount)); } -static void Interpolator_destructor(JNIEnv* env, jobject clazz, SkInterpolator* interp) +static void Interpolator_destructor(JNIEnv* env, jobject clazz, jlong interpHandle) { + SkInterpolator* interp = reinterpret_cast(interpHandle); delete interp; } -static void Interpolator_reset(JNIEnv* env, jobject clazz, SkInterpolator* interp, int valueCount, int frameCount) +static void Interpolator_reset(JNIEnv* env, jobject clazz, jlong interpHandle, jint valueCount, jint frameCount) { + SkInterpolator* interp = reinterpret_cast(interpHandle); interp->reset(valueCount, frameCount); } -static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, SkInterpolator* interp, int index, int msec, jfloatArray valueArray, jfloatArray blendArray) +static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, jlong interpHandle, jint index, jint msec, jfloatArray valueArray, jfloatArray blendArray) { + SkInterpolator* interp = reinterpret_cast(interpHandle); SkScalar blendStorage[4]; SkScalar* blend = NULL; @@ -46,8 +49,9 @@ static void Interpolator_setKeyFrame(JNIEnv* env, jobject clazz, SkInterpolator* interp->setKeyFrame(index, msec, scalars, blend); } -static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, SkInterpolator* interp, float repeatCount, jboolean mirror) +static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, jlong interpHandle, jfloat repeatCount, jboolean mirror) { + SkInterpolator* interp = reinterpret_cast(interpHandle); if (repeatCount > 32000) repeatCount = 32000; @@ -55,8 +59,9 @@ static void Interpolator_setRepeatMirror(JNIEnv* env, jobject clazz, SkInterpola interp->setMirror(mirror != 0); } -static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator* interp, int msec, jfloatArray valueArray) +static jint Interpolator_timeToValues(JNIEnv* env, jobject clazz, jlong interpHandle, jint msec, jfloatArray valueArray) { + SkInterpolator* interp = reinterpret_cast(interpHandle); SkInterpolatorBase::Result result; float* values = valueArray ? env->GetFloatArrayElements(valueArray, NULL) : NULL; @@ -70,7 +75,7 @@ static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator* env->ReleaseFloatArrayElements(valueArray, values, 0); } - return result; + return static_cast(result); } // ---------------------------------------------------------------------------- @@ -79,12 +84,12 @@ static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator* * JNI registration. */ static JNINativeMethod gInterpolatorMethods[] = { - { "nativeConstructor", "(II)I", (void*)Interpolator_constructor }, - { "nativeDestructor", "(I)V", (void*)Interpolator_destructor }, - { "nativeReset", "(III)V", (void*)Interpolator_reset }, - { "nativeSetKeyFrame", "(III[F[F)V", (void*)Interpolator_setKeyFrame }, - { "nativeSetRepeatMirror", "(IFZ)V", (void*)Interpolator_setRepeatMirror }, - { "nativeTimeToValues", "(II[F)I", (void*)Interpolator_timeToValues } + { "nativeConstructor", "(II)J", (void*)Interpolator_constructor }, + { "nativeDestructor", "(J)V", (void*)Interpolator_destructor }, + { "nativeReset", "(JII)V", (void*)Interpolator_reset }, + { "nativeSetKeyFrame", "(JII[F[F)V", (void*)Interpolator_setKeyFrame }, + { "nativeSetRepeatMirror", "(JFZ)V", (void*)Interpolator_setRepeatMirror }, + { "nativeTimeToValues", "(JI[F)I", (void*)Interpolator_timeToValues } }; int register_android_graphics_Interpolator(JNIEnv* env) -- cgit v1.1