summaryrefslogtreecommitdiff
path: root/opengl
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2019-03-26 16:28:41 -0400
committerLeon Scroggins III <scroggo@google.com>2019-03-27 13:39:23 -0400
commit71fae62f5fe03e9f8453ac3880587567ffcf9be6 (patch)
tree2d6c009c2e34eaebd050506048406dd1876a9f02 /opengl
parentca8aef63766b3193464b8f9b4cde45324a83789a (diff)
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
Diffstat (limited to 'opengl')
-rw-r--r--opengl/java/android/opengl/GLUtils.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/opengl/java/android/opengl/GLUtils.java b/opengl/java/android/opengl/GLUtils.java
index d0973359058a..ca8d5ac52021 100644
--- a/opengl/java/android/opengl/GLUtils.java
+++ b/opengl/java/android/opengl/GLUtils.java
@@ -44,7 +44,7 @@ public final class GLUtils {
if (bitmap.isRecycled()) {
throw new IllegalArgumentException("bitmap is recycled");
}
- int result = native_getInternalFormat(bitmap);
+ int result = native_getInternalFormat(bitmap.getNativeInstance());
if (result < 0) {
throw new IllegalArgumentException("Unknown internalformat");
}
@@ -66,7 +66,7 @@ public final class GLUtils {
if (bitmap.isRecycled()) {
throw new IllegalArgumentException("bitmap is recycled");
}
- int result = native_getType(bitmap);
+ int result = native_getType(bitmap.getNativeInstance());
if (result < 0) {
throw new IllegalArgumentException("Unknown type");
}
@@ -103,7 +103,8 @@ public final class GLUtils {
if (bitmap.isRecycled()) {
throw new IllegalArgumentException("bitmap is recycled");
}
- if (native_texImage2D(target, level, internalformat, bitmap, -1, border)!=0) {
+ if (native_texImage2D(target, level, internalformat, bitmap.getNativeInstance(), -1,
+ border) != 0) {
throw new IllegalArgumentException("invalid Bitmap format");
}
}
@@ -129,7 +130,8 @@ public final class GLUtils {
if (bitmap.isRecycled()) {
throw new IllegalArgumentException("bitmap is recycled");
}
- if (native_texImage2D(target, level, internalformat, bitmap, type, border)!=0) {
+ if (native_texImage2D(target, level, internalformat, bitmap.getNativeInstance(), type,
+ border) != 0) {
throw new IllegalArgumentException("invalid Bitmap format");
}
}
@@ -151,7 +153,7 @@ public final class GLUtils {
if (bitmap.isRecycled()) {
throw new IllegalArgumentException("bitmap is recycled");
}
- if (native_texImage2D(target, level, -1, bitmap, -1, border)!=0) {
+ if (native_texImage2D(target, level, -1, bitmap.getNativeInstance(), -1, border) != 0) {
throw new IllegalArgumentException("invalid Bitmap format");
}
}
@@ -187,7 +189,8 @@ public final class GLUtils {
throw new IllegalArgumentException("bitmap is recycled");
}
int type = getType(bitmap);
- if (native_texSubImage2D(target, level, xoffset, yoffset, bitmap, -1, type)!=0) {
+ if (native_texSubImage2D(target, level, xoffset, yoffset, bitmap.getNativeInstance(), -1,
+ type) != 0) {
throw new IllegalArgumentException("invalid Bitmap format");
}
}
@@ -211,7 +214,8 @@ public final class GLUtils {
if (bitmap.isRecycled()) {
throw new IllegalArgumentException("bitmap is recycled");
}
- if (native_texSubImage2D(target, level, xoffset, yoffset, bitmap, format, type)!=0) {
+ if (native_texSubImage2D(target, level, xoffset, yoffset, bitmap.getNativeInstance(),
+ format, type) != 0) {
throw new IllegalArgumentException("invalid Bitmap format");
}
}
@@ -261,10 +265,10 @@ public final class GLUtils {
}
}
- native private static int native_getInternalFormat(Bitmap bitmap);
- native private static int native_getType(Bitmap bitmap);
+ native private static int native_getInternalFormat(long bitmapHandle);
+ native private static int native_getType(long bitmapHandle);
native private static int native_texImage2D(int target, int level, int internalformat,
- Bitmap bitmap, int type, int border);
+ long bitmapHandle, int type, int border);
native private static int native_texSubImage2D(int target, int level, int xoffset, int yoffset,
- Bitmap bitmap, int format, int type);
+ long bitmapHandle, int format, int type);
}