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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*
** Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
// This source file is automatically generated
#include "jni.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <utils/misc.h>
#include <assert.h>
#include <EGL/egl.h>
#include <gui/Surface.h>
#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <ui/ANativeObjectBase.h>
static int initialized = 0;
static jclass egldisplayClass;
static jclass eglcontextClass;
static jclass eglsurfaceClass;
static jclass eglconfigClass;
static jmethodID egldisplayGetHandleID;
static jmethodID eglcontextGetHandleID;
static jmethodID eglsurfaceGetHandleID;
static jmethodID eglconfigGetHandleID;
static jmethodID egldisplayConstructor;
static jmethodID eglcontextConstructor;
static jmethodID eglsurfaceConstructor;
static jmethodID eglconfigConstructor;
static jobject eglNoContextObject;
static jobject eglNoDisplayObject;
static jobject eglNoSurfaceObject;
/* Cache method IDs each time the class is loaded. */
static void
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay");
egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal);
jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext");
eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal);
jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface");
eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal);
jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I");
eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I");
eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I");
eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I");
egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V");
eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V");
eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V");
eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V");
jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT);
eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY);
eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE);
eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
jclass eglClass = _env->FindClass("android/opengl/EGL14");
jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;");
_env->SetStaticObjectField(eglClass, noContextFieldID, eglNoContextObject);
jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;");
_env->SetStaticObjectField(eglClass, noDisplayFieldID, eglNoDisplayObject);
jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;");
_env->SetStaticObjectField(eglClass, noSurfaceFieldID, eglNoSurfaceObject);
}
static void *
fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
if (obj == NULL){
jniThrowException(_env, "java/lang/IllegalArgumentException",
"Object is set to null.");
}
return (void*) (_env->CallIntMethod(obj, mid));
}
static jobject
toEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) {
if (cls == eglcontextClass &&
(EGLContext)handle == EGL_NO_CONTEXT) {
return eglNoContextObject;
}
if (cls == egldisplayClass &&
(EGLDisplay)handle == EGL_NO_DISPLAY) {
return eglNoDisplayObject;
}
if (cls == eglsurfaceClass &&
(EGLSurface)handle == EGL_NO_SURFACE) {
return eglNoSurfaceObject;
}
return _env->NewObject(cls, con, (jint)handle);
}
// --------------------------------------------------------------------------
|