blob: bae40f1e8d2f63d7e70abeb55814d2eec1b59ae0 [file] [log] [blame]
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001#ifndef _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_
2#define _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004#include "jni.h"
Leon Scroggins III23ac0362020-05-04 15:38:58 -04005#include "SkData.h"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006
Leon Scroggins IIIca320212013-08-20 17:59:39 -04007class SkMemoryStream;
8class SkStream;
9class SkStreamRewindable;
10class SkWStream;
11
12/**
13 * Return an adaptor from a Java InputStream to an SkStream.
Leon Scroggins III7315f1b2013-09-10 20:26:05 -040014 * Does not support rewind.
Leon Scroggins IIIca320212013-08-20 17:59:39 -040015 * @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.
Leon Scroggins IIIed074fd2017-12-11 13:47:23 -050019 * @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.
Leon Scroggins IIIca320212013-08-20 17:59:39 -040022 * @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 */
Leon Scroggins IIIed074fd2017-12-11 13:47:23 -050027SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage,
28 bool swallowExceptions = true);
Leon Scroggins IIIca320212013-08-20 17:59:39 -040029
30/**
Leon Scroggins III23ac0362020-05-04 15:38:58 -040031 * Copy a Java InputStream to an SkData.
Leon Scroggins IIIca320212013-08-20 17:59:39 -040032 * @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.
Leon Scroggins III23ac0362020-05-04 15:38:58 -040036 * @return SkData containing the stream's data.
Leon Scroggins IIIca320212013-08-20 17:59:39 -040037 */
Leon Scroggins III23ac0362020-05-04 15:38:58 -040038sk_sp<SkData> CopyJavaInputStream(JNIEnv* env, jobject stream, jbyteArray storage);
Leon Scroggins IIIca320212013-08-20 17:59:39 -040039
Leon Scroggins IIIed074fd2017-12-11 13:47:23 -050040SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage);
Andreas Gampeed6b9df2014-11-20 22:02:20 -080041
42#endif // _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_