Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6606d16e authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am 6706888e: am 775667c0: am 03e8be75: am 8796ab7f: am bb35356d: Merge changes...

am 6706888e: am 775667c0: am 03e8be75: am 8796ab7f: am bb35356d: Merge changes Id54087dd,I946325e4,I2a2b2e68

* commit '6706888e':
  AArch64: Use long for pointers in BitmapRegionDecoder
  AArch64: Use long for pointers in Movie class
  AArch64: Add AssetInputStream.getNativeAsset
parents a3340da7 6706888e
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -539,6 +539,12 @@ public final class AssetManager {
        public final int getAssetInt() {
        public final int getAssetInt() {
            return mAsset;
            return mAsset;
        }
        }
        /**
         * @hide
         */
        public final long getNativeAsset() {
            return mAsset;
        }
        private AssetInputStream(int asset)
        private AssetInputStream(int asset)
        {
        {
            mAsset = asset;
            mAsset = asset;
+18 −14
Original line number Original line Diff line number Diff line
@@ -101,7 +101,7 @@ static jobject createBitmapRegionDecoder(JNIEnv* env, SkStreamRewindable* stream
}
}


static jobject nativeNewInstanceFromByteArray(JNIEnv* env, jobject, jbyteArray byteArray,
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
    /*  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
        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.
        For now we just always copy the array's data if isShareable.
@@ -150,7 +150,7 @@ static jobject nativeNewInstanceFromStream(JNIEnv* env, jobject clazz,
}
}


static jobject nativeNewInstanceFromAsset(JNIEnv* env, jobject clazz,
static jobject nativeNewInstanceFromAsset(JNIEnv* env, jobject clazz,
                                 jint native_asset, // Asset
                                 jlong native_asset, // Asset
                                 jboolean isShareable) {
                                 jboolean isShareable) {
    Asset* asset = reinterpret_cast<Asset*>(native_asset);
    Asset* asset = reinterpret_cast<Asset*>(native_asset);
    SkAutoTUnref<SkMemoryStream> stream(CopyAssetToStream(asset));
    SkAutoTUnref<SkMemoryStream> stream(CopyAssetToStream(asset));
@@ -169,8 +169,9 @@ static jobject nativeNewInstanceFromAsset(JNIEnv* env, jobject clazz,
 * purgeable not supported
 * purgeable not supported
 * reportSizeToVM not supported
 * reportSizeToVM not supported
 */
 */
static jobject nativeDecodeRegion(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd,
static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle,
                                int start_x, int start_y, int width, int height, jobject options) {
                                jint start_x, jint start_y, jint width, jint height, jobject options) {
    SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
    jobject tileBitmap = NULL;
    jobject tileBitmap = NULL;
    SkImageDecoder *decoder = brd->getDecoder();
    SkImageDecoder *decoder = brd->getDecoder();
    int sampleSize = 1;
    int sampleSize = 1;
@@ -255,15 +256,18 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, SkBitmapRegionDecoder *b
    return GraphicsJNI::createBitmap(env, bitmap, buff, bitmapCreateFlags, NULL, NULL, -1);
    return GraphicsJNI::createBitmap(env, bitmap, buff, bitmapCreateFlags, NULL, NULL, -1);
}
}


static int nativeGetHeight(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
static jint nativeGetHeight(JNIEnv* env, jobject, jlong brdHandle) {
    return brd->getHeight();
    SkBitmapRegionDecoder *brd = reinterpret_cast<SkBitmapRegionDecoder*>(brdHandle);
    return static_cast<jint>(brd->getHeight());
}
}


static int nativeGetWidth(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {
static jint nativeGetWidth(JNIEnv* env, jobject, jlong brdHandle) {
    return brd->getWidth();
    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;
    delete brd;
}
}


@@ -273,14 +277,14 @@ static void nativeClean(JNIEnv* env, jobject, SkBitmapRegionDecoder *brd) {


static JNINativeMethod gBitmapRegionDecoderMethods[] = {
static JNINativeMethod gBitmapRegionDecoderMethods[] = {
    {   "nativeDecodeRegion",
    {   "nativeDecodeRegion",
        "(IIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
        "(JIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
        (void*)nativeDecodeRegion},
        (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",
    {   "nativeNewInstance",
        "([BIIZ)Landroid/graphics/BitmapRegionDecoder;",
        "([BIIZ)Landroid/graphics/BitmapRegionDecoder;",
@@ -298,7 +302,7 @@ static JNINativeMethod gBitmapRegionDecoderMethods[] = {
    },
    },


    {   "nativeNewInstance",
    {   "nativeNewInstance",
        "(IZ)Landroid/graphics/BitmapRegionDecoder;",
        "(JZ)Landroid/graphics/BitmapRegionDecoder;",
        (void*)nativeNewInstanceFromAsset
        (void*)nativeNewInstanceFromAsset
    },
    },
};
};
+2 −2
Original line number Original line Diff line number Diff line
@@ -412,7 +412,7 @@ jobject GraphicsJNI::createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecode


    jobject obj = env->NewObject(gBitmapRegionDecoder_class,
    jobject obj = env->NewObject(gBitmapRegionDecoder_class,
            gBitmapRegionDecoder_constructorMethodID,
            gBitmapRegionDecoder_constructorMethodID,
            static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)));
            reinterpret_cast<jlong>(bitmap));
    hasException(env); // For the side effect of logging.
    hasException(env); // For the side effect of logging.
    return obj;
    return obj;
}
}
@@ -671,7 +671,7 @@ int register_android_graphics_Graphics(JNIEnv* env)
    gBitmap_reinitMethodID = env->GetMethodID(gBitmap_class, "reinit", "(IIZ)V");
    gBitmap_reinitMethodID = env->GetMethodID(gBitmap_class, "reinit", "(IIZ)V");
    gBitmap_getAllocationByteCountMethodID = env->GetMethodID(gBitmap_class, "getAllocationByteCount", "()I");
    gBitmap_getAllocationByteCountMethodID = env->GetMethodID(gBitmap_class, "getAllocationByteCount", "()I");
    gBitmapRegionDecoder_class = make_globalref(env, "android/graphics/BitmapRegionDecoder");
    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_class = make_globalref(env, "android/graphics/Bitmap$Config");
    gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class,
    gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class,
+19 −18
Original line number Original line Diff line number Diff line
@@ -27,43 +27,43 @@ jobject create_jmovie(JNIEnv* env, SkMovie* moov) {
        return NULL;
        return NULL;
    }
    }
    return env->NewObject(gMovie_class, gMovie_constructorMethodID,
    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) {
static SkMovie* J2Movie(JNIEnv* env, jobject movie) {
    SkASSERT(env);
    SkASSERT(env);
    SkASSERT(movie);
    SkASSERT(movie);
    SkASSERT(env->IsInstanceOf(movie, gMovie_class));
    SkASSERT(env->IsInstanceOf(movie, gMovie_class));
    SkMovie* m = (SkMovie*)env->GetIntField(movie, gMovie_nativeInstanceID);
    SkMovie* m = (SkMovie*)env->GetLongField(movie, gMovie_nativeInstanceID);
    SkASSERT(m);
    SkASSERT(m);
    return 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);
    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);
    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) {
static jboolean movie_isOpaque(JNIEnv* env, jobject movie) {
    NPE_CHECK_RETURN_ZERO(env, 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);
    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);
    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,
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);
    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);
    android::Asset* asset = reinterpret_cast<android::Asset*>(native_asset);
    if (asset == NULL) return NULL;
    if (asset == NULL) return NULL;
    SkAutoTUnref<SkStreamRewindable> stream (new android::AssetStreamAdaptor(asset,
    SkAutoTUnref<SkStreamRewindable> stream (new android::AssetStreamAdaptor(asset,
@@ -117,7 +117,7 @@ static jobject movie_decodeStream(JNIEnv* env, jobject clazz, jobject istream) {


static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz,
static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz,
                                     jbyteArray byteArray,
                                     jbyteArray byteArray,
                                     int offset, int length) {
                                     jint offset, jint length) {


    NPE_CHECK_RETURN_ZERO(env, byteArray);
    NPE_CHECK_RETURN_ZERO(env, byteArray);


@@ -132,7 +132,8 @@ static jobject movie_decodeByteArray(JNIEnv* env, jobject clazz,
    return create_jmovie(env, moov);
    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;
    delete movie;
}
}


@@ -148,11 +149,11 @@ static JNINativeMethod gMethods[] = {
    {   "setTime",  "(I)Z", (void*)movie_setTime  },
    {   "setTime",  "(I)Z", (void*)movie_setTime  },
    {   "draw",     "(Landroid/graphics/Canvas;FFLandroid/graphics/Paint;)V",
    {   "draw",     "(Landroid/graphics/Canvas;FFLandroid/graphics/Paint;)V",
                            (void*)movie_draw  },
                            (void*)movie_draw  },
    { "nativeDecodeAsset", "(I)Landroid/graphics/Movie;",
    { "nativeDecodeAsset", "(J)Landroid/graphics/Movie;",
                            (void*)movie_decodeAsset },
                            (void*)movie_decodeAsset },
    { "nativeDecodeStream", "(Ljava/io/InputStream;)Landroid/graphics/Movie;",
    { "nativeDecodeStream", "(Ljava/io/InputStream;)Landroid/graphics/Movie;",
                            (void*)movie_decodeStream },
                            (void*)movie_decodeStream },
    { "nativeDestructor","(I)V", (void*)movie_destructor },
    { "nativeDestructor","(J)V", (void*)movie_destructor },
    { "decodeByteArray", "([BII)Landroid/graphics/Movie;",
    { "decodeByteArray", "([BII)Landroid/graphics/Movie;",
                            (void*)movie_decodeByteArray },
                            (void*)movie_decodeByteArray },
};
};
@@ -167,10 +168,10 @@ int register_android_graphics_Movie(JNIEnv* env)
    RETURN_ERR_IF_NULL(gMovie_class);
    RETURN_ERR_IF_NULL(gMovie_class);
    gMovie_class = (jclass)env->NewGlobalRef(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);
    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_ERR_IF_NULL(gMovie_nativeInstanceID);


    return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
    return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
+8 −8
Original line number Original line Diff line number Diff line
@@ -33,7 +33,7 @@ import java.io.InputStream;
 *
 *
 */
 */
public final class BitmapRegionDecoder {
public final class BitmapRegionDecoder {
    private int mNativeBitmapRegionDecoder;
    private long mNativeBitmapRegionDecoder;
    private boolean mRecycled;
    private boolean mRecycled;
    // ensures that the native decoder object exists and that only one decode can
    // ensures that the native decoder object exists and that only one decode can
    // occur at a time.
    // occur at a time.
@@ -114,7 +114,7 @@ public final class BitmapRegionDecoder {
            boolean isShareable) throws IOException {
            boolean isShareable) throws IOException {
        if (is instanceof AssetManager.AssetInputStream) {
        if (is instanceof AssetManager.AssetInputStream) {
            return nativeNewInstance(
            return nativeNewInstance(
                    ((AssetManager.AssetInputStream) is).getAssetInt(),
                    ((AssetManager.AssetInputStream) is).getNativeAsset(),
                    isShareable);
                    isShareable);
        } else {
        } else {
            // pass some temp storage down to the native code. 1024 is made up,
            // pass some temp storage down to the native code. 1024 is made up,
@@ -165,7 +165,7 @@ public final class BitmapRegionDecoder {


        This can be called from JNI code.
        This can be called from JNI code.
    */
    */
    private BitmapRegionDecoder(int decoder) {
    private BitmapRegionDecoder(long decoder) {
        mNativeBitmapRegionDecoder = decoder;
        mNativeBitmapRegionDecoder = decoder;
        mRecycled = false;
        mRecycled = false;
    }
    }
@@ -254,12 +254,12 @@ public final class BitmapRegionDecoder {
        }
        }
    }
    }


    private static native Bitmap nativeDecodeRegion(int lbm,
    private static native Bitmap nativeDecodeRegion(long lbm,
            int start_x, int start_y, int width, int height,
            int start_x, int start_y, int width, int height,
            BitmapFactory.Options options);
            BitmapFactory.Options options);
    private static native int nativeGetWidth(int lbm);
    private static native int nativeGetWidth(long lbm);
    private static native int nativeGetHeight(int lbm);
    private static native int nativeGetHeight(long lbm);
    private static native void nativeClean(int lbm);
    private static native void nativeClean(long lbm);


    private static native BitmapRegionDecoder nativeNewInstance(
    private static native BitmapRegionDecoder nativeNewInstance(
            byte[] data, int offset, int length, boolean isShareable);
            byte[] data, int offset, int length, boolean isShareable);
@@ -268,5 +268,5 @@ public final class BitmapRegionDecoder {
    private static native BitmapRegionDecoder nativeNewInstance(
    private static native BitmapRegionDecoder nativeNewInstance(
            InputStream is, byte[] storage, boolean isShareable);
            InputStream is, byte[] storage, boolean isShareable);
    private static native BitmapRegionDecoder nativeNewInstance(
    private static native BitmapRegionDecoder nativeNewInstance(
            int asset, boolean isShareable);
            long asset, boolean isShareable);
}
}
Loading