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

Commit 077386db authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am 6b81bfd1: am caea42fd: am 98002dfb: Merge "AArch64: Use long for pointers...

am 6b81bfd1: am caea42fd: am 98002dfb: Merge "AArch64: Use long for pointers in graphics/PathMeasure"

* commit '6b81bfd1':
  AArch64: Use long for pointers in graphics/PathMeasure
parents 213f243f 6b81bfd1
Loading
Loading
Loading
Loading
+62 −36
Original line number Diff line number Diff line
@@ -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, jlong pairHandle,
                        jlong pathHandle, jboolean forceClosedHandle) {
        PathMeasurePair* pair = reinterpret_cast<PathMeasurePair*>(pairHandle);
        const SkPath* path = reinterpret_cast<SkPath*>(pathHandle);
        bool forceClosed = (forceClosedHandle == JNI_TRUE);

    static void setPath(JNIEnv* env, jobject clazz, PathMeasurePair* pair, const SkPath* path, jboolean forceClosed) {
        if (NULL == path) {
            pair->fPath.reset();
        } else {
@@ -65,8 +78,9 @@ 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]) {
@@ -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) {
+10 −10
Original line number Diff line number Diff line
@@ -138,16 +138,16 @@ public class PathMeasure {
        native_destroy(native_instance);
    }

    private static native int native_create(int native_path, boolean forceClosed);
    private static native void native_setPath(int native_instance, int native_path, boolean forceClosed);
    private static native float native_getLength(int native_instance);
    private static native boolean native_getPosTan(int native_instance, float distance, float pos[], float tan[]);
    private static native boolean native_getMatrix(int native_instance, float distance, int native_matrix, int flags);
    private static native boolean native_getSegment(int native_instance, float startD, float stopD, int native_path, boolean startWithMoveTo);
    private static native boolean native_isClosed(int native_instance);
    private static native boolean native_nextContour(int native_instance);
    private static native void native_destroy(int native_instance);

    /* package */private final int native_instance;
    private static native long native_create(long native_path, boolean forceClosed);
    private static native void native_setPath(long native_instance, long native_path, boolean forceClosed);
    private static native float native_getLength(long native_instance);
    private static native boolean native_getPosTan(long native_instance, float distance, float pos[], float tan[]);
    private static native boolean native_getMatrix(long native_instance, float distance, long native_matrix, int flags);
    private static native boolean native_getSegment(long native_instance, float startD, float stopD, long native_path, boolean startWithMoveTo);
    private static native boolean native_isClosed(long native_instance);
    private static native boolean native_nextContour(long native_instance);
    private static native void native_destroy(long native_instance);

    /* package */private final long native_instance;
}