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