Merge "Move Path to NAR" into pi-dev
am: 9434b66bf7
Change-Id: I693153af6cdd6face8aae7cc1cd6c828fc774b78
This commit is contained in:
@@ -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) {
|
||||
@@ -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) {
|
||||
@@ -469,7 +472,9 @@ public:
|
||||
SkRect rect;
|
||||
SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
|
||||
jboolean result = obj->isRect(&rect);
|
||||
GraphicsJNI::rect_to_jrectf(rect, env, jrect);
|
||||
if (jrect) {
|
||||
GraphicsJNI::rect_to_jrectf(rect, env, jrect);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -52,6 +58,7 @@ public class Path {
|
||||
*/
|
||||
public Path() {
|
||||
mNativePath = nInit();
|
||||
sRegistry.registerNativeAllocation(this, mNativePath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,6 +76,7 @@ public class Path {
|
||||
}
|
||||
}
|
||||
mNativePath = nInit(valNative);
|
||||
sRegistry.registerNativeAllocation(this, mNativePath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user