summaryrefslogtreecommitdiffstats
path: root/core/jni/android/graphics/NIOBuffer.h
blob: 36b5554a5dc7cd7782404c9594427a5339cfd572 (plain)
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
#ifndef NIOBuffer_DEFINED
#define NIOBuffer_DEFINED

#include <jni.h>
#include "SkBitmap.h"

class NIOBuffer {
public:
    NIOBuffer(JNIEnv* env, jobject buffer);
    // this checks to ensure that free() was called
    ~NIOBuffer();

    void* lock(JNIEnv* env, int* remaining);
    void unlock(JNIEnv* env, bool dataChanged);
    // must be called before destructor
    void free(JNIEnv* env);

    // call once on boot, to setup JNI globals
    static void RegisterJNI(JNIEnv*);

private:
    jobject     fBuffer;
    void*       fLockedPtr;
    jbyteArray  fLockedArray;
};

#endif