Loading graphics/java/android/graphics/Bitmap.java +5 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,11 @@ public final class Bitmap implements Parcelable { * how pixels are stored. This affects the quality (color depth) as * well as the ability to display transparent/translucent colors. */ // It's touched by Graphics.cpp, so we need to make this enum usable on Ravenwood. // Otherwise, all the ctors would throw, which would make the class unloadable // because the static initializer needs the enum members because of `sConfigs`. // TODO: Remove it once we expose the outer class. @android.ravenwood.annotation.RavenwoodKeepWholeClass public enum Config { // these native values must match up with the enum in SkBitmap.h Loading graphics/java/android/graphics/Interpolator.java +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ package android.graphics; import android.os.SystemClock; @android.ravenwood.annotation.RavenwoodKeepWholeClass @android.ravenwood.annotation.RavenwoodClassLoadHook( android.ravenwood.annotation.RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK) public class Interpolator { public Interpolator(int valueCount) { Loading graphics/java/android/graphics/Matrix.java +55 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ import java.io.PrintWriter; /** * The Matrix class holds a 3x3 matrix for transforming coordinates. */ @android.ravenwood.annotation.RavenwoodKeepWholeClass @android.ravenwood.annotation.RavenwoodClassLoadHook( android.ravenwood.annotation.RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK) public class Matrix { public static final int MSCALE_X = 0; //!< use with getValues/setValues Loading Loading @@ -229,7 +232,7 @@ public class Matrix { private static class NoImagePreloadHolder { public static final NativeAllocationRegistry sRegistry = NativeAllocationRegistry.createMalloced( Matrix.class.getClassLoader(), nGetNativeFinalizer()); Matrix.class.getClassLoader(), nGetNativeFinalizerWrapper()); } private final long native_instance; Loading @@ -238,7 +241,7 @@ public class Matrix { * Create an identity matrix */ public Matrix() { native_instance = nCreate(0); native_instance = nCreateWrapper(0); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, native_instance); } Loading @@ -248,7 +251,7 @@ public class Matrix { * @param src The matrix to copy into this matrix */ public Matrix(Matrix src) { native_instance = nCreate(src != null ? src.native_instance : 0); native_instance = nCreateWrapper(src != null ? src.native_instance : 0); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, native_instance); } Loading Loading @@ -846,6 +849,34 @@ public class Matrix { return native_instance; } /** * Wrapper method we use to switch to ExtraNatives.nCreate(src) only on Ravenwood. * * @see ExtraNatives */ @android.ravenwood.annotation.RavenwoodReplace private static long nCreateWrapper(long src) { return nCreate(src); } private static long nCreateWrapper$ravenwood(long src) { return ExtraNatives.nCreate(src); } /** * Wrapper method we use to switch to ExtraNatives.nGetNativeFinalizer(src) only on Ravenwood. * * @see ExtraNatives */ @android.ravenwood.annotation.RavenwoodReplace private static long nGetNativeFinalizerWrapper() { return nGetNativeFinalizer(); } private static long nGetNativeFinalizerWrapper$ravenwood() { return ExtraNatives.nGetNativeFinalizer(); } // ------------------ Regular JNI ------------------------ private static native long nCreate(long nSrc_or_zero); Loading Loading @@ -943,4 +974,25 @@ public class Matrix { private static native float nMapRadius(long nObject, float radius); @CriticalNative private static native boolean nEquals(long nA, long nB); /** * Due to b/337329128, native methods that are called by the static initializers cannot be * in the same class when running on a host side JVM (such as on Ravenwood and Android Studio). * * There are two methods that are called by the static initializers (either directly or * indirectly) in this class, namely nCreate() and nGetNativeFinalizer(). On Ravenwood * these methods can't be on the Matrix class itself, so we use a nested class to host them. * * We still keep the original nCreate() method and call it on non-ravenwood environment, * in order to avoid problems in downstream (such as Android Studio). * * @see #nCreateWrapper(long) * @see #nGetNativeFinalizerWrapper() * * TODO(b/337110712) Clean it up somehow. (remove the original nCreate() and unify the code?) */ private static class ExtraNatives { static native long nCreate(long nSrc_or_zero); static native long nGetNativeFinalizer(); } } graphics/java/android/graphics/Path.java +11 −6 Original line number Diff line number Diff line Loading @@ -36,11 +36,16 @@ import libcore.util.NativeAllocationRegistry; * (based on the paint's Style), or it can be used for clipping or to draw * text on a path. */ @android.ravenwood.annotation.RavenwoodKeepWholeClass @android.ravenwood.annotation.RavenwoodClassLoadHook( android.ravenwood.annotation.RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK) public class Path { private static final NativeAllocationRegistry sRegistry = // See b/337329128 for why we need an inner class here. private static class NoImagePreloadHolder { static final NativeAllocationRegistry sRegistry = NativeAllocationRegistry.createMalloced( Path.class.getClassLoader(), nGetFinalizer()); } /** * @hide Loading @@ -52,7 +57,7 @@ public class Path { */ public Path() { mNativePath = nInit(); sRegistry.registerNativeAllocation(this, mNativePath); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading @@ -62,7 +67,7 @@ public class Path { */ public Path(@Nullable Path src) { mNativePath = nInit(src != null ? src.mNativePath : 0); sRegistry.registerNativeAllocation(this, mNativePath); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading libs/hwui/jni/Graphics.cpp +1 −12 Original line number Diff line number Diff line Loading @@ -212,10 +212,6 @@ static jfieldID gRegion_nativeInstanceID; static jmethodID gRegion_constructorMethodID; static jclass gByte_class; static jobject gVMRuntime; static jclass gVMRuntime_class; static jmethodID gVMRuntime_newNonMovableArray; static jmethodID gVMRuntime_addressOf; static jclass gColorSpace_class; static jmethodID gColorSpace_getMethodID; Loading Loading @@ -789,13 +785,6 @@ int register_android_graphics_Graphics(JNIEnv* env) gByte_class = (jclass) env->NewGlobalRef( env->GetStaticObjectField(c, env->GetStaticFieldID(c, "TYPE", "Ljava/lang/Class;"))); gVMRuntime_class = MakeGlobalRefOrDie(env, FindClassOrDie(env, "dalvik/system/VMRuntime")); m = env->GetStaticMethodID(gVMRuntime_class, "getRuntime", "()Ldalvik/system/VMRuntime;"); gVMRuntime = env->NewGlobalRef(env->CallStaticObjectMethod(gVMRuntime_class, m)); gVMRuntime_newNonMovableArray = GetMethodIDOrDie(env, gVMRuntime_class, "newNonMovableArray", "(Ljava/lang/Class;I)Ljava/lang/Object;"); gVMRuntime_addressOf = GetMethodIDOrDie(env, gVMRuntime_class, "addressOf", "(Ljava/lang/Object;)J"); gColorSpace_class = MakeGlobalRefOrDie(env, FindClassOrDie(env, "android/graphics/ColorSpace")); gColorSpace_getMethodID = GetStaticMethodIDOrDie(env, gColorSpace_class, "get", "(Landroid/graphics/ColorSpace$Named;)Landroid/graphics/ColorSpace;"); Loading Loading
graphics/java/android/graphics/Bitmap.java +5 −0 Original line number Diff line number Diff line Loading @@ -465,6 +465,11 @@ public final class Bitmap implements Parcelable { * how pixels are stored. This affects the quality (color depth) as * well as the ability to display transparent/translucent colors. */ // It's touched by Graphics.cpp, so we need to make this enum usable on Ravenwood. // Otherwise, all the ctors would throw, which would make the class unloadable // because the static initializer needs the enum members because of `sConfigs`. // TODO: Remove it once we expose the outer class. @android.ravenwood.annotation.RavenwoodKeepWholeClass public enum Config { // these native values must match up with the enum in SkBitmap.h Loading
graphics/java/android/graphics/Interpolator.java +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,9 @@ package android.graphics; import android.os.SystemClock; @android.ravenwood.annotation.RavenwoodKeepWholeClass @android.ravenwood.annotation.RavenwoodClassLoadHook( android.ravenwood.annotation.RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK) public class Interpolator { public Interpolator(int valueCount) { Loading
graphics/java/android/graphics/Matrix.java +55 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ import java.io.PrintWriter; /** * The Matrix class holds a 3x3 matrix for transforming coordinates. */ @android.ravenwood.annotation.RavenwoodKeepWholeClass @android.ravenwood.annotation.RavenwoodClassLoadHook( android.ravenwood.annotation.RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK) public class Matrix { public static final int MSCALE_X = 0; //!< use with getValues/setValues Loading Loading @@ -229,7 +232,7 @@ public class Matrix { private static class NoImagePreloadHolder { public static final NativeAllocationRegistry sRegistry = NativeAllocationRegistry.createMalloced( Matrix.class.getClassLoader(), nGetNativeFinalizer()); Matrix.class.getClassLoader(), nGetNativeFinalizerWrapper()); } private final long native_instance; Loading @@ -238,7 +241,7 @@ public class Matrix { * Create an identity matrix */ public Matrix() { native_instance = nCreate(0); native_instance = nCreateWrapper(0); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, native_instance); } Loading @@ -248,7 +251,7 @@ public class Matrix { * @param src The matrix to copy into this matrix */ public Matrix(Matrix src) { native_instance = nCreate(src != null ? src.native_instance : 0); native_instance = nCreateWrapper(src != null ? src.native_instance : 0); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, native_instance); } Loading Loading @@ -846,6 +849,34 @@ public class Matrix { return native_instance; } /** * Wrapper method we use to switch to ExtraNatives.nCreate(src) only on Ravenwood. * * @see ExtraNatives */ @android.ravenwood.annotation.RavenwoodReplace private static long nCreateWrapper(long src) { return nCreate(src); } private static long nCreateWrapper$ravenwood(long src) { return ExtraNatives.nCreate(src); } /** * Wrapper method we use to switch to ExtraNatives.nGetNativeFinalizer(src) only on Ravenwood. * * @see ExtraNatives */ @android.ravenwood.annotation.RavenwoodReplace private static long nGetNativeFinalizerWrapper() { return nGetNativeFinalizer(); } private static long nGetNativeFinalizerWrapper$ravenwood() { return ExtraNatives.nGetNativeFinalizer(); } // ------------------ Regular JNI ------------------------ private static native long nCreate(long nSrc_or_zero); Loading Loading @@ -943,4 +974,25 @@ public class Matrix { private static native float nMapRadius(long nObject, float radius); @CriticalNative private static native boolean nEquals(long nA, long nB); /** * Due to b/337329128, native methods that are called by the static initializers cannot be * in the same class when running on a host side JVM (such as on Ravenwood and Android Studio). * * There are two methods that are called by the static initializers (either directly or * indirectly) in this class, namely nCreate() and nGetNativeFinalizer(). On Ravenwood * these methods can't be on the Matrix class itself, so we use a nested class to host them. * * We still keep the original nCreate() method and call it on non-ravenwood environment, * in order to avoid problems in downstream (such as Android Studio). * * @see #nCreateWrapper(long) * @see #nGetNativeFinalizerWrapper() * * TODO(b/337110712) Clean it up somehow. (remove the original nCreate() and unify the code?) */ private static class ExtraNatives { static native long nCreate(long nSrc_or_zero); static native long nGetNativeFinalizer(); } }
graphics/java/android/graphics/Path.java +11 −6 Original line number Diff line number Diff line Loading @@ -36,11 +36,16 @@ import libcore.util.NativeAllocationRegistry; * (based on the paint's Style), or it can be used for clipping or to draw * text on a path. */ @android.ravenwood.annotation.RavenwoodKeepWholeClass @android.ravenwood.annotation.RavenwoodClassLoadHook( android.ravenwood.annotation.RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK) public class Path { private static final NativeAllocationRegistry sRegistry = // See b/337329128 for why we need an inner class here. private static class NoImagePreloadHolder { static final NativeAllocationRegistry sRegistry = NativeAllocationRegistry.createMalloced( Path.class.getClassLoader(), nGetFinalizer()); } /** * @hide Loading @@ -52,7 +57,7 @@ public class Path { */ public Path() { mNativePath = nInit(); sRegistry.registerNativeAllocation(this, mNativePath); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading @@ -62,7 +67,7 @@ public class Path { */ public Path(@Nullable Path src) { mNativePath = nInit(src != null ? src.mNativePath : 0); sRegistry.registerNativeAllocation(this, mNativePath); NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativePath); } /** Loading
libs/hwui/jni/Graphics.cpp +1 −12 Original line number Diff line number Diff line Loading @@ -212,10 +212,6 @@ static jfieldID gRegion_nativeInstanceID; static jmethodID gRegion_constructorMethodID; static jclass gByte_class; static jobject gVMRuntime; static jclass gVMRuntime_class; static jmethodID gVMRuntime_newNonMovableArray; static jmethodID gVMRuntime_addressOf; static jclass gColorSpace_class; static jmethodID gColorSpace_getMethodID; Loading Loading @@ -789,13 +785,6 @@ int register_android_graphics_Graphics(JNIEnv* env) gByte_class = (jclass) env->NewGlobalRef( env->GetStaticObjectField(c, env->GetStaticFieldID(c, "TYPE", "Ljava/lang/Class;"))); gVMRuntime_class = MakeGlobalRefOrDie(env, FindClassOrDie(env, "dalvik/system/VMRuntime")); m = env->GetStaticMethodID(gVMRuntime_class, "getRuntime", "()Ldalvik/system/VMRuntime;"); gVMRuntime = env->NewGlobalRef(env->CallStaticObjectMethod(gVMRuntime_class, m)); gVMRuntime_newNonMovableArray = GetMethodIDOrDie(env, gVMRuntime_class, "newNonMovableArray", "(Ljava/lang/Class;I)Ljava/lang/Object;"); gVMRuntime_addressOf = GetMethodIDOrDie(env, gVMRuntime_class, "addressOf", "(Ljava/lang/Object;)J"); gColorSpace_class = MakeGlobalRefOrDie(env, FindClassOrDie(env, "android/graphics/ColorSpace")); gColorSpace_getMethodID = GetStaticMethodIDOrDie(env, gColorSpace_class, "get", "(Landroid/graphics/ColorSpace$Named;)Landroid/graphics/ColorSpace;"); Loading