diff options
author | Narayan Kamath <narayan@google.com> | 2014-01-16 15:38:24 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-01-16 15:38:24 +0000 |
commit | 077386dbda31bfef96acca3a1ba84fece67e391a (patch) | |
tree | ede60b111806881a167f5d3f72c0e64d51168ad1 /core/jni | |
parent | 213f243f35e8ad7b605c91c08ce6271302d211a7 (diff) | |
parent | 6b81bfd10f63c166ff6e4afb0f267ce9e5275366 (diff) | |
download | frameworks_base-077386dbda31bfef96acca3a1ba84fece67e391a.zip frameworks_base-077386dbda31bfef96acca3a1ba84fece67e391a.tar.gz frameworks_base-077386dbda31bfef96acca3a1ba84fece67e391a.tar.bz2 |
am 6b81bfd1: am caea42fd: am 98002dfb: Merge "AArch64: Use long for pointers in graphics/PathMeasure"
* commit '6b81bfd10f63c166ff6e4afb0f267ce9e5275366':
AArch64: Use long for pointers in graphics/PathMeasure
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android/graphics/PathMeasure.cpp | 98 |
1 files changed, 62 insertions, 36 deletions
diff --git a/core/jni/android/graphics/PathMeasure.cpp b/core/jni/android/graphics/PathMeasure.cpp index 51a3f3a..8478a02 100644 --- a/core/jni/android/graphics/PathMeasure.cpp +++ b/core/jni/android/graphics/PathMeasure.cpp @@ -52,11 +52,24 @@ namespace android { class SkPathMeasureGlue { public: - static PathMeasurePair* create(JNIEnv* env, jobject clazz, const SkPath* path, jboolean forceClosed) { - return path ? new PathMeasurePair(*path, forceClosed) : new PathMeasurePair; + static jlong create(JNIEnv* env, jobject clazz, jlong pathHandle, + jboolean forceClosedHandle) { + const SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + bool forceClosed = (forceClosedHandle == JNI_TRUE); + PathMeasurePair* pair; + if(path) + pair = new PathMeasurePair(*path, forceClosed); + else + pair = new PathMeasurePair; + return reinterpret_cast<jlong>(pair); } - - static void setPath(JNIEnv* env, jobject clazz, PathMeasurePair* pair, const SkPath* path, jboolean forceClosed) { + + static void setPath(JNIEnv* env, jobject clazz, jlong pairHandle, + jlong pathHandle, jboolean forceClosedHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + const SkPath* path = reinterpret_cast<SkPath*>(pathHandle); + bool forceClosed = (forceClosedHandle == JNI_TRUE); + if (NULL == path) { pair->fPath.reset(); } else { @@ -64,11 +77,12 @@ public: } pair->fMeasure.setPath(&pair->fPath, forceClosed); } - - static jfloat getLength(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { - return SkScalarToFloat(pair->fMeasure.getLength()); + + static jfloat getLength(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + return static_cast<jfloat>(SkScalarToFloat(pair->fMeasure.getLength())); } - + static void convertTwoElemFloatArray(JNIEnv* env, jfloatArray array, const SkScalar src[2]) { AutoJavaFloatArray autoArray(env, array, 2); jfloat* ptr = autoArray.ptr(); @@ -76,13 +90,14 @@ public: ptr[1] = SkScalarToFloat(src[1]); } - static jboolean getPosTan(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat dist, jfloatArray pos, jfloatArray tan) { + static jboolean getPosTan(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat dist, jfloatArray pos, jfloatArray tan) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); SkScalar tmpPos[2], tmpTan[2]; SkScalar* posPtr = pos ? tmpPos : NULL; SkScalar* tanPtr = tan ? tmpTan : NULL; if (!pair->fMeasure.getPosTan(SkFloatToScalar(dist), (SkPoint*)posPtr, (SkVector*)tanPtr)) { - return false; + return JNI_FALSE; } if (pos) { @@ -91,42 +106,53 @@ public: if (tan) { convertTwoElemFloatArray(env, tan, tmpTan); } - return true; + return JNI_TRUE; } - - static jboolean getMatrix(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat dist, - SkMatrix* matrix, int flags) { - return pair->fMeasure.getMatrix(SkFloatToScalar(dist), matrix, (SkPathMeasure::MatrixFlags)flags); + + static jboolean getMatrix(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat dist, + jlong matrixHandle, jint flags) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); + bool result = pair->fMeasure.getMatrix(SkFloatToScalar(dist), matrix, (SkPathMeasure::MatrixFlags)flags); + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean getSegment(JNIEnv* env, jobject clazz, PathMeasurePair* pair, jfloat startF, - jfloat stopF, SkPath* dst, jboolean startWithMoveTo) { - return pair->fMeasure.getSegment(SkFloatToScalar(startF), SkFloatToScalar(stopF), dst, startWithMoveTo); + + static jboolean getSegment(JNIEnv* env, jobject clazz, jlong pairHandle, jfloat startF, + jfloat stopF, jlong dstHandle, jboolean startWithMoveTo) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + SkPath* dst = reinterpret_cast<SkPath*>(dstHandle); + bool result = pair->fMeasure.getSegment(SkFloatToScalar(startF), SkFloatToScalar(stopF), dst, startWithMoveTo); + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean isClosed(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { - return pair->fMeasure.isClosed(); + + static jboolean isClosed(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + bool result = pair->fMeasure.isClosed(); + return result ? JNI_TRUE : JNI_FALSE; } - - static jboolean nextContour(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { - return pair->fMeasure.nextContour(); + + static jboolean nextContour(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); + bool result = pair->fMeasure.nextContour(); + return result ? JNI_TRUE : JNI_FALSE; } - - static void destroy(JNIEnv* env, jobject clazz, PathMeasurePair* pair) { + + static void destroy(JNIEnv* env, jobject clazz, jlong pairHandle) { + PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle); delete pair; } }; static JNINativeMethod methods[] = { - {"native_create", "(IZ)I", (void*) SkPathMeasureGlue::create }, - {"native_setPath", "(IIZ)V", (void*) SkPathMeasureGlue::setPath }, - {"native_getLength", "(I)F", (void*) SkPathMeasureGlue::getLength }, - {"native_getPosTan", "(IF[F[F)Z", (void*) SkPathMeasureGlue::getPosTan }, - {"native_getMatrix", "(IFII)Z", (void*) SkPathMeasureGlue::getMatrix }, - {"native_getSegment", "(IFFIZ)Z", (void*) SkPathMeasureGlue::getSegment }, - {"native_isClosed", "(I)Z", (void*) SkPathMeasureGlue::isClosed }, - {"native_nextContour", "(I)Z", (void*) SkPathMeasureGlue::nextContour }, - {"native_destroy", "(I)V", (void*) SkPathMeasureGlue::destroy } + {"native_create", "(JZ)J", (void*) SkPathMeasureGlue::create }, + {"native_setPath", "(JJZ)V", (void*) SkPathMeasureGlue::setPath }, + {"native_getLength", "(J)F", (void*) SkPathMeasureGlue::getLength }, + {"native_getPosTan", "(JF[F[F)Z", (void*) SkPathMeasureGlue::getPosTan }, + {"native_getMatrix", "(JFJI)Z", (void*) SkPathMeasureGlue::getMatrix }, + {"native_getSegment", "(JFFJZ)Z", (void*) SkPathMeasureGlue::getSegment }, + {"native_isClosed", "(J)Z", (void*) SkPathMeasureGlue::isClosed }, + {"native_nextContour", "(J)Z", (void*) SkPathMeasureGlue::nextContour }, + {"native_destroy", "(J)V", (void*) SkPathMeasureGlue::destroy } }; int register_android_graphics_PathMeasure(JNIEnv* env) { |