1 #ifndef _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ 2 #define _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ 3 4 #include "jni.h" 5 #include "SkData.h" 6 7 class SkMemoryStream; 8 class SkStream; 9 class SkStreamRewindable; 10 class SkWStream; 11 12 /** 13 * Return an adaptor from a Java InputStream to an SkStream. 14 * Does not support rewind. 15 * @param env JNIEnv object. 16 * @param stream Pointer to Java InputStream. 17 * @param storage Java byte array for retrieving data from the 18 * Java InputStream. 19 * @param swallowExceptions Whether to call ExceptionClear() after 20 * an Exception is thrown. If false, it is up to the client to 21 * clear or propagate the exception. 22 * @return SkStream Simple subclass of SkStream which supports its 23 * basic methods like reading. Only valid until the calling 24 * function returns, since the Java InputStream is not managed 25 * by the SkStream. 26 */ 27 SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage, 28 bool swallowExceptions = true); 29 30 /** 31 * Copy a Java InputStream to an SkData. 32 * @param env JNIEnv object. 33 * @param stream Pointer to Java InputStream. 34 * @param storage Java byte array for retrieving data from the 35 * Java InputStream. 36 * @return SkData containing the stream's data. 37 */ 38 sk_sp<SkData> CopyJavaInputStream(JNIEnv* env, jobject stream, jbyteArray storage); 39 40 SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage); 41 42 #endif // _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ 43