* commit '718516f3b73468c480ef8d2283a1c80a6223658d': Fix memory leak of SkMovie class
This commit is contained in:
@@ -115,6 +115,10 @@ 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) {
|
||||||
|
delete movie;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <android_runtime/AndroidRuntime.h>
|
#include <android_runtime/AndroidRuntime.h>
|
||||||
@@ -129,6 +133,7 @@ static JNINativeMethod gMethods[] = {
|
|||||||
(void*)movie_draw },
|
(void*)movie_draw },
|
||||||
{ "decodeStream", "(Ljava/io/InputStream;)Landroid/graphics/Movie;",
|
{ "decodeStream", "(Ljava/io/InputStream;)Landroid/graphics/Movie;",
|
||||||
(void*)movie_decodeStream },
|
(void*)movie_decodeStream },
|
||||||
|
{ "nativeDestructor","(I)V", (void*)movie_destructor },
|
||||||
{ "decodeByteArray", "([BII)Landroid/graphics/Movie;",
|
{ "decodeByteArray", "([BII)Landroid/graphics/Movie;",
|
||||||
(void*)movie_decodeByteArray },
|
(void*)movie_decodeByteArray },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public class Movie {
|
|||||||
public static native Movie decodeByteArray(byte[] data, int offset,
|
public static native Movie decodeByteArray(byte[] data, int offset,
|
||||||
int length);
|
int length);
|
||||||
|
|
||||||
|
private static native void nativeDestructor(int nativeMovie);
|
||||||
|
|
||||||
public static Movie decodeFile(String pathName) {
|
public static Movie decodeFile(String pathName) {
|
||||||
InputStream is;
|
InputStream is;
|
||||||
try {
|
try {
|
||||||
@@ -57,6 +59,15 @@ public class Movie {
|
|||||||
return decodeTempStream(is);
|
return decodeTempStream(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
try {
|
||||||
|
nativeDestructor(mNativeMovie);
|
||||||
|
} finally {
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Movie decodeTempStream(InputStream is) {
|
private static Movie decodeTempStream(InputStream is) {
|
||||||
Movie moov = null;
|
Movie moov = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user