Loading core/jni/android/graphics/Path.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -37,6 +37,14 @@ namespace android { class SkPathGlue { public: static void finalizer(SkPath* obj) { // Purge entries from the HWUI path cache if this path's data is unique if (obj->unique() && android::uirenderer::Caches::hasInstance()) { android::uirenderer::Caches::getInstance().pathCache.removeDeferred(obj); } delete obj; } // ---------------- Regular JNI ----------------------------- static jlong init(JNIEnv* env, jclass clazz) { Loading @@ -48,13 +56,8 @@ public: return reinterpret_cast<jlong>(new SkPath(*val)); } static void finalize(JNIEnv* env, jclass clazz, jlong objHandle) { SkPath* obj = reinterpret_cast<SkPath*>(objHandle); // Purge entries from the HWUI path cache if this path's data is unique if (obj->unique() && android::uirenderer::Caches::hasInstance()) { android::uirenderer::Caches::getInstance().pathCache.removeDeferred(obj); } delete obj; static jlong getFinalizer(JNIEnv* env, jclass clazz) { return static_cast<jlong>(reinterpret_cast<uintptr_t>(&finalizer)); } static void set(JNIEnv* env, jclass clazz, jlong dstHandle, jlong srcHandle) { Loading Loading @@ -469,7 +472,9 @@ public: SkRect rect; SkPath* obj = reinterpret_cast<SkPath*>(objHandle); jboolean result = obj->isRect(&rect); if (jrect) { GraphicsJNI::rect_to_jrectf(rect, env, jrect); } return result; } Loading Loading @@ -510,7 +515,7 @@ public: static const JNINativeMethod methods[] = { {"nInit","()J", (void*) SkPathGlue::init}, {"nInit","(J)J", (void*) SkPathGlue::init_Path}, {"nFinalize", "(J)V", (void*) SkPathGlue::finalize}, {"nGetFinalizer", "()J", (void*) SkPathGlue::getFinalizer}, {"nSet","(JJ)V", (void*) SkPathGlue::set}, {"nComputeBounds","(JLandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds}, {"nIncReserve","(JI)V", (void*) SkPathGlue::incReserve}, Loading graphics/java/android/graphics/Path.java +11 −12 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.annotation.Size; import dalvik.annotation.optimization.CriticalNative; import dalvik.annotation.optimization.FastNative; import libcore.util.NativeAllocationRegistry; /** * The Path class encapsulates compound (multiple contour) geometric paths * consisting of straight line segments, quadratic curves, and cubic curves. Loading @@ -32,10 +34,14 @@ import dalvik.annotation.optimization.FastNative; * text on a path. */ public class Path { private static final NativeAllocationRegistry sRegistry = new NativeAllocationRegistry( Path.class.getClassLoader(), nGetFinalizer(), 48 /* dummy size */); /** * @hide */ public long mNativePath; public final long mNativePath; /** * @hide Loading @@ -52,6 +58,7 @@ public class Path { */ public Path() { mNativePath = nInit(); sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading @@ -69,6 +76,7 @@ public class Path { } } mNativePath = nInit(valNative); sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading Loading @@ -297,7 +305,7 @@ public class Path { * a rectangle * @return true if the path specifies a rectangle */ public boolean isRect(RectF rect) { public boolean isRect(@Nullable RectF rect) { return nIsRect(mNativePath, rect); } Loading Loading @@ -771,15 +779,6 @@ public class Path { nTransform(mNativePath, matrix.native_instance); } protected void finalize() throws Throwable { try { nFinalize(mNativePath); mNativePath = 0; // Other finalizers can still call us. } finally { super.finalize(); } } /** @hide */ public final long readOnlyNI() { return mNativePath; Loading Loading @@ -820,7 +819,7 @@ public class Path { private static native long nInit(); private static native long nInit(long nPath); private static native void nFinalize(long nPath); private static native long nGetFinalizer(); private static native void nSet(long native_dst, long nSrc); private static native void nComputeBounds(long nPath, RectF bounds); private static native void nIncReserve(long nPath, int extraPtCount); Loading Loading
core/jni/android/graphics/Path.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -37,6 +37,14 @@ namespace android { class SkPathGlue { public: static void finalizer(SkPath* obj) { // Purge entries from the HWUI path cache if this path's data is unique if (obj->unique() && android::uirenderer::Caches::hasInstance()) { android::uirenderer::Caches::getInstance().pathCache.removeDeferred(obj); } delete obj; } // ---------------- Regular JNI ----------------------------- static jlong init(JNIEnv* env, jclass clazz) { Loading @@ -48,13 +56,8 @@ public: return reinterpret_cast<jlong>(new SkPath(*val)); } static void finalize(JNIEnv* env, jclass clazz, jlong objHandle) { SkPath* obj = reinterpret_cast<SkPath*>(objHandle); // Purge entries from the HWUI path cache if this path's data is unique if (obj->unique() && android::uirenderer::Caches::hasInstance()) { android::uirenderer::Caches::getInstance().pathCache.removeDeferred(obj); } delete obj; static jlong getFinalizer(JNIEnv* env, jclass clazz) { return static_cast<jlong>(reinterpret_cast<uintptr_t>(&finalizer)); } static void set(JNIEnv* env, jclass clazz, jlong dstHandle, jlong srcHandle) { Loading Loading @@ -469,7 +472,9 @@ public: SkRect rect; SkPath* obj = reinterpret_cast<SkPath*>(objHandle); jboolean result = obj->isRect(&rect); if (jrect) { GraphicsJNI::rect_to_jrectf(rect, env, jrect); } return result; } Loading Loading @@ -510,7 +515,7 @@ public: static const JNINativeMethod methods[] = { {"nInit","()J", (void*) SkPathGlue::init}, {"nInit","(J)J", (void*) SkPathGlue::init_Path}, {"nFinalize", "(J)V", (void*) SkPathGlue::finalize}, {"nGetFinalizer", "()J", (void*) SkPathGlue::getFinalizer}, {"nSet","(JJ)V", (void*) SkPathGlue::set}, {"nComputeBounds","(JLandroid/graphics/RectF;)V", (void*) SkPathGlue::computeBounds}, {"nIncReserve","(JI)V", (void*) SkPathGlue::incReserve}, Loading
graphics/java/android/graphics/Path.java +11 −12 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.annotation.Size; import dalvik.annotation.optimization.CriticalNative; import dalvik.annotation.optimization.FastNative; import libcore.util.NativeAllocationRegistry; /** * The Path class encapsulates compound (multiple contour) geometric paths * consisting of straight line segments, quadratic curves, and cubic curves. Loading @@ -32,10 +34,14 @@ import dalvik.annotation.optimization.FastNative; * text on a path. */ public class Path { private static final NativeAllocationRegistry sRegistry = new NativeAllocationRegistry( Path.class.getClassLoader(), nGetFinalizer(), 48 /* dummy size */); /** * @hide */ public long mNativePath; public final long mNativePath; /** * @hide Loading @@ -52,6 +58,7 @@ public class Path { */ public Path() { mNativePath = nInit(); sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading @@ -69,6 +76,7 @@ public class Path { } } mNativePath = nInit(valNative); sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading Loading @@ -297,7 +305,7 @@ public class Path { * a rectangle * @return true if the path specifies a rectangle */ public boolean isRect(RectF rect) { public boolean isRect(@Nullable RectF rect) { return nIsRect(mNativePath, rect); } Loading Loading @@ -771,15 +779,6 @@ public class Path { nTransform(mNativePath, matrix.native_instance); } protected void finalize() throws Throwable { try { nFinalize(mNativePath); mNativePath = 0; // Other finalizers can still call us. } finally { super.finalize(); } } /** @hide */ public final long readOnlyNI() { return mNativePath; Loading Loading @@ -820,7 +819,7 @@ public class Path { private static native long nInit(); private static native long nInit(long nPath); private static native void nFinalize(long nPath); private static native long nGetFinalizer(); private static native void nSet(long native_dst, long nSrc); private static native void nComputeBounds(long nPath, RectF bounds); private static native void nIncReserve(long nPath, int extraPtCount); Loading