diff options
4 files changed, 19 insertions, 20 deletions
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp index 6646579..ee47ac4 100644 --- a/core/jni/android/graphics/BitmapRegionDecoder.cpp +++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp @@ -141,7 +141,7 @@ static jobject nativeNewInstanceFromStream(JNIEnv* env, jobject clazz, jboolean isShareable) { jobject brd = NULL; // for now we don't allow shareable with java inputstreams - SkStream* stream = CopyJavaInputStream(env, is, storage); + SkStreamRewindable* stream = CopyJavaInputStream(env, is, storage); if (stream) { brd = createBitmapRegionDecoder(env, stream); diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp index 797d155..d264392 100644 --- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp +++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp @@ -159,8 +159,8 @@ private: friend class RewindableJavaStream; }; -SkStream* WrapJavaInputStream(JNIEnv* env, jobject stream, - jbyteArray storage) { +SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream, + jbyteArray storage) { static bool gInited; if (!gInited) { @@ -190,6 +190,7 @@ SkStream* WrapJavaInputStream(JNIEnv* env, jobject stream, return new JavaInputStreamAdaptor(env, stream, storage); } + static SkMemoryStream* adaptor_to_mem_stream(SkStream* adaptor) { SkASSERT(adaptor != NULL); SkDynamicMemoryWStream wStream; @@ -203,9 +204,9 @@ static SkMemoryStream* adaptor_to_mem_stream(SkStream* adaptor) { return new SkMemoryStream(data.get()); } -SkMemoryStream* CopyJavaInputStream(JNIEnv* env, jobject stream, - jbyteArray storage) { - SkAutoTUnref<SkStream> adaptor(WrapJavaInputStream(env, stream, storage)); +SkStreamRewindable* CopyJavaInputStream(JNIEnv* env, jobject stream, + jbyteArray storage) { + SkAutoTUnref<SkStream> adaptor(CreateJavaInputStreamAdaptor(env, stream, storage)); if (NULL == adaptor.get()) { return NULL; } @@ -302,7 +303,7 @@ static size_t get_length_if_supported(JNIEnv* env, jobject jstream) { SkStreamRewindable* GetRewindableStream(JNIEnv* env, jobject stream, jbyteArray storage) { - SkAutoTUnref<SkStream> adaptor(WrapJavaInputStream(env, stream, storage)); + SkAutoTUnref<SkStream> adaptor(CreateJavaInputStreamAdaptor(env, stream, storage)); if (NULL == adaptor.get()) { return NULL; } diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h index 5218dc5..fcc0c9a 100644 --- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h +++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h @@ -24,8 +24,8 @@ class SkWStream; * function returns, since the Java InputStream is not managed * by the SkStream. */ -SkStream* WrapJavaInputStream(JNIEnv* env, jobject stream, - jbyteArray storage); +SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream, + jbyteArray storage); /** * Copy a Java InputStream. @@ -33,13 +33,11 @@ SkStream* WrapJavaInputStream(JNIEnv* env, jobject stream, * @param stream Pointer to Java InputStream. * @param storage Java byte array for retrieving data from the * Java InputStream. - * @return SkMemoryStream The data in stream will be copied to a new - * SkMemoryStream. - * FIXME: Could return a more generic return type if ViewStateSerializer - * did not require an SkMemoryStream. + * @return SkStreamRewindable The data in stream will be copied + * to a new SkStreamRewindable. */ -SkMemoryStream* CopyJavaInputStream(JNIEnv* env, jobject stream, - jbyteArray storage); +SkStreamRewindable* CopyJavaInputStream(JNIEnv* env, jobject stream, + jbyteArray storage); /** * Get a rewindable stream from a Java InputStream. @@ -50,7 +48,7 @@ SkMemoryStream* CopyJavaInputStream(JNIEnv* env, jobject stream, * @return SkStreamRewindable Either a wrapper around the Java * InputStream, if possible, or a copy which is rewindable. * Since it may be a wrapper, must not be used after the - * caller returns, like the result of WrapJavaInputStream. + * caller returns, like the result of CreateJavaInputStreamAdaptor. */ SkStreamRewindable* GetRewindableStream(JNIEnv* env, jobject stream, jbyteArray storage); @@ -69,5 +67,4 @@ android::AssetStreamAdaptor* CheckForAssetStream(JNIEnv* env, jobject stream); SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage); - #endif diff --git a/core/jni/android/graphics/Picture.cpp b/core/jni/android/graphics/Picture.cpp index dff2b18..fcf22b8 100644 --- a/core/jni/android/graphics/Picture.cpp +++ b/core/jni/android/graphics/Picture.cpp @@ -39,9 +39,10 @@ public: static SkPicture* deserialize(JNIEnv* env, jobject, jobject jstream, jbyteArray jstorage) { SkPicture* picture = NULL; - SkAutoTUnref<SkStream> strm(WrapJavaInputStream(env, jstream, jstorage)); - if (strm.get()) { - picture = SkPicture::CreateFromStream(strm.get()); + SkStream* strm = CreateJavaInputStreamAdaptor(env, jstream, jstorage); + if (strm) { + picture = SkPicture::CreateFromStream(strm); + delete strm; } return picture; } |