1 /*
2 **
3 ** Copyright 2006, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #include <nativehelper/JNIHelp.h>
19 #include <android_runtime/AndroidRuntime.h>
20 #include <android_runtime/android_view_Surface.h>
21 #include <android_runtime/android_graphics_SurfaceTexture.h>
22 #include <utils/misc.h>
23
24
25 #include <EGL/egl.h>
26 #include <GLES/gl.h>
27 #include <private/EGL/display.h>
28
29 #include <gui/Surface.h>
30 #include <gui/GLConsumer.h>
31 #include <gui/Surface.h>
32
33 #include <ui/ANativeObjectBase.h>
34
35 namespace android {
36
37 static jclass gConfig_class;
38
39 static jmethodID gConfig_ctorID;
40
41 static jfieldID gDisplay_EGLDisplayFieldID;
42 static jfieldID gContext_EGLContextFieldID;
43 static jfieldID gSurface_EGLSurfaceFieldID;
44 static jfieldID gConfig_EGLConfigFieldID;
45
getDisplay(JNIEnv * env,jobject o)46 static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) {
47 if (!o) return EGL_NO_DISPLAY;
48 return (EGLDisplay)env->GetLongField(o, gDisplay_EGLDisplayFieldID);
49 }
getSurface(JNIEnv * env,jobject o)50 static inline EGLSurface getSurface(JNIEnv* env, jobject o) {
51 if (!o) return EGL_NO_SURFACE;
52 return (EGLSurface)env->GetLongField(o, gSurface_EGLSurfaceFieldID);
53 }
getContext(JNIEnv * env,jobject o)54 static inline EGLContext getContext(JNIEnv* env, jobject o) {
55 if (!o) return EGL_NO_CONTEXT;
56 return (EGLContext)env->GetLongField(o, gContext_EGLContextFieldID);
57 }
getConfig(JNIEnv * env,jobject o)58 static inline EGLConfig getConfig(JNIEnv* env, jobject o) {
59 if (!o) return 0;
60 return (EGLConfig)env->GetLongField(o, gConfig_EGLConfigFieldID);
61 }
62
EglBoolToJBool(EGLBoolean eglBool)63 static inline jboolean EglBoolToJBool(EGLBoolean eglBool) {
64 return eglBool == EGL_TRUE ? JNI_TRUE : JNI_FALSE;
65 }
66
nativeClassInit(JNIEnv * _env,jclass eglImplClass)67 static void nativeClassInit(JNIEnv *_env, jclass eglImplClass)
68 {
69 jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl");
70 gConfig_class = (jclass) _env->NewGlobalRef(config_class);
71 gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(J)V");
72 gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "J");
73
74 jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl");
75 gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "J");
76
77 jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl");
78 gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "J");
79
80 jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
81 gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "J");
82 }
83
84 static const jint gNull_attrib_base[] = {EGL_NONE};
85
validAttribList(JNIEnv * _env,jintArray attrib_list)86 static bool validAttribList(JNIEnv *_env, jintArray attrib_list) {
87 if (attrib_list == NULL) {
88 return true;
89 }
90 jsize len = _env->GetArrayLength(attrib_list);
91 if (len < 1) {
92 return false;
93 }
94 jint item = 0;
95 _env->GetIntArrayRegion(attrib_list, len-1, 1, &item);
96 return item == EGL_NONE;
97 }
98
beginNativeAttribList(JNIEnv * _env,jintArray attrib_list)99 static jint* beginNativeAttribList(JNIEnv *_env, jintArray attrib_list) {
100 if (attrib_list != NULL) {
101 return _env->GetIntArrayElements(attrib_list, (jboolean *)0);
102 } else {
103 return(jint*) gNull_attrib_base;
104 }
105 }
106
endNativeAttributeList(JNIEnv * _env,jintArray attrib_list,jint * attrib_base)107 static void endNativeAttributeList(JNIEnv *_env, jintArray attrib_list, jint* attrib_base) {
108 if (attrib_list != NULL) {
109 _env->ReleaseIntArrayElements(attrib_list, attrib_base, 0);
110 }
111 }
112
jni_eglInitialize(JNIEnv * _env,jobject _this,jobject display,jintArray major_minor)113 static jboolean jni_eglInitialize(JNIEnv *_env, jobject _this, jobject display,
114 jintArray major_minor) {
115 if (display == NULL || (major_minor != NULL &&
116 _env->GetArrayLength(major_minor) < 2)) {
117 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
118 return JNI_FALSE;
119 }
120
121 EGLDisplay dpy = getDisplay(_env, display);
122 EGLBoolean success = eglInitialize(dpy, NULL, NULL);
123 if (success && major_minor) {
124 int len = _env->GetArrayLength(major_minor);
125 if (len) {
126 // we're exposing only EGL 1.0
127 jint* base = (jint *)_env->GetPrimitiveArrayCritical(major_minor, (jboolean *)0);
128 if (len >= 1) base[0] = 1;
129 if (len >= 2) base[1] = 0;
130 _env->ReleasePrimitiveArrayCritical(major_minor, base, 0);
131 }
132 }
133 return EglBoolToJBool(success);
134 }
135
jni_eglQueryContext(JNIEnv * _env,jobject _this,jobject display,jobject context,jint attribute,jintArray value)136 static jboolean jni_eglQueryContext(JNIEnv *_env, jobject _this, jobject display,
137 jobject context, jint attribute, jintArray value) {
138 if (display == NULL || context == NULL || value == NULL
139 || _env->GetArrayLength(value) < 1) {
140 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
141 return JNI_FALSE;
142 }
143 EGLDisplay dpy = getDisplay(_env, display);
144 EGLContext ctx = getContext(_env, context);
145 EGLBoolean success = EGL_FALSE;
146 int len = _env->GetArrayLength(value);
147 if (len) {
148 jint* base = _env->GetIntArrayElements(value, (jboolean *)0);
149 success = eglQueryContext(dpy, ctx, attribute, base);
150 _env->ReleaseIntArrayElements(value, base, 0);
151 }
152 return EglBoolToJBool(success);
153 }
154
jni_eglQuerySurface(JNIEnv * _env,jobject _this,jobject display,jobject surface,jint attribute,jintArray value)155 static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display,
156 jobject surface, jint attribute, jintArray value) {
157 if (display == NULL || surface == NULL || value == NULL
158 || _env->GetArrayLength(value) < 1) {
159 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
160 return JNI_FALSE;
161 }
162 EGLDisplay dpy = getDisplay(_env, display);
163 EGLContext sur = getSurface(_env, surface);
164
165 EGLBoolean success = EGL_FALSE;
166 int len = _env->GetArrayLength(value);
167 if (len) {
168 jint* base = _env->GetIntArrayElements(value, (jboolean *)0);
169 success = eglQuerySurface(dpy, sur, attribute, base);
170 _env->ReleaseIntArrayElements(value, base, 0);
171 }
172 return EglBoolToJBool(success);
173 }
174
jni_getInitCount(JNIEnv * _env,jobject _clazz,jobject display)175 static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) {
176 EGLDisplay dpy = getDisplay(_env, display);
177 return android::egl_get_init_count(dpy);
178 }
179
jni_eglReleaseThread(JNIEnv * _env,jobject _this)180 static jboolean jni_eglReleaseThread(JNIEnv *_env, jobject _this) {
181 return EglBoolToJBool(eglReleaseThread());
182 }
183
jni_eglChooseConfig(JNIEnv * _env,jobject _this,jobject display,jintArray attrib_list,jobjectArray configs,jint config_size,jintArray num_config)184 static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display,
185 jintArray attrib_list, jobjectArray configs, jint config_size, jintArray num_config) {
186 if (display == NULL
187 || !validAttribList(_env, attrib_list)
188 || (configs != NULL && _env->GetArrayLength(configs) < config_size)
189 || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) {
190 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
191 return JNI_FALSE;
192 }
193 EGLDisplay dpy = getDisplay(_env, display);
194 EGLBoolean success = EGL_FALSE;
195
196 if (configs == NULL) {
197 config_size = 0;
198 }
199 EGLConfig nativeConfigs[config_size];
200
201 int num = 0;
202 jint* attrib_base = beginNativeAttribList(_env, attrib_list);
203 success = eglChooseConfig(dpy, attrib_base, configs ? nativeConfigs : 0, config_size, &num);
204 endNativeAttributeList(_env, attrib_list, attrib_base);
205
206 if (num_config != NULL) {
207 _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num);
208 }
209
210 if (success && configs!=NULL) {
211 for (int i=0 ; i<num ; i++) {
212 jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, reinterpret_cast<jlong>(nativeConfigs[i]));
213 _env->SetObjectArrayElement(configs, i, obj);
214 }
215 }
216 return EglBoolToJBool(success);
217 }
218
jni_eglCreateContext(JNIEnv * _env,jobject _this,jobject display,jobject config,jobject share_context,jintArray attrib_list)219 static jlong jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display,
220 jobject config, jobject share_context, jintArray attrib_list) {
221 if (display == NULL || config == NULL || share_context == NULL
222 || !validAttribList(_env, attrib_list)) {
223 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
224 return JNI_FALSE;
225 }
226 EGLDisplay dpy = getDisplay(_env, display);
227 EGLConfig cnf = getConfig(_env, config);
228 EGLContext shr = getContext(_env, share_context);
229 jint* base = beginNativeAttribList(_env, attrib_list);
230 EGLContext ctx = eglCreateContext(dpy, cnf, shr, base);
231 endNativeAttributeList(_env, attrib_list, base);
232 return reinterpret_cast<jlong>(ctx);
233 }
234
jni_eglCreatePbufferSurface(JNIEnv * _env,jobject _this,jobject display,jobject config,jintArray attrib_list)235 static jlong jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display,
236 jobject config, jintArray attrib_list) {
237 if (display == NULL || config == NULL
238 || !validAttribList(_env, attrib_list)) {
239 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
240 return JNI_FALSE;
241 }
242 EGLDisplay dpy = getDisplay(_env, display);
243 EGLConfig cnf = getConfig(_env, config);
244 jint* base = beginNativeAttribList(_env, attrib_list);
245 EGLSurface sur = eglCreatePbufferSurface(dpy, cnf, base);
246 endNativeAttributeList(_env, attrib_list, base);
247 return reinterpret_cast<jlong>(sur);
248 }
249
jni_eglCreatePixmapSurface(JNIEnv * _env,jobject _this,jobject out_sur,jobject display,jobject config,jobject native_pixmap,jintArray attrib_list)250 static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_sur,
251 jobject display, jobject config, jobject native_pixmap,
252 jintArray attrib_list)
253 {
254 jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePixmapSurface");
255 }
256
jni_eglCreateWindowSurface(JNIEnv * _env,jobject _this,jobject display,jobject config,jobject native_window,jintArray attrib_list)257 static jlong jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display,
258 jobject config, jobject native_window, jintArray attrib_list) {
259 if (display == NULL || config == NULL
260 || !validAttribList(_env, attrib_list)) {
261 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
262 return JNI_FALSE;
263 }
264 EGLDisplay dpy = getDisplay(_env, display);
265 EGLContext cnf = getConfig(_env, config);
266 sp<ANativeWindow> window;
267 if (native_window == NULL) {
268 not_valid_surface:
269 jniThrowException(_env, "java/lang/IllegalArgumentException",
270 "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface");
271 return 0;
272 }
273
274 window = android_view_Surface_getNativeWindow(_env, native_window);
275 if (window == NULL)
276 goto not_valid_surface;
277
278 jint* base = beginNativeAttribList(_env, attrib_list);
279 EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
280 endNativeAttributeList(_env, attrib_list, base);
281 return reinterpret_cast<jlong>(sur);
282 }
283
jni_eglCreateWindowSurfaceTexture(JNIEnv * _env,jobject _this,jobject display,jobject config,jobject native_window,jintArray attrib_list)284 static jlong jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display,
285 jobject config, jobject native_window, jintArray attrib_list) {
286 if (display == NULL || config == NULL
287 || !validAttribList(_env, attrib_list)) {
288 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
289 return 0;
290 }
291 EGLDisplay dpy = getDisplay(_env, display);
292 EGLContext cnf = getConfig(_env, config);
293 sp<ANativeWindow> window;
294 if (native_window == 0) {
295 not_valid_surface:
296 jniThrowException(_env, "java/lang/IllegalArgumentException",
297 "Make sure the SurfaceTexture is valid");
298 return 0;
299 }
300
301 sp<IGraphicBufferProducer> producer(SurfaceTexture_getProducer(_env, native_window));
302 window = new Surface(producer, true);
303 if (window == NULL)
304 goto not_valid_surface;
305
306 jint* base = beginNativeAttribList(_env, attrib_list);
307 EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
308 endNativeAttributeList(_env, attrib_list, base);
309 return reinterpret_cast<jlong>(sur);
310 }
311
jni_eglGetConfigAttrib(JNIEnv * _env,jobject _this,jobject display,jobject config,jint attribute,jintArray value)312 static jboolean jni_eglGetConfigAttrib(JNIEnv *_env, jobject _this, jobject display,
313 jobject config, jint attribute, jintArray value) {
314 if (display == NULL || config == NULL
315 || (value == NULL || _env->GetArrayLength(value) < 1)) {
316 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
317 return JNI_FALSE;
318 }
319 EGLDisplay dpy = getDisplay(_env, display);
320 EGLContext cnf = getConfig(_env, config);
321 EGLBoolean success = EGL_FALSE;
322 jint localValue;
323 success = eglGetConfigAttrib(dpy, cnf, attribute, &localValue);
324 if (success) {
325 _env->SetIntArrayRegion(value, 0, 1, &localValue);
326 }
327 return EglBoolToJBool(success);
328 }
329
jni_eglGetConfigs(JNIEnv * _env,jobject _this,jobject display,jobjectArray configs,jint config_size,jintArray num_config)330 static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display,
331 jobjectArray configs, jint config_size, jintArray num_config) {
332 if (display == NULL || (configs != NULL && _env->GetArrayLength(configs) < config_size)
333 || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) {
334 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
335 return JNI_FALSE;
336 }
337 EGLDisplay dpy = getDisplay(_env, display);
338 EGLBoolean success = EGL_FALSE;
339 if (configs == NULL) {
340 config_size = 0;
341 }
342 EGLConfig nativeConfigs[config_size];
343 int num;
344 success = eglGetConfigs(dpy, configs ? nativeConfigs : 0, config_size, &num);
345 if (num_config != NULL) {
346 _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num);
347 }
348 if (success && configs) {
349 for (int i=0 ; i<num ; i++) {
350 jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, reinterpret_cast<jlong>(nativeConfigs[i]));
351 _env->SetObjectArrayElement(configs, i, obj);
352 }
353 }
354 return EglBoolToJBool(success);
355 }
356
jni_eglGetError(JNIEnv * _env,jobject _this)357 static jint jni_eglGetError(JNIEnv *_env, jobject _this) {
358 EGLint error = eglGetError();
359 return error;
360 }
361
jni_eglGetCurrentContext(JNIEnv * _env,jobject _this)362 static jlong jni_eglGetCurrentContext(JNIEnv *_env, jobject _this) {
363 return reinterpret_cast<jlong>(eglGetCurrentContext());
364 }
365
jni_eglGetCurrentDisplay(JNIEnv * _env,jobject _this)366 static jlong jni_eglGetCurrentDisplay(JNIEnv *_env, jobject _this) {
367 return reinterpret_cast<jlong>(eglGetCurrentDisplay());
368 }
369
jni_eglGetCurrentSurface(JNIEnv * _env,jobject _this,jint readdraw)370 static jlong jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) {
371 if ((readdraw != EGL_READ) && (readdraw != EGL_DRAW)) {
372 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
373 return 0;
374 }
375 return reinterpret_cast<jlong>(eglGetCurrentSurface(readdraw));
376 }
377
jni_eglDestroyContext(JNIEnv * _env,jobject _this,jobject display,jobject context)378 static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) {
379 if (display == NULL || context == NULL) {
380 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
381 return JNI_FALSE;
382 }
383 EGLDisplay dpy = getDisplay(_env, display);
384 EGLContext ctx = getContext(_env, context);
385 return EglBoolToJBool(eglDestroyContext(dpy, ctx));
386 }
387
jni_eglDestroySurface(JNIEnv * _env,jobject _this,jobject display,jobject surface)388 static jboolean jni_eglDestroySurface(JNIEnv *_env, jobject _this, jobject display, jobject surface) {
389 if (display == NULL || surface == NULL) {
390 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
391 return JNI_FALSE;
392 }
393 EGLDisplay dpy = getDisplay(_env, display);
394 EGLSurface sur = getSurface(_env, surface);
395 return EglBoolToJBool(eglDestroySurface(dpy, sur));
396 }
397
jni_eglGetDisplay(JNIEnv * _env,jobject _this,jobject native_display)398 static jlong jni_eglGetDisplay(JNIEnv *_env, jobject _this, jobject native_display) {
399 return reinterpret_cast<jlong>(eglGetDisplay(EGL_DEFAULT_DISPLAY));
400 }
401
jni_eglMakeCurrent(JNIEnv * _env,jobject _this,jobject display,jobject draw,jobject read,jobject context)402 static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display, jobject draw, jobject read, jobject context) {
403 if (display == NULL || draw == NULL || read == NULL || context == NULL) {
404 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
405 return JNI_FALSE;
406 }
407 EGLDisplay dpy = getDisplay(_env, display);
408 EGLSurface sdr = getSurface(_env, draw);
409 EGLSurface srd = getSurface(_env, read);
410 EGLContext ctx = getContext(_env, context);
411 return EglBoolToJBool(eglMakeCurrent(dpy, sdr, srd, ctx));
412 }
413
jni_eglQueryString(JNIEnv * _env,jobject _this,jobject display,jint name)414 static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) {
415 if (display == NULL) {
416 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
417 return NULL;
418 }
419 EGLDisplay dpy = getDisplay(_env, display);
420 const char* chars = eglQueryString(dpy, name);
421 return _env->NewStringUTF(chars);
422 }
423
jni_eglSwapBuffers(JNIEnv * _env,jobject _this,jobject display,jobject surface)424 static jboolean jni_eglSwapBuffers(JNIEnv *_env, jobject _this, jobject display, jobject surface) {
425 if (display == NULL || surface == NULL) {
426 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
427 return JNI_FALSE;
428 }
429 EGLDisplay dpy = getDisplay(_env, display);
430 EGLSurface sur = getSurface(_env, surface);
431 return EglBoolToJBool(eglSwapBuffers(dpy, sur));
432 }
433
jni_eglTerminate(JNIEnv * _env,jobject _this,jobject display)434 static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) {
435 if (display == NULL) {
436 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
437 return JNI_FALSE;
438 }
439 EGLDisplay dpy = getDisplay(_env, display);
440 return EglBoolToJBool(eglTerminate(dpy));
441 }
442
jni_eglCopyBuffers(JNIEnv * _env,jobject _this,jobject display,jobject surface,jobject native_pixmap)443 static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display,
444 jobject surface, jobject native_pixmap) {
445 if (display == NULL || surface == NULL || native_pixmap == NULL) {
446 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
447 return JNI_FALSE;
448 }
449 // TODO: Implement this
450 return JNI_FALSE;
451 }
452
jni_eglWaitGL(JNIEnv * _env,jobject _this)453 static jboolean jni_eglWaitGL(JNIEnv *_env, jobject _this) {
454 return EglBoolToJBool(eglWaitGL());
455 }
456
jni_eglWaitNative(JNIEnv * _env,jobject _this,jint engine,jobject bindTarget)457 static jboolean jni_eglWaitNative(JNIEnv *_env, jobject _this, jint engine, jobject bindTarget) {
458 return EglBoolToJBool(eglWaitNative(engine));
459 }
460
461
462 static const char *classPathName = "com/google/android/gles_jni/EGLImpl";
463
464 #define DISPLAY "Ljavax/microedition/khronos/egl/EGLDisplay;"
465 #define CONTEXT "Ljavax/microedition/khronos/egl/EGLContext;"
466 #define CONFIG "Ljavax/microedition/khronos/egl/EGLConfig;"
467 #define SURFACE "Ljavax/microedition/khronos/egl/EGLSurface;"
468 #define OBJECT "Ljava/lang/Object;"
469 #define STRING "Ljava/lang/String;"
470
471 static const JNINativeMethod methods[] = {
472 {"_nativeClassInit","()V", (void*)nativeClassInit },
473 {"eglWaitGL", "()Z", (void*)jni_eglWaitGL },
474 {"eglInitialize", "(" DISPLAY "[I)Z", (void*)jni_eglInitialize },
475 {"eglQueryContext", "(" DISPLAY CONTEXT "I[I)Z", (void*)jni_eglQueryContext },
476 {"eglQuerySurface", "(" DISPLAY SURFACE "I[I)Z", (void*)jni_eglQuerySurface },
477 {"eglReleaseThread","()Z", (void*)jni_eglReleaseThread },
478 {"getInitCount", "(" DISPLAY ")I", (void*)jni_getInitCount },
479 {"eglChooseConfig", "(" DISPLAY "[I[" CONFIG "I[I)Z", (void*)jni_eglChooseConfig },
480 {"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)J", (void*)jni_eglCreateContext },
481 {"eglGetConfigs", "(" DISPLAY "[" CONFIG "I[I)Z", (void*)jni_eglGetConfigs },
482 {"eglTerminate", "(" DISPLAY ")Z", (void*)jni_eglTerminate },
483 {"eglCopyBuffers", "(" DISPLAY SURFACE OBJECT ")Z", (void*)jni_eglCopyBuffers },
484 {"eglWaitNative", "(I" OBJECT ")Z", (void*)jni_eglWaitNative },
485 {"eglGetError", "()I", (void*)jni_eglGetError },
486 {"eglGetConfigAttrib", "(" DISPLAY CONFIG "I[I)Z", (void*)jni_eglGetConfigAttrib },
487 {"_eglGetDisplay", "(" OBJECT ")J", (void*)jni_eglGetDisplay },
488 {"_eglGetCurrentContext", "()J", (void*)jni_eglGetCurrentContext },
489 {"_eglGetCurrentDisplay", "()J", (void*)jni_eglGetCurrentDisplay },
490 {"_eglGetCurrentSurface", "(I)J", (void*)jni_eglGetCurrentSurface },
491 {"_eglCreatePbufferSurface","(" DISPLAY CONFIG "[I)J", (void*)jni_eglCreatePbufferSurface },
492 {"_eglCreatePixmapSurface", "(" SURFACE DISPLAY CONFIG OBJECT "[I)V", (void*)jni_eglCreatePixmapSurface },
493 {"_eglCreateWindowSurface", "(" DISPLAY CONFIG OBJECT "[I)J", (void*)jni_eglCreateWindowSurface },
494 {"_eglCreateWindowSurfaceTexture", "(" DISPLAY CONFIG OBJECT "[I)J", (void*)jni_eglCreateWindowSurfaceTexture },
495 {"eglDestroyContext", "(" DISPLAY CONTEXT ")Z", (void*)jni_eglDestroyContext },
496 {"eglDestroySurface", "(" DISPLAY SURFACE ")Z", (void*)jni_eglDestroySurface },
497 {"eglMakeCurrent", "(" DISPLAY SURFACE SURFACE CONTEXT")Z", (void*)jni_eglMakeCurrent },
498 {"eglQueryString", "(" DISPLAY "I)" STRING, (void*)jni_eglQueryString },
499 {"eglSwapBuffers", "(" DISPLAY SURFACE ")Z", (void*)jni_eglSwapBuffers },
500 };
501
502 } // namespace android
503
register_com_google_android_gles_jni_EGLImpl(JNIEnv * _env)504 int register_com_google_android_gles_jni_EGLImpl(JNIEnv *_env)
505 {
506 int err;
507 err = android::AndroidRuntime::registerNativeMethods(_env,
508 android::classPathName, android::methods, NELEM(android::methods));
509 return err;
510 }
511