am 8796ab7f: am bb35356d: Merge changes Id54087dd,I946325e4,I2a2b2e68
* commit '8796ab7f22d3e9f5b85571e8851851c023416f96':
AArch64: Use long for pointers in BitmapRegionDecoder
AArch64: Use long for pointers in Movie class
AArch64: Add AssetInputStream.getNativeAsset
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index fc9e486..48211b5 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -540,6 +540,12 @@
public final int getAssetInt() {
return mAsset;
}
+ /**
+ * @hide
+ */
+ public final long getNativeAsset() {
+ return mAsset;
+ }
private AssetInputStream(int asset)
{
mAsset = asset;
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index ee47ac4..e7d2422 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -102,7 +102,7 @@
}
static jobject nativeNewInstanceFromByteArray(JNIEnv* env, jobject, jbyteArray byteArray,
- int offset, int length, jboolean isShareable) {
+ jint offset, jint length, jboolean isShareable) {
/* If isShareable we could decide to just wrap the java array and
share it, but that means adding a globalref to the java array object
For now we just always copy the array's data if isShareable.
@@ -151,7 +151,7 @@
}
static jobject nativeNewInstanceFromAsset(JNIEnv* env, jobject clazz,
- jint native_asset, // Asset
+ jlong native_asset, // Asset
jboolean isShareable) {
Asset* asset = reinterpret_cast<Asset*>(native_asset);
SkAutoTUnref<SkMemoryStream> stream(CopyAssetToStream(asset));
@@ -170,8 +170,9 @@
* purgeable not supported
* reportSizeToVM not supported
*/
-static jobject nativeDecodeRegion(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd,
- int start_x, int start_y, int width, int height, jobject options) {
+static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle,
+ jint start_x, jint start_y, jint width, jint height, jobject options) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
jobject tileBitmap = NULL;
SkImageDecoder *decoder = brd->getDecoder();
int sampleSize = 1;
@@ -256,15 +257,18 @@
return GraphicsJNI::createBitmap(env, bitmap, buff, bitmapCreateFlags, NULL, NULL, -1);
}
-static int nativeGetHeight(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
- return brd->getHeight();
+static jint nativeGetHeight(JNIEnv* env, jobject, jlong brdHandle) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
+ return static_cast<jint>(brd->getHeight());
}
-static int nativeGetWidth(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
- return brd->getWidth();
+static jint nativeGetWidth(JNIEnv* env, jobject, jlong brdHandle) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
+ return static_cast<jint>(brd->getWidth());
}
-static void nativeClean(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
+static void nativeClean(JNIEnv* env, jobject, jlong brdHandle) {
+ SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
delete brd;
}
@@ -274,14 +278,14 @@
static JNINativeMethod gBitmapRegionDecoderMethods[] = {
{ "nativeDecodeRegion",
- "(IIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
+ "(JIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
(void*)nativeDecodeRegion},
- { "nativeGetHeight", "(I)I", (void*)nativeGetHeight},
+ { "nativeGetHeight", "(J)I", (void*)nativeGetHeight},
- { "nativeGetWidth", "(I)I", (void*)nativeGetWidth},
+ { "nativeGetWidth", "(J)I", (void*)nativeGetWidth},
- { "nativeClean", "(I)V", (void*)nativeClean},
+ { "nativeClean", "(J)V", (void*)nativeClean},
{ "nativeNewInstance",
"([BIIZ)Landroid/graphics/BitmapRegionDecoder;",
@@ -299,7 +303,7 @@
},
{ "nativeNewInstance",
- "(IZ)Landroid/graphics/BitmapRegionDecoder;",
+ "(JZ)Landroid/graphics/BitmapRegionDecoder;",
(void*)nativeNewInstanceFromAsset
},
};
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 38a9ba3..a10e1586 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -392,7 +392,7 @@
jobject obj = env->NewObject(gBitmapRegionDecoder_class,
gBitmapRegionDecoder_constructorMethodID,
- static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)));
+ reinterpret_cast<jlong>(bitmap));
hasException(env); // For the side effect of logging.
return obj;
}
@@ -651,7 +651,7 @@
gBitmap_reinitMethodID = env->GetMethodID(gBitmap_class, "reinit", "(IIZ)V");
gBitmap_getAllocationByteCountMethodID = env->GetMethodID(gBitmap_class, "getAllocationByteCount", "()I");
gBitmapRegionDecoder_class = make_globalref(env, "android/graphics/BitmapRegionDecoder");
- gBitmapRegionDecoder_constructorMethodID = env->GetMethodID(gBitmapRegionDecoder_class, "<init>", "(I)V");
+ gBitmapRegionDecoder_constructorMethodID = env->GetMethodID(gBitmapRegionDecoder_class, "<init>", "(J)V");
gBitmapConfig_class = make_globalref(env, "android/graphics/Bitmap$Config");
gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class,
diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp
index feb2dec..0040b6f 100644
--- a/core/jni/android/graphics/Movie.cpp
+++ b/core/jni/android/graphics/Movie.cpp
@@ -27,43 +27,43 @@
return NULL;
}
return env->NewObject(gMovie_class, gMovie_constructorMethodID,
- static_cast<jint>(reinterpret_cast<uintptr_t>(moov)));
+ static_cast<jlong>(reinterpret_cast<uintptr_t>(moov)));
}
static SkMovie* J2Movie(JNIEnv* env, jobject movie) {
SkASSERT(env);
SkASSERT(movie);
SkASSERT(env->IsInstanceOf(movie, gMovie_class));
- SkMovie* m = (SkMovie*)env->GetIntField(movie, gMovie_nativeInstanceID);
+ SkMovie* m = (SkMovie*)env->GetLongField(movie, gMovie_nativeInstanceID);
SkASSERT(m);
return m;
}
///////////////////////////////////////////////////////////////////////////////
-static int movie_width(JNIEnv* env, jobject movie) {
+static jint movie_width(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->width();
+ return static_cast<jint>(J2Movie(env, movie)->width());
}
-static int movie_height(JNIEnv* env, jobject movie) {
+static jint movie_height(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->height();
+ return static_cast<jint>(J2Movie(env, movie)->height());
}
static jboolean movie_isOpaque(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->isOpaque();
+ return J2Movie(env, movie)->isOpaque() ? JNI_TRUE : JNI_FALSE;
}
-static int movie_duration(JNIEnv* env, jobject movie) {
+static jint movie_duration(JNIEnv* env, jobject movie) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->duration();
+ return static_cast<jint>(J2Movie(env, movie)->duration());
}
-static jboolean movie_setTime(JNIEnv* env, jobject movie, int ms) {
+static jboolean movie_setTime(JNIEnv* env, jobject movie, jint ms) {
NPE_CHECK_RETURN_ZERO(env, movie);
- return J2Movie(env, movie)->setTime(ms);
+ return J2Movie(env, movie)->setTime(ms) ? JNI_TRUE : JNI_FALSE;
}
static void movie_draw(JNIEnv* env, jobject movie, jobject canvas,
@@ -82,7 +82,7 @@
c->drawBitmap(b, sx, sy, p);
}
-static jobject movie_decodeAsset(JNIEnv* env, jobject clazz, jint native_asset) {
+static jobject movie_decodeAsset(JNIEnv* env, jobject clazz, jlong native_asset) {
android::Asset* asset = reinterpret_cast<android::Asset*>(native_asset);
if (asset == NULL) return NULL;
SkAutoTUnref<SkStreamRewindable> stream (new android::AssetStreamAdaptor(asset));
@@ -115,7 +115,7 @@
static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz,
jbyteArray byteArray,
- int offset, int length) {
+ jint offset, jint length) {
NPE_CHECK_RETURN_ZERO(env, byteArray);
@@ -130,7 +130,8 @@
return create_jmovie(env, moov);
}
-static void movie_destructor(JNIEnv* env, jobject, SkMovie* movie) {
+static void movie_destructor(JNIEnv* env, jobject, jlong movieHandle) {
+ SkMovie* movie = (SkMovie*) movieHandle;
delete movie;
}
@@ -146,11 +147,11 @@
{ "setTime", "(I)Z", (void*)movie_setTime },
{ "draw", "(Landroid/graphics/Canvas;FFLandroid/graphics/Paint;)V",
(void*)movie_draw },
- { "nativeDecodeAsset", "(I)Landroid/graphics/Movie;",
+ { "nativeDecodeAsset", "(J)Landroid/graphics/Movie;",
(void*)movie_decodeAsset },
{ "nativeDecodeStream", "(Ljava/io/InputStream;)Landroid/graphics/Movie;",
(void*)movie_decodeStream },
- { "nativeDestructor","(I)V", (void*)movie_destructor },
+ { "nativeDestructor","(J)V", (void*)movie_destructor },
{ "decodeByteArray", "([BII)Landroid/graphics/Movie;",
(void*)movie_decodeByteArray },
};
@@ -165,10 +166,10 @@
RETURN_ERR_IF_NULL(gMovie_class);
gMovie_class = (jclass)env->NewGlobalRef(gMovie_class);
- gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(I)V");
+ gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(J)V");
RETURN_ERR_IF_NULL(gMovie_constructorMethodID);
- gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "I");
+ gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "J");
RETURN_ERR_IF_NULL(gMovie_nativeInstanceID);
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
diff --git a/graphics/java/android/graphics/BitmapRegionDecoder.java b/graphics/java/android/graphics/BitmapRegionDecoder.java
index 3a99977..e689b08 100644
--- a/graphics/java/android/graphics/BitmapRegionDecoder.java
+++ b/graphics/java/android/graphics/BitmapRegionDecoder.java
@@ -33,7 +33,7 @@
*
*/
public final class BitmapRegionDecoder {
- private int mNativeBitmapRegionDecoder;
+ private long mNativeBitmapRegionDecoder;
private boolean mRecycled;
// ensures that the native decoder object exists and that only one decode can
// occur at a time.
@@ -114,7 +114,7 @@
boolean isShareable) throws IOException {
if (is instanceof AssetManager.AssetInputStream) {
return nativeNewInstance(
- ((AssetManager.AssetInputStream) is).getAssetInt(),
+ ((AssetManager.AssetInputStream) is).getNativeAsset(),
isShareable);
} else {
// pass some temp storage down to the native code. 1024 is made up,
@@ -165,7 +165,7 @@
This can be called from JNI code.
*/
- private BitmapRegionDecoder(int decoder) {
+ private BitmapRegionDecoder(long decoder) {
mNativeBitmapRegionDecoder = decoder;
mRecycled = false;
}
@@ -254,12 +254,12 @@
}
}
- private static native Bitmap nativeDecodeRegion(int lbm,
+ private static native Bitmap nativeDecodeRegion(long lbm,
int start_x, int start_y, int width, int height,
BitmapFactory.Options options);
- private static native int nativeGetWidth(int lbm);
- private static native int nativeGetHeight(int lbm);
- private static native void nativeClean(int lbm);
+ private static native int nativeGetWidth(long lbm);
+ private static native int nativeGetHeight(long lbm);
+ private static native void nativeClean(long lbm);
private static native BitmapRegionDecoder nativeNewInstance(
byte[] data, int offset, int length, boolean isShareable);
@@ -268,5 +268,5 @@
private static native BitmapRegionDecoder nativeNewInstance(
InputStream is, byte[] storage, boolean isShareable);
private static native BitmapRegionDecoder nativeNewInstance(
- int asset, boolean isShareable);
+ long asset, boolean isShareable);
}
diff --git a/graphics/java/android/graphics/Movie.java b/graphics/java/android/graphics/Movie.java
index 9419faf..b0a4553 100644
--- a/graphics/java/android/graphics/Movie.java
+++ b/graphics/java/android/graphics/Movie.java
@@ -21,9 +21,9 @@
import java.io.FileInputStream;
public class Movie {
- private final int mNativeMovie;
+ private final long mNativeMovie;
- private Movie(int nativeMovie) {
+ private Movie(long nativeMovie) {
if (nativeMovie == 0) {
throw new RuntimeException("native movie creation failed");
}
@@ -48,19 +48,19 @@
return null;
}
if (is instanceof AssetManager.AssetInputStream) {
- final int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
+ final long asset = ((AssetManager.AssetInputStream) is).getNativeAsset();
return nativeDecodeAsset(asset);
}
return nativeDecodeStream(is);
}
- private static native Movie nativeDecodeAsset(int asset);
+ private static native Movie nativeDecodeAsset(long asset);
private static native Movie nativeDecodeStream(InputStream is);
public static native Movie decodeByteArray(byte[] data, int offset,
int length);
- private static native void nativeDestructor(int nativeMovie);
+ private static native void nativeDestructor(long nativeMovie);
public static Movie decodeFile(String pathName) {
InputStream is;