Pass Bitmap's native instance to JNI where feasible
Test: CtsGraphicsTestCases, CtsUiRenderingTestCases,
CtsRenderscriptTestCases
This is significantly faster than passing the Java object down and then
calling a JNI method to retrieve the pointer. See
https://buganizer.corp.google.com/issues/16656908#comment19
In some cases this changes what used to be native crashes (due to
android::BitmapWrapper:assertValid's LOG_ALWAYS_FATAL_IF) into
NullPointerExceptions (if a caller used a null Bitmap).
In addition:
- Remove unnecessary JNIEnv param from toBitmap(jlong)
- Change instances of toBitmap(JNIEnv*, jobject) to the above
- Replace calls to GraphicsJNI::getSkBitmap() to inline calls to
toBitmap/getSkBitmap
- make Canvas#nInitRaster @FastNative (FIXME: Could these be
@CriticalNative?)
Change-Id: I6194097be1b6e6952eba70e1e7052a5a250eed93
This commit is contained in:
@@ -196,6 +196,7 @@ public final class BitmapRegionDecoder {
|
||||
throw new IllegalArgumentException("rectangle is outside the image");
|
||||
return nativeDecodeRegion(mNativeBitmapRegionDecoder, rect.left, rect.top,
|
||||
rect.right - rect.left, rect.bottom - rect.top, options,
|
||||
BitmapFactory.Options.nativeInBitmap(options),
|
||||
BitmapFactory.Options.nativeColorSpace(options));
|
||||
}
|
||||
}
|
||||
@@ -266,7 +267,8 @@ public final class BitmapRegionDecoder {
|
||||
|
||||
private static native Bitmap nativeDecodeRegion(long lbm,
|
||||
int start_x, int start_y, int width, int height,
|
||||
BitmapFactory.Options options, long colorSpaceHandle);
|
||||
BitmapFactory.Options options, long inBitmapHandle,
|
||||
long colorSpaceHandle);
|
||||
private static native int nativeGetWidth(long lbm);
|
||||
private static native int nativeGetHeight(long lbm);
|
||||
private static native void nativeClean(long lbm);
|
||||
|
||||
Reference in New Issue
Block a user