Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1 | #ifndef _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ |
| 2 | #define _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4 | #include "jni.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5 | |
Leon Scroggins III | ca32021 | 2013-08-20 17:59:39 -0400 | [diff] [blame] | 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. |
Leon Scroggins III | 7315f1b | 2013-09-10 20:26:05 -0400 | [diff] [blame] | 13 | * Does not support rewind. |
Leon Scroggins III | ca32021 | 2013-08-20 17:59:39 -0400 | [diff] [blame] | 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. |
Leon Scroggins III | ed074fd | 2017-12-11 13:47:23 -0500 | [diff] [blame] | 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. |
Leon Scroggins III | ca32021 | 2013-08-20 17:59:39 -0400 | [diff] [blame] | 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 | */ |
Leon Scroggins III | ed074fd | 2017-12-11 13:47:23 -0500 | [diff] [blame] | 26 | SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage, |
| 27 | bool swallowExceptions = true); |
Leon Scroggins III | ca32021 | 2013-08-20 17:59:39 -0400 | [diff] [blame] | 28 | |
| 29 | /** |
Leon Scroggins III | 7315f1b | 2013-09-10 20:26:05 -0400 | [diff] [blame] | 30 | * Copy a Java InputStream. The result will be rewindable. |
Leon Scroggins III | ca32021 | 2013-08-20 17:59:39 -0400 | [diff] [blame] | 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. |
Leon Scroggins III | c779752 | 2013-09-03 11:35:00 -0400 | [diff] [blame] | 35 | * @return SkStreamRewindable The data in stream will be copied |
| 36 | * to a new SkStreamRewindable. |
Leon Scroggins III | ca32021 | 2013-08-20 17:59:39 -0400 | [diff] [blame] | 37 | */ |
Leon Scroggins III | ed074fd | 2017-12-11 13:47:23 -0500 | [diff] [blame] | 38 | SkStreamRewindable* CopyJavaInputStream(JNIEnv* env, jobject stream, jbyteArray storage); |
Leon Scroggins III | ca32021 | 2013-08-20 17:59:39 -0400 | [diff] [blame] | 39 | |
Leon Scroggins III | ed074fd | 2017-12-11 13:47:23 -0500 | [diff] [blame] | 40 | SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 41 | |
| 42 | #endif // _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ |