File: ByteBufferStreamAdaptor.h

package info (click to toggle)
android-platform-frameworks-base 1%3A10.0.0%2Br36-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 321,788 kB
  • sloc: java: 962,234; cpp: 274,314; xml: 242,770; python: 5,060; sh: 1,432; ansic: 494; makefile: 47; sed: 19
file content (37 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _ANDROID_GRAPHICS_BYTE_BUFFER_STREAM_ADAPTOR_H_
#define _ANDROID_GRAPHICS_BYTE_BUFFER_STREAM_ADAPTOR_H_

#include <jni.h>
#include <memory>

class SkStream;

/**
 * Create an adaptor for treating a java.nio.ByteBuffer as an SkStream.
 *
 * This will special case direct ByteBuffers, but not the case where a byte[]
 * can be used directly. For that, use CreateByteArrayStreamAdaptor.
 *
 * @param jbyteBuffer corresponding to the java ByteBuffer. This method will
 *      add a global ref.
 * @param initialPosition returned by ByteBuffer.position(). Decoding starts
 *      from here.
 * @param limit returned by ByteBuffer.limit().
 *
 * Returns null on failure.
 */
std::unique_ptr<SkStream> CreateByteBufferStreamAdaptor(JNIEnv*, jobject jbyteBuffer,
                                                        size_t initialPosition, size_t limit);

/**
 * Create an adaptor for treating a Java byte[] as an SkStream.
 *
 * @param offset into the byte[] of the beginning of the data to use.
 * @param length of data to use, starting from offset.
 *
 * Returns null on failure.
 */
std::unique_ptr<SkStream> CreateByteArrayStreamAdaptor(JNIEnv*, jbyteArray array, size_t offset,
                                                       size_t length);

#endif  // _ANDROID_GRAPHICS_BYTE_BUFFER_STREAM_ADAPTOR_H_