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 
6 class SkMemoryStream;
7 class SkStream;
8 class SkStreamRewindable;
9 class SkWStream;
10 
11 /**
12  *  Return an adaptor from a Java InputStream to an SkStream.
13  *  Does not support rewind.
14  *  @param env JNIEnv object.
15  *  @param stream Pointer to Java InputStream.
16  *  @param storage Java byte array for retrieving data from the
17  *      Java InputStream.
18  *  @param swallowExceptions Whether to call ExceptionClear() after
19  *      an Exception is thrown. If false, it is up to the client to
20  *      clear or propagate the exception.
21  *  @return SkStream Simple subclass of SkStream which supports its
22  *      basic methods like reading. Only valid until the calling
23  *      function returns, since the Java InputStream is not managed
24  *      by the SkStream.
25  */
26 SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage,
27                                        bool swallowExceptions = true);
28 
29 /**
30  *  Copy a Java InputStream. The result will be rewindable.
31  *  @param env JNIEnv object.
32  *  @param stream Pointer to Java InputStream.
33  *  @param storage Java byte array for retrieving data from the
34  *      Java InputStream.
35  *  @return SkStreamRewindable The data in stream will be copied
36  *      to a new SkStreamRewindable.
37  */
38 SkStreamRewindable* 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