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:
Leon Scroggins III
2019-03-26 16:28:41 -04:00
parent ca8aef6376
commit 71fae62f5f
22 changed files with 198 additions and 159 deletions

View File

@@ -62,9 +62,9 @@ public class BitmapShader extends Shader {
@Override
long createNativeInstance(long nativeMatrix) {
return nativeCreate(nativeMatrix, mBitmap, mTileX, mTileY);
return nativeCreate(nativeMatrix, mBitmap.getNativeInstance(), mTileX, mTileY);
}
private static native long nativeCreate(long nativeMatrix, Bitmap bitmap,
private static native long nativeCreate(long nativeMatrix, long bitmapHandle,
int shaderTileModeX, int shaderTileModeY);
}