Skip to content
Snippets Groups Projects
Commit dcaf5593 authored by Ashok Bhat's avatar Ashok Bhat Committed by David Butcher
Browse files

AArch64: Use long for pointers in Movie class


For storing pointers, long is used in Movie class,
as native pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

Change-Id: I946325e4af6cb9282012bebdaee89e1117d8797b
Signed-off-by: default avatarAshok Bhat <ashok.bhat@arm.com>
Signed-off-by: default avatarMarcus Oakland <marcus.oakland@arm.com>
parent a0545dd5
No related branches found
No related tags found
No related merge requests found
......@@ -27,43 +27,43 @@ jobject create_jmovie(JNIEnv* env, SkMovie* moov) {
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 @@ static void movie_draw(JNIEnv* env, jobject movie, jobject canvas,
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_decodeStream(JNIEnv* env, jobject clazz, jobject istream) {
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 @@ static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz,
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 @@ static JNINativeMethod gMethods[] = {
{ "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 @@ int register_android_graphics_Movie(JNIEnv* env)
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,
......
......@@ -21,9 +21,9 @@ import java.io.InputStream;
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 @@ public class Movie {
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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment