Home | History | Annotate | Download | only in graphics
      1 #ifndef _ANDROID_GRAPHICS_BYTE_BUFFER_STREAM_ADAPTOR_H_
      2 #define _ANDROID_GRAPHICS_BYTE_BUFFER_STREAM_ADAPTOR_H_
      3 
      4 #include <jni.h>
      5 #include <memory>
      6 
      7 class SkStream;
      8 
      9 /**
     10  * Create an adaptor for treating a java.nio.ByteBuffer as an SkStream.
     11  *
     12  * This will special case direct ByteBuffers, but not the case where a byte[]
     13  * can be used directly. For that, use CreateByteArrayStreamAdaptor.
     14  *
     15  * @param jbyteBuffer corresponding to the java ByteBuffer. This method will
     16  *      add a global ref.
     17  * @param initialPosition returned by ByteBuffer.position(). Decoding starts
     18  *      from here.
     19  * @param limit returned by ByteBuffer.limit().
     20  *
     21  * Returns null on failure.
     22  */
     23 std::unique_ptr<SkStream> CreateByteBufferStreamAdaptor(JNIEnv*, jobject jbyteBuffer,
     24                                                         size_t initialPosition, size_t limit);
     25 
     26 /**
     27  * Create an adaptor for treating a Java byte[] as an SkStream.
     28  *
     29  * @param offset into the byte[] of the beginning of the data to use.
     30  * @param length of data to use, starting from offset.
     31  *
     32  * Returns null on failure.
     33  */
     34 std::unique_ptr<SkStream> CreateByteArrayStreamAdaptor(JNIEnv*, jbyteArray array, size_t offset,
     35                                                        size_t length);
     36 
     37 #endif  // _ANDROID_GRAPHICS_BYTE_BUFFER_STREAM_ADAPTOR_H_
     38