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 "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 #include <EGL/egl.h> 25 #include <GLES/gl.h> 26 27 #include <EGL/egl_display.h> 28 29 #include <surfaceflinger/Surface.h> 30 #include <SkBitmap.h> 31 #include <SkPixelRef.h> 32 33 #include <gui/SurfaceTexture.h> 34 #include <gui/SurfaceTextureClient.h> 35 36 namespace android { 37 38 static jclass gConfig_class; 39 40 static jmethodID gConfig_ctorID; 41 42 static jfieldID gDisplay_EGLDisplayFieldID; 43 static jfieldID gContext_EGLContextFieldID; 44 static jfieldID gSurface_EGLSurfaceFieldID; 45 static jfieldID gSurface_NativePixelRefFieldID; 46 static jfieldID gConfig_EGLConfigFieldID; 47 static jfieldID gSurface_SurfaceFieldID; 48 static jfieldID gBitmap_NativeBitmapFieldID; 49 50 static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) { 51 if (!o) return EGL_NO_DISPLAY; 52 return (EGLDisplay)env->GetIntField(o, gDisplay_EGLDisplayFieldID); 53 } 54 static inline EGLSurface getSurface(JNIEnv* env, jobject o) { 55 if (!o) return EGL_NO_SURFACE; 56 return (EGLSurface)env->GetIntField(o, gSurface_EGLSurfaceFieldID); 57 } 58 static inline EGLContext getContext(JNIEnv* env, jobject o) { 59 if (!o) return EGL_NO_CONTEXT; 60 return (EGLContext)env->GetIntField(o, gContext_EGLContextFieldID); 61 } 62 static inline EGLConfig getConfig(JNIEnv* env, jobject o) { 63 if (!o) return 0; 64 return (EGLConfig)env->GetIntField(o, gConfig_EGLConfigFieldID); 65 } 66 static void nativeClassInit(JNIEnv *_env, jclass eglImplClass) 67 { 68 jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl"); 69 gConfig_class = (jclass) _env->NewGlobalRef(config_class); 70 gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V"); 71 gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I"); 72 73 jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl"); 74 gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "I"); 75 76 jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl"); 77 gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "I"); 78 79 jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl"); 80 gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "I"); 81 gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "I"); 82 83 jclass bitmap_class = _env->FindClass("android/graphics/Bitmap"); 84 gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "I"); 85 } 86 87 static const jint gNull_attrib_base[] = {EGL_NONE}; 88 89 static bool validAttribList(JNIEnv *_env, jintArray attrib_list) { 90 if (attrib_list == NULL) { 91 return true; 92 } 93 jsize len = _env->GetArrayLength(attrib_list); 94 if (len < 1) { 95 return false; 96 } 97 jint item = 0; 98 _env->GetIntArrayRegion(attrib_list, len-1, 1, &item); 99 return item == EGL_NONE; 100 } 101 102 static jint* beginNativeAttribList(JNIEnv *_env, jintArray attrib_list) { 103 if (attrib_list != NULL) { 104 return (jint *)_env->GetPrimitiveArrayCritical(attrib_list, (jboolean *)0); 105 } else { 106 return(jint*) gNull_attrib_base; 107 } 108 } 109 110 static void endNativeAttributeList(JNIEnv *_env, jintArray attrib_list, jint* attrib_base) { 111 if (attrib_list != NULL) { 112 _env->ReleasePrimitiveArrayCritical(attrib_list, attrib_base, JNI_ABORT); 113 } 114 } 115 116 static jboolean jni_eglInitialize(JNIEnv *_env, jobject _this, jobject display, 117 jintArray major_minor) { 118 if (display == NULL || (major_minor != NULL && 119 _env->GetArrayLength(major_minor) < 2)) { 120 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 121 return JNI_FALSE; 122 } 123 124 EGLDisplay dpy = getDisplay(_env, display); 125 jboolean success = eglInitialize(dpy, NULL, NULL); 126 if (success && major_minor) { 127 int len = _env->GetArrayLength(major_minor); 128 if (len) { 129 // we're exposing only EGL 1.0 130 jint* base = (jint *)_env->GetPrimitiveArrayCritical(major_minor, (jboolean *)0); 131 if (len >= 1) base[0] = 1; 132 if (len >= 2) base[1] = 0; 133 _env->ReleasePrimitiveArrayCritical(major_minor, base, JNI_ABORT); 134 } 135 } 136 return success; 137 } 138 139 static jboolean jni_eglQueryContext(JNIEnv *_env, jobject _this, jobject display, 140 jobject context, jint attribute, jintArray value) { 141 if (display == NULL || context == NULL || value == NULL 142 || _env->GetArrayLength(value) < 1) { 143 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 144 return JNI_FALSE; 145 } 146 EGLDisplay dpy = getDisplay(_env, display); 147 EGLContext ctx = getContext(_env, context); 148 jboolean success = JNI_FALSE; 149 int len = _env->GetArrayLength(value); 150 if (len) { 151 jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0); 152 success = eglQueryContext(dpy, ctx, attribute, base); 153 _env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT); 154 } 155 return success; 156 } 157 158 static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display, 159 jobject surface, jint attribute, jintArray value) { 160 if (display == NULL || surface == NULL || value == NULL 161 || _env->GetArrayLength(value) < 1) { 162 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 163 return JNI_FALSE; 164 } 165 EGLDisplay dpy = getDisplay(_env, display); 166 EGLContext sur = getSurface(_env, surface); 167 168 jboolean success = JNI_FALSE; 169 int len = _env->GetArrayLength(value); 170 if (len) { 171 jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0); 172 success = eglQuerySurface(dpy, sur, attribute, base); 173 _env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT); 174 } 175 return success; 176 } 177 178 static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) { 179 EGLDisplay dpy = getDisplay(_env, display); 180 egl_display_t* eglDisplay = get_display(dpy); 181 return eglDisplay ? eglDisplay->getRefsCount() : 0; 182 } 183 184 static jboolean jni_eglReleaseThread(JNIEnv *_env, jobject _this) { 185 return eglReleaseThread(); 186 } 187 188 static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display, 189 jintArray attrib_list, jobjectArray configs, jint config_size, jintArray num_config) { 190 if (display == NULL 191 || !validAttribList(_env, attrib_list) 192 || (configs != NULL && _env->GetArrayLength(configs) < config_size) 193 || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) { 194 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 195 return JNI_FALSE; 196 } 197 EGLDisplay dpy = getDisplay(_env, display); 198 jboolean success = JNI_FALSE; 199 200 if (configs == NULL) { 201 config_size = 0; 202 } 203 EGLConfig nativeConfigs[config_size]; 204 205 int num = 0; 206 jint* attrib_base = beginNativeAttribList(_env, attrib_list); 207 success = eglChooseConfig(dpy, attrib_base, configs ? nativeConfigs : 0, config_size, &num); 208 endNativeAttributeList(_env, attrib_list, attrib_base); 209 210 if (num_config != NULL) { 211 _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num); 212 } 213 214 if (success && configs!=NULL) { 215 for (int i=0 ; i<num ; i++) { 216 jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]); 217 _env->SetObjectArrayElement(configs, i, obj); 218 } 219 } 220 return success; 221 } 222 223 static jint jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display, 224 jobject config, jobject share_context, jintArray attrib_list) { 225 if (display == NULL || config == NULL || share_context == NULL 226 || !validAttribList(_env, attrib_list)) { 227 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 228 return JNI_FALSE; 229 } 230 EGLDisplay dpy = getDisplay(_env, display); 231 EGLConfig cnf = getConfig(_env, config); 232 EGLContext shr = getContext(_env, share_context); 233 jint* base = beginNativeAttribList(_env, attrib_list); 234 EGLContext ctx = eglCreateContext(dpy, cnf, shr, base); 235 endNativeAttributeList(_env, attrib_list, base); 236 return (jint)ctx; 237 } 238 239 static jint jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display, 240 jobject config, jintArray attrib_list) { 241 if (display == NULL || config == NULL 242 || !validAttribList(_env, attrib_list)) { 243 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 244 return JNI_FALSE; 245 } 246 EGLDisplay dpy = getDisplay(_env, display); 247 EGLConfig cnf = getConfig(_env, config); 248 jint* base = beginNativeAttribList(_env, attrib_list); 249 EGLSurface sur = eglCreatePbufferSurface(dpy, cnf, base); 250 endNativeAttributeList(_env, attrib_list, base); 251 return (jint)sur; 252 } 253 254 static PixelFormat convertPixelFormat(SkBitmap::Config format) 255 { 256 switch (format) { 257 case SkBitmap::kARGB_8888_Config: return PIXEL_FORMAT_RGBA_8888; 258 case SkBitmap::kARGB_4444_Config: return PIXEL_FORMAT_RGBA_4444; 259 case SkBitmap::kRGB_565_Config: return PIXEL_FORMAT_RGB_565; 260 case SkBitmap::kA8_Config: return PIXEL_FORMAT_A_8; 261 default: return PIXEL_FORMAT_NONE; 262 } 263 } 264 265 static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_sur, 266 jobject display, jobject config, jobject native_pixmap, 267 jintArray attrib_list) 268 { 269 if (display == NULL || config == NULL || native_pixmap == NULL 270 || !validAttribList(_env, attrib_list)) { 271 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 272 return; 273 } 274 EGLDisplay dpy = getDisplay(_env, display); 275 EGLConfig cnf = getConfig(_env, config); 276 jint* base = 0; 277 278 SkBitmap const * nativeBitmap = 279 (SkBitmap const *)_env->GetIntField(native_pixmap, 280 gBitmap_NativeBitmapFieldID); 281 SkPixelRef* ref = nativeBitmap ? nativeBitmap->pixelRef() : 0; 282 if (ref == NULL) { 283 jniThrowException(_env, "java/lang/IllegalArgumentException", "Bitmap has no PixelRef"); 284 return; 285 } 286 287 SkSafeRef(ref); 288 ref->lockPixels(); 289 290 egl_native_pixmap_t pixmap; 291 pixmap.version = sizeof(pixmap); 292 pixmap.width = nativeBitmap->width(); 293 pixmap.height = nativeBitmap->height(); 294 pixmap.stride = nativeBitmap->rowBytes() / nativeBitmap->bytesPerPixel(); 295 pixmap.format = convertPixelFormat(nativeBitmap->config()); 296 pixmap.data = (uint8_t*)ref->pixels(); 297 298 base = beginNativeAttribList(_env, attrib_list); 299 EGLSurface sur = eglCreatePixmapSurface(dpy, cnf, &pixmap, base); 300 endNativeAttributeList(_env, attrib_list, base); 301 302 if (sur != EGL_NO_SURFACE) { 303 _env->SetIntField(out_sur, gSurface_EGLSurfaceFieldID, (int)sur); 304 _env->SetIntField(out_sur, gSurface_NativePixelRefFieldID, (int)ref); 305 } else { 306 ref->unlockPixels(); 307 SkSafeUnref(ref); 308 } 309 } 310 311 static jint jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display, 312 jobject config, jobject native_window, jintArray attrib_list) { 313 if (display == NULL || config == NULL 314 || !validAttribList(_env, attrib_list)) { 315 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 316 return JNI_FALSE; 317 } 318 EGLDisplay dpy = getDisplay(_env, display); 319 EGLContext cnf = getConfig(_env, config); 320 sp<ANativeWindow> window; 321 if (native_window == NULL) { 322 not_valid_surface: 323 jniThrowException(_env, "java/lang/IllegalArgumentException", 324 "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"); 325 return 0; 326 } 327 328 window = android_Surface_getNativeWindow(_env, native_window); 329 if (window == NULL) 330 goto not_valid_surface; 331 332 jint* base = beginNativeAttribList(_env, attrib_list); 333 EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base); 334 endNativeAttributeList(_env, attrib_list, base); 335 return (jint)sur; 336 } 337 338 static jint jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display, 339 jobject config, jobject native_window, jintArray attrib_list) { 340 if (display == NULL || config == NULL 341 || !validAttribList(_env, attrib_list)) { 342 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 343 return JNI_FALSE; 344 } 345 EGLDisplay dpy = getDisplay(_env, display); 346 EGLContext cnf = getConfig(_env, config); 347 sp<ANativeWindow> window; 348 if (native_window == 0) { 349 not_valid_surface: 350 jniThrowException(_env, "java/lang/IllegalArgumentException", 351 "Make sure the SurfaceTexture is valid"); 352 return 0; 353 } 354 355 sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(_env, native_window)); 356 357 window = new SurfaceTextureClient(surfaceTexture); 358 if (window == NULL) 359 goto not_valid_surface; 360 361 jint* base = beginNativeAttribList(_env, attrib_list); 362 EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base); 363 endNativeAttributeList(_env, attrib_list, base); 364 return (jint)sur; 365 } 366 367 static jboolean jni_eglGetConfigAttrib(JNIEnv *_env, jobject _this, jobject display, 368 jobject config, jint attribute, jintArray value) { 369 if (display == NULL || config == NULL 370 || (value == NULL || _env->GetArrayLength(value) < 1)) { 371 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 372 return JNI_FALSE; 373 } 374 EGLDisplay dpy = getDisplay(_env, display); 375 EGLContext cnf = getConfig(_env, config); 376 jboolean success = JNI_FALSE; 377 jint localValue; 378 success = eglGetConfigAttrib(dpy, cnf, attribute, &localValue); 379 if (success) { 380 _env->SetIntArrayRegion(value, 0, 1, &localValue); 381 } 382 return success; 383 } 384 385 static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display, 386 jobjectArray configs, jint config_size, jintArray num_config) { 387 if (display == NULL || (configs != NULL && _env->GetArrayLength(configs) < config_size) 388 || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) { 389 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 390 return JNI_FALSE; 391 } 392 EGLDisplay dpy = getDisplay(_env, display); 393 jboolean success = JNI_FALSE; 394 if (configs == NULL) { 395 config_size = 0; 396 } 397 EGLConfig nativeConfigs[config_size]; 398 int num; 399 success = eglGetConfigs(dpy, configs ? nativeConfigs : 0, config_size, &num); 400 if (num_config != NULL) { 401 _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num); 402 } 403 if (success && configs) { 404 for (int i=0 ; i<num ; i++) { 405 jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]); 406 _env->SetObjectArrayElement(configs, i, obj); 407 } 408 } 409 return success; 410 } 411 412 static jint jni_eglGetError(JNIEnv *_env, jobject _this) { 413 EGLint error = eglGetError(); 414 return error; 415 } 416 417 static jint jni_eglGetCurrentContext(JNIEnv *_env, jobject _this) { 418 return (jint)eglGetCurrentContext(); 419 } 420 421 static jint jni_eglGetCurrentDisplay(JNIEnv *_env, jobject _this) { 422 return (jint)eglGetCurrentDisplay(); 423 } 424 425 static jint jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) { 426 if ((readdraw != EGL_READ) && (readdraw != EGL_DRAW)) { 427 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 428 return 0; 429 } 430 return (jint)eglGetCurrentSurface(readdraw); 431 } 432 433 static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) { 434 if (display == NULL || context == NULL) { 435 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 436 return JNI_FALSE; 437 } 438 EGLDisplay dpy = getDisplay(_env, display); 439 EGLContext ctx = getContext(_env, context); 440 return eglDestroyContext(dpy, ctx); 441 } 442 443 static jboolean jni_eglDestroySurface(JNIEnv *_env, jobject _this, jobject display, jobject surface) { 444 if (display == NULL || surface == NULL) { 445 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 446 return JNI_FALSE; 447 } 448 EGLDisplay dpy = getDisplay(_env, display); 449 EGLSurface sur = getSurface(_env, surface); 450 451 if (sur) { 452 SkPixelRef* ref = (SkPixelRef*)(_env->GetIntField(surface, 453 gSurface_NativePixelRefFieldID)); 454 if (ref) { 455 ref->unlockPixels(); 456 SkSafeUnref(ref); 457 } 458 } 459 return eglDestroySurface(dpy, sur); 460 } 461 462 static jint jni_eglGetDisplay(JNIEnv *_env, jobject _this, jobject native_display) { 463 return (jint)eglGetDisplay(EGL_DEFAULT_DISPLAY); 464 } 465 466 static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display, jobject draw, jobject read, jobject context) { 467 if (display == NULL || draw == NULL || read == NULL || context == NULL) { 468 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 469 return JNI_FALSE; 470 } 471 EGLDisplay dpy = getDisplay(_env, display); 472 EGLSurface sdr = getSurface(_env, draw); 473 EGLSurface srd = getSurface(_env, read); 474 EGLContext ctx = getContext(_env, context); 475 return eglMakeCurrent(dpy, sdr, srd, ctx); 476 } 477 478 static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) { 479 if (display == NULL) { 480 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 481 return NULL; 482 } 483 EGLDisplay dpy = getDisplay(_env, display); 484 const char* chars = eglQueryString(dpy, name); 485 return _env->NewStringUTF(chars); 486 } 487 488 static jboolean jni_eglSwapBuffers(JNIEnv *_env, jobject _this, jobject display, jobject surface) { 489 if (display == NULL || surface == NULL) { 490 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 491 return JNI_FALSE; 492 } 493 EGLDisplay dpy = getDisplay(_env, display); 494 EGLSurface sur = getSurface(_env, surface); 495 return eglSwapBuffers(dpy, sur); 496 } 497 498 static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) { 499 if (display == NULL) { 500 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 501 return JNI_FALSE; 502 } 503 EGLDisplay dpy = getDisplay(_env, display); 504 return eglTerminate(dpy); 505 } 506 507 static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display, 508 jobject surface, jobject native_pixmap) { 509 if (display == NULL || surface == NULL || native_pixmap == NULL) { 510 jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); 511 return JNI_FALSE; 512 } 513 // TODO: Implement this 514 return JNI_FALSE; 515 } 516 517 static jboolean jni_eglWaitGL(JNIEnv *_env, jobject _this) { 518 return eglWaitGL(); 519 } 520 521 static jboolean jni_eglWaitNative(JNIEnv *_env, jobject _this, jint engine, jobject bindTarget) { 522 return eglWaitNative(engine); 523 } 524 525 526 static const char *classPathName = "com/google/android/gles_jni/EGLImpl"; 527 528 #define DISPLAY "Ljavax/microedition/khronos/egl/EGLDisplay;" 529 #define CONTEXT "Ljavax/microedition/khronos/egl/EGLContext;" 530 #define CONFIG "Ljavax/microedition/khronos/egl/EGLConfig;" 531 #define SURFACE "Ljavax/microedition/khronos/egl/EGLSurface;" 532 #define OBJECT "Ljava/lang/Object;" 533 #define STRING "Ljava/lang/String;" 534 535 static JNINativeMethod methods[] = { 536 {"_nativeClassInit","()V", (void*)nativeClassInit }, 537 {"eglWaitGL", "()Z", (void*)jni_eglWaitGL }, 538 {"eglInitialize", "(" DISPLAY "[I)Z", (void*)jni_eglInitialize }, 539 {"eglQueryContext", "(" DISPLAY CONTEXT "I[I)Z", (void*)jni_eglQueryContext }, 540 {"eglQuerySurface", "(" DISPLAY SURFACE "I[I)Z", (void*)jni_eglQuerySurface }, 541 {"eglReleaseThread","()Z", (void*)jni_eglReleaseThread }, 542 {"getInitCount", "(" DISPLAY ")I", (void*)jni_getInitCount }, 543 {"eglChooseConfig", "(" DISPLAY "[I[" CONFIG "I[I)Z", (void*)jni_eglChooseConfig }, 544 {"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)I", (void*)jni_eglCreateContext }, 545 {"eglGetConfigs", "(" DISPLAY "[" CONFIG "I[I)Z", (void*)jni_eglGetConfigs }, 546 {"eglTerminate", "(" DISPLAY ")Z", (void*)jni_eglTerminate }, 547 {"eglCopyBuffers", "(" DISPLAY SURFACE OBJECT ")Z", (void*)jni_eglCopyBuffers }, 548 {"eglWaitNative", "(I" OBJECT ")Z", (void*)jni_eglWaitNative }, 549 {"eglGetError", "()I", (void*)jni_eglGetError }, 550 {"eglGetConfigAttrib", "(" DISPLAY CONFIG "I[I)Z", (void*)jni_eglGetConfigAttrib }, 551 {"_eglGetDisplay", "(" OBJECT ")I", (void*)jni_eglGetDisplay }, 552 {"_eglGetCurrentContext", "()I", (void*)jni_eglGetCurrentContext }, 553 {"_eglGetCurrentDisplay", "()I", (void*)jni_eglGetCurrentDisplay }, 554 {"_eglGetCurrentSurface", "(I)I", (void*)jni_eglGetCurrentSurface }, 555 {"_eglCreatePbufferSurface","(" DISPLAY CONFIG "[I)I", (void*)jni_eglCreatePbufferSurface }, 556 {"_eglCreatePixmapSurface", "(" SURFACE DISPLAY CONFIG OBJECT "[I)V", (void*)jni_eglCreatePixmapSurface }, 557 {"_eglCreateWindowSurface", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurface }, 558 {"_eglCreateWindowSurfaceTexture", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurfaceTexture }, 559 {"eglDestroyContext", "(" DISPLAY CONTEXT ")Z", (void*)jni_eglDestroyContext }, 560 {"eglDestroySurface", "(" DISPLAY SURFACE ")Z", (void*)jni_eglDestroySurface }, 561 {"eglMakeCurrent", "(" DISPLAY SURFACE SURFACE CONTEXT")Z", (void*)jni_eglMakeCurrent }, 562 {"eglQueryString", "(" DISPLAY "I)" STRING, (void*)jni_eglQueryString }, 563 {"eglSwapBuffers", "(" DISPLAY SURFACE ")Z", (void*)jni_eglSwapBuffers }, 564 }; 565 566 } // namespace android 567 568 int register_com_google_android_gles_jni_EGLImpl(JNIEnv *_env) 569 { 570 int err; 571 err = android::AndroidRuntime::registerNativeMethods(_env, 572 android::classPathName, android::methods, NELEM(android::methods)); 573 return err; 574 } 575