android_opengl_EGL14.cpp revision 82bb813f112d9565faa990e32dbe833f96461892
1/* 2** 3** Copyright 2012, 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// This source file is automatically generated 19 20#include "jni.h" 21#include "JNIHelp.h" 22#include <android_runtime/AndroidRuntime.h> 23#include <android_runtime/android_view_Surface.h> 24#include <android_runtime/android_graphics_SurfaceTexture.h> 25#include <utils/misc.h> 26 27#include <assert.h> 28#include <EGL/egl.h> 29 30#include <gui/Surface.h> 31#include <gui/SurfaceTexture.h> 32#include <gui/SurfaceTextureClient.h> 33 34#include <ui/ANativeObjectBase.h> 35 36static int initialized = 0; 37 38static jclass egldisplayClass; 39static jclass eglcontextClass; 40static jclass eglsurfaceClass; 41static jclass eglconfigClass; 42 43static jmethodID egldisplayGetHandleID; 44static jmethodID eglcontextGetHandleID; 45static jmethodID eglsurfaceGetHandleID; 46static jmethodID eglconfigGetHandleID; 47 48static jmethodID egldisplayConstructor; 49static jmethodID eglcontextConstructor; 50static jmethodID eglsurfaceConstructor; 51static jmethodID eglconfigConstructor; 52 53static jobject eglNoContextObject; 54static jobject eglNoDisplayObject; 55static jobject eglNoSurfaceObject; 56 57 58 59/* Cache method IDs each time the class is loaded. */ 60 61static void 62nativeClassInit(JNIEnv *_env, jclass glImplClass) 63{ 64 jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay"); 65 egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal); 66 jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext"); 67 eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal); 68 jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface"); 69 eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal); 70 jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig"); 71 eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal); 72 73 egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I"); 74 eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I"); 75 eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I"); 76 eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I"); 77 78 79 egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V"); 80 eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V"); 81 eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V"); 82 eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V"); 83 84 jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT); 85 eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject); 86 jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY); 87 eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject); 88 jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE); 89 eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject); 90 91 92 jclass eglClass = _env->FindClass("android/opengl/EGL14"); 93 jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;"); 94 _env->SetStaticObjectField(eglClass, noContextFieldID, eglNoContextObject); 95 96 jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;"); 97 _env->SetStaticObjectField(eglClass, noDisplayFieldID, eglNoDisplayObject); 98 99 jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;"); 100 _env->SetStaticObjectField(eglClass, noSurfaceFieldID, eglNoSurfaceObject); 101} 102 103static void * 104fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) { 105 if (obj == NULL){ 106 jniThrowException(_env, "java/lang/IllegalArgumentException", 107 "Object is set to null."); 108 } 109 110 return (void*) (_env->CallIntMethod(obj, mid)); 111} 112 113static jobject 114toEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) { 115 if (cls == eglcontextClass && 116 (EGLContext)handle == EGL_NO_CONTEXT) { 117 return eglNoContextObject; 118 } 119 120 if (cls == egldisplayClass && 121 (EGLDisplay)handle == EGL_NO_DISPLAY) { 122 return eglNoDisplayObject; 123 } 124 125 if (cls == eglsurfaceClass && 126 (EGLSurface)handle == EGL_NO_SURFACE) { 127 return eglNoSurfaceObject; 128 } 129 130 return _env->NewObject(cls, con, (jint)handle); 131} 132 133// -------------------------------------------------------------------------- 134/* EGLint eglGetError ( void ) */ 135static jint 136android_eglGetError 137 (JNIEnv *_env, jobject _this) { 138 EGLint _returnValue = (EGLint) 0; 139 _returnValue = eglGetError(); 140 return _returnValue; 141} 142 143/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */ 144static jobject 145android_eglGetDisplay 146 (JNIEnv *_env, jobject _this, jint display_id) { 147 EGLDisplay _returnValue = (EGLDisplay) 0; 148 _returnValue = eglGetDisplay( 149 (EGLNativeDisplayType)display_id 150 ); 151 return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue); 152} 153 154/* EGLBoolean eglInitialize ( EGLDisplay dpy, EGLint *major, EGLint *minor ) */ 155static jboolean 156android_eglInitialize 157 (JNIEnv *_env, jobject _this, jobject dpy, jintArray major_ref, jint majorOffset, jintArray minor_ref, jint minorOffset) { 158 jint _exception = 0; 159 const char * _exceptionType; 160 const char * _exceptionMessage; 161 EGLBoolean _returnValue = (EGLBoolean) 0; 162 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 163 EGLint *major_base = (EGLint *) 0; 164 jint _majorRemaining; 165 EGLint *major = (EGLint *) 0; 166 EGLint *minor_base = (EGLint *) 0; 167 jint _minorRemaining; 168 EGLint *minor = (EGLint *) 0; 169 170 if (!major_ref) { 171 _exception = 1; 172 _exceptionType = "java/lang/IllegalArgumentException"; 173 _exceptionMessage = "major == null"; 174 goto exit; 175 } 176 if (majorOffset < 0) { 177 _exception = 1; 178 _exceptionType = "java/lang/IllegalArgumentException"; 179 _exceptionMessage = "majorOffset < 0"; 180 goto exit; 181 } 182 _majorRemaining = _env->GetArrayLength(major_ref) - majorOffset; 183 if (_majorRemaining < 1) { 184 _exception = 1; 185 _exceptionType = "java/lang/IllegalArgumentException"; 186 _exceptionMessage = "length - majorOffset < 1 < needed"; 187 goto exit; 188 } 189 major_base = (EGLint *) 190 _env->GetPrimitiveArrayCritical(major_ref, (jboolean *)0); 191 major = major_base + majorOffset; 192 193 if (!minor_ref) { 194 _exception = 1; 195 _exceptionType = "java/lang/IllegalArgumentException"; 196 _exceptionMessage = "minor == null"; 197 goto exit; 198 } 199 if (minorOffset < 0) { 200 _exception = 1; 201 _exceptionType = "java/lang/IllegalArgumentException"; 202 _exceptionMessage = "minorOffset < 0"; 203 goto exit; 204 } 205 _minorRemaining = _env->GetArrayLength(minor_ref) - minorOffset; 206 if (_minorRemaining < 1) { 207 _exception = 1; 208 _exceptionType = "java/lang/IllegalArgumentException"; 209 _exceptionMessage = "length - minorOffset < 1 < needed"; 210 goto exit; 211 } 212 minor_base = (EGLint *) 213 _env->GetPrimitiveArrayCritical(minor_ref, (jboolean *)0); 214 minor = minor_base + minorOffset; 215 216 _returnValue = eglInitialize( 217 (EGLDisplay)dpy_native, 218 (EGLint *)major, 219 (EGLint *)minor 220 ); 221 222exit: 223 if (minor_base) { 224 _env->ReleasePrimitiveArrayCritical(minor_ref, minor_base, 225 _exception ? JNI_ABORT: 0); 226 } 227 if (major_base) { 228 _env->ReleasePrimitiveArrayCritical(major_ref, major_base, 229 _exception ? JNI_ABORT: 0); 230 } 231 if (_exception) { 232 jniThrowException(_env, _exceptionType, _exceptionMessage); 233 } 234 return _returnValue; 235} 236 237/* EGLBoolean eglTerminate ( EGLDisplay dpy ) */ 238static jboolean 239android_eglTerminate 240 (JNIEnv *_env, jobject _this, jobject dpy) { 241 EGLBoolean _returnValue = (EGLBoolean) 0; 242 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 243 244 _returnValue = eglTerminate( 245 (EGLDisplay)dpy_native 246 ); 247 return _returnValue; 248} 249 250/* const char * eglQueryString ( EGLDisplay dpy, EGLint name ) */ 251static jstring 252android_eglQueryString__Landroind_opengl_EGLDisplay_2I 253 (JNIEnv *_env, jobject _this, jobject dpy, jint name) { 254 const char* chars = (const char*) eglQueryString( 255 (EGLDisplay)fromEGLHandle(_env, egldisplayGetHandleID, dpy), 256 (EGLint)name 257 ); 258 return _env->NewStringUTF(chars); 259} 260/* EGLBoolean eglGetConfigs ( EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */ 261static jboolean 262android_eglGetConfigs 263 (JNIEnv *_env, jobject _this, jobject dpy, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) { 264 jint _exception = 0; 265 const char * _exceptionType; 266 const char * _exceptionMessage; 267 EGLBoolean _returnValue = (EGLBoolean) 0; 268 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 269 jint _configsRemaining; 270 EGLConfig *configs = (EGLConfig *) 0; 271 EGLint *num_config_base = (EGLint *) 0; 272 jint _num_configRemaining; 273 EGLint *num_config = (EGLint *) 0; 274 275 if (!configs_ref) { 276 _exception = 1; 277 _exceptionType = "java/lang/IllegalArgumentException"; 278 _exceptionMessage = "configs == null"; 279 goto exit; 280 } 281 if (configsOffset < 0) { 282 _exception = 1; 283 _exceptionType = "java/lang/IllegalArgumentException"; 284 _exceptionMessage = "configsOffset < 0"; 285 goto exit; 286 } 287 _configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset; 288 if (_configsRemaining < config_size) { 289 _exception = 1; 290 _exceptionType = "java/lang/IllegalArgumentException"; 291 _exceptionMessage = "length - configsOffset < config_size < needed"; 292 goto exit; 293 } 294 configs = new EGLConfig[_configsRemaining]; 295 296 if (!num_config_ref) { 297 _exception = 1; 298 _exceptionType = "java/lang/IllegalArgumentException"; 299 _exceptionMessage = "num_config == null"; 300 goto exit; 301 } 302 if (num_configOffset < 0) { 303 _exception = 1; 304 _exceptionType = "java/lang/IllegalArgumentException"; 305 _exceptionMessage = "num_configOffset < 0"; 306 goto exit; 307 } 308 _num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset; 309 num_config_base = (EGLint *) 310 _env->GetPrimitiveArrayCritical(num_config_ref, (jboolean *)0); 311 num_config = num_config_base + num_configOffset; 312 313 _returnValue = eglGetConfigs( 314 (EGLDisplay)dpy_native, 315 (EGLConfig *)configs, 316 (EGLint)config_size, 317 (EGLint *)num_config 318 ); 319 320exit: 321 if (num_config_base) { 322 _env->ReleasePrimitiveArrayCritical(num_config_ref, num_config_base, 323 _exception ? JNI_ABORT: 0); 324 } 325 if (configs) { 326 for (int i = 0; i < _configsRemaining; i++) { 327 jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]); 328 _env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new); 329 } 330 delete[] configs; 331 } 332 if (_exception) { 333 jniThrowException(_env, _exceptionType, _exceptionMessage); 334 } 335 return _returnValue; 336} 337 338/* EGLBoolean eglChooseConfig ( EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */ 339static jboolean 340android_eglChooseConfig 341 (JNIEnv *_env, jobject _this, jobject dpy, jintArray attrib_list_ref, jint attrib_listOffset, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) { 342 jint _exception = 0; 343 const char * _exceptionType; 344 const char * _exceptionMessage; 345 EGLBoolean _returnValue = (EGLBoolean) 0; 346 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 347 bool attrib_list_sentinel = false; 348 EGLint *attrib_list_base = (EGLint *) 0; 349 jint _attrib_listRemaining; 350 EGLint *attrib_list = (EGLint *) 0; 351 jint _configsRemaining; 352 EGLConfig *configs = (EGLConfig *) 0; 353 EGLint *num_config_base = (EGLint *) 0; 354 jint _num_configRemaining; 355 EGLint *num_config = (EGLint *) 0; 356 357 if (!attrib_list_ref) { 358 _exception = 1; 359 _exceptionType = "java/lang/IllegalArgumentException"; 360 _exceptionMessage = "attrib_list == null"; 361 goto exit; 362 } 363 if (attrib_listOffset < 0) { 364 _exception = 1; 365 _exceptionType = "java/lang/IllegalArgumentException"; 366 _exceptionMessage = "attrib_listOffset < 0"; 367 goto exit; 368 } 369 _attrib_listRemaining = _env->GetArrayLength(attrib_list_ref) - attrib_listOffset; 370 attrib_list_base = (EGLint *) 371 _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 372 attrib_list = attrib_list_base + attrib_listOffset; 373 attrib_list_sentinel = false; 374 for (int i = _attrib_listRemaining - 1; i >= 0; i--) { 375 if (attrib_list[i] == EGL_NONE){ 376 attrib_list_sentinel = true; 377 break; 378 } 379 } 380 if (attrib_list_sentinel == false) { 381 _exception = 1; 382 _exceptionType = "java/lang/IllegalArgumentException"; 383 _exceptionMessage = "attrib_list must contain EGL_NONE!"; 384 goto exit; 385 } 386 387 if (!configs_ref) { 388 _exception = 1; 389 _exceptionType = "java/lang/IllegalArgumentException"; 390 _exceptionMessage = "configs == null"; 391 goto exit; 392 } 393 if (configsOffset < 0) { 394 _exception = 1; 395 _exceptionType = "java/lang/IllegalArgumentException"; 396 _exceptionMessage = "configsOffset < 0"; 397 goto exit; 398 } 399 _configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset; 400 if (_configsRemaining < config_size) { 401 _exception = 1; 402 _exceptionType = "java/lang/IllegalArgumentException"; 403 _exceptionMessage = "length - configsOffset < config_size < needed"; 404 goto exit; 405 } 406 configs = new EGLConfig[_configsRemaining]; 407 408 if (!num_config_ref) { 409 _exception = 1; 410 _exceptionType = "java/lang/IllegalArgumentException"; 411 _exceptionMessage = "num_config == null"; 412 goto exit; 413 } 414 if (num_configOffset < 0) { 415 _exception = 1; 416 _exceptionType = "java/lang/IllegalArgumentException"; 417 _exceptionMessage = "num_configOffset < 0"; 418 goto exit; 419 } 420 _num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset; 421 if (_num_configRemaining < 1) { 422 _exception = 1; 423 _exceptionType = "java/lang/IllegalArgumentException"; 424 _exceptionMessage = "length - num_configOffset < 1 < needed"; 425 goto exit; 426 } 427 num_config_base = (EGLint *) 428 _env->GetPrimitiveArrayCritical(num_config_ref, (jboolean *)0); 429 num_config = num_config_base + num_configOffset; 430 431 _returnValue = eglChooseConfig( 432 (EGLDisplay)dpy_native, 433 (EGLint *)attrib_list, 434 (EGLConfig *)configs, 435 (EGLint)config_size, 436 (EGLint *)num_config 437 ); 438 439exit: 440 if (num_config_base) { 441 _env->ReleasePrimitiveArrayCritical(num_config_ref, num_config_base, 442 _exception ? JNI_ABORT: 0); 443 } 444 if (attrib_list_base) { 445 _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 446 JNI_ABORT); 447 } 448 if (configs) { 449 for (int i = 0; i < _configsRemaining; i++) { 450 jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]); 451 _env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new); 452 } 453 delete[] configs; 454 } 455 if (_exception) { 456 jniThrowException(_env, _exceptionType, _exceptionMessage); 457 } 458 return _returnValue; 459} 460 461/* EGLBoolean eglGetConfigAttrib ( EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value ) */ 462static jboolean 463android_eglGetConfigAttrib 464 (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint attribute, jintArray value_ref, jint offset) { 465 jint _exception = 0; 466 const char * _exceptionType; 467 const char * _exceptionMessage; 468 EGLBoolean _returnValue = (EGLBoolean) 0; 469 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 470 EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 471 EGLint *value_base = (EGLint *) 0; 472 jint _remaining; 473 EGLint *value = (EGLint *) 0; 474 475 if (!value_ref) { 476 _exception = 1; 477 _exceptionType = "java/lang/IllegalArgumentException"; 478 _exceptionMessage = "value == null"; 479 goto exit; 480 } 481 if (offset < 0) { 482 _exception = 1; 483 _exceptionType = "java/lang/IllegalArgumentException"; 484 _exceptionMessage = "offset < 0"; 485 goto exit; 486 } 487 _remaining = _env->GetArrayLength(value_ref) - offset; 488 if (_remaining < 1) { 489 _exception = 1; 490 _exceptionType = "java/lang/IllegalArgumentException"; 491 _exceptionMessage = "length - offset < 1 < needed"; 492 goto exit; 493 } 494 value_base = (EGLint *) 495 _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0); 496 value = value_base + offset; 497 498 _returnValue = eglGetConfigAttrib( 499 (EGLDisplay)dpy_native, 500 (EGLConfig)config_native, 501 (EGLint)attribute, 502 (EGLint *)value 503 ); 504 505exit: 506 if (value_base) { 507 _env->ReleasePrimitiveArrayCritical(value_ref, value_base, 508 _exception ? JNI_ABORT: 0); 509 } 510 if (_exception) { 511 jniThrowException(_env, _exceptionType, _exceptionMessage); 512 } 513 return _returnValue; 514} 515 516/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */ 517static jobject 518android_eglCreateWindowSurface 519 (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) { 520 jint _exception = 0; 521 const char * _exceptionType = ""; 522 const char * _exceptionMessage = ""; 523 EGLSurface _returnValue = (EGLSurface) 0; 524 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 525 EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 526 int attrib_list_sentinel = 0; 527 EGLint *attrib_list_base = (EGLint *) 0; 528 jint _remaining; 529 EGLint *attrib_list = (EGLint *) 0; 530 android::sp<ANativeWindow> window; 531 532 if (!attrib_list_ref) { 533 _exception = 1; 534 _exceptionType = "java/lang/IllegalArgumentException"; 535 _exceptionMessage = "attrib_list == null"; 536 goto exit; 537 } 538 if (offset < 0) { 539 _exception = 1; 540 _exceptionType = "java/lang/IllegalArgumentException"; 541 _exceptionMessage = "offset < 0"; 542 goto exit; 543 } 544 if (win == NULL) { 545not_valid_surface: 546 _exception = 1; 547 _exceptionType = "java/lang/IllegalArgumentException"; 548 _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"; 549 goto exit; 550 } 551 552 window = android::android_view_Surface_getNativeWindow(_env, win); 553 554 if (window == NULL) 555 goto not_valid_surface; 556 557 _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 558 attrib_list_base = (EGLint *) 559 _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 560 attrib_list = attrib_list_base + offset; 561 attrib_list_sentinel = 0; 562 for (int i = _remaining - 1; i >= 0; i--) { 563 if (*((EGLint*)(attrib_list + i)) == EGL_NONE){ 564 attrib_list_sentinel = 1; 565 break; 566 } 567 } 568 if (attrib_list_sentinel == 0) { 569 _exception = 1; 570 _exceptionType = "java/lang/IllegalArgumentException"; 571 _exceptionMessage = "attrib_list must contain EGL_NONE!"; 572 goto exit; 573 } 574 575 _returnValue = eglCreateWindowSurface( 576 (EGLDisplay)dpy_native, 577 (EGLConfig)config_native, 578 (EGLNativeWindowType)window.get(), 579 (EGLint *)attrib_list 580 ); 581 582exit: 583 if (attrib_list_base) { 584 _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 585 JNI_ABORT); 586 } 587 if (_exception) { 588 jniThrowException(_env, _exceptionType, _exceptionMessage); 589 } 590 return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 591} 592 593/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */ 594static jobject 595android_eglCreateWindowSurfaceTexture 596 (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) { 597 jint _exception = 0; 598 const char * _exceptionType = ""; 599 const char * _exceptionMessage = ""; 600 EGLSurface _returnValue = (EGLSurface) 0; 601 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 602 EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 603 int attrib_list_sentinel = 0; 604 EGLint *attrib_list_base = (EGLint *) 0; 605 jint _remaining; 606 EGLint *attrib_list = (EGLint *) 0; 607 android::sp<ANativeWindow> window; 608 android::sp<android::SurfaceTexture> surfaceTexture; 609 610 if (!attrib_list_ref) { 611 _exception = 1; 612 _exceptionType = "java/lang/IllegalArgumentException"; 613 _exceptionMessage = "attrib_list == null"; 614 goto exit; 615 } 616 if (offset < 0) { 617 _exception = 1; 618 _exceptionType = "java/lang/IllegalArgumentException"; 619 _exceptionMessage = "offset < 0"; 620 goto exit; 621 } 622 if (win == NULL) { 623not_valid_surface: 624 _exception = 1; 625 _exceptionType = "java/lang/IllegalArgumentException"; 626 _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"; 627 goto exit; 628 } 629 surfaceTexture = android::SurfaceTexture_getSurfaceTexture(_env, win); 630 631 if (surfaceTexture == NULL) 632 goto not_valid_surface; 633 634 window = new android::SurfaceTextureClient(surfaceTexture->getBufferQueue()); 635 636 if (window == NULL) 637 goto not_valid_surface; 638 639 _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 640 attrib_list_base = (EGLint *) 641 _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 642 attrib_list = attrib_list_base + offset; 643 attrib_list_sentinel = 0; 644 for (int i = _remaining - 1; i >= 0; i--) { 645 if (*((EGLint*)(attrib_list + i)) == EGL_NONE){ 646 attrib_list_sentinel = 1; 647 break; 648 } 649 } 650 if (attrib_list_sentinel == 0) { 651 _exception = 1; 652 _exceptionType = "java/lang/IllegalArgumentException"; 653 _exceptionMessage = "attrib_list must contain EGL_NONE!"; 654 goto exit; 655 } 656 657 _returnValue = eglCreateWindowSurface( 658 (EGLDisplay)dpy_native, 659 (EGLConfig)config_native, 660 (EGLNativeWindowType)window.get(), 661 (EGLint *)attrib_list 662 ); 663 664exit: 665 if (attrib_list_base) { 666 _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 667 JNI_ABORT); 668 } 669 if (_exception) { 670 jniThrowException(_env, _exceptionType, _exceptionMessage); 671 } 672 return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 673} 674/* EGLSurface eglCreatePbufferSurface ( EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list ) */ 675static jobject 676android_eglCreatePbufferSurface 677 (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jintArray attrib_list_ref, jint offset) { 678 jint _exception = 0; 679 const char * _exceptionType; 680 const char * _exceptionMessage; 681 EGLSurface _returnValue = (EGLSurface) 0; 682 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 683 EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 684 bool attrib_list_sentinel = false; 685 EGLint *attrib_list_base = (EGLint *) 0; 686 jint _remaining; 687 EGLint *attrib_list = (EGLint *) 0; 688 689 if (!attrib_list_ref) { 690 _exception = 1; 691 _exceptionType = "java/lang/IllegalArgumentException"; 692 _exceptionMessage = "attrib_list == null"; 693 goto exit; 694 } 695 if (offset < 0) { 696 _exception = 1; 697 _exceptionType = "java/lang/IllegalArgumentException"; 698 _exceptionMessage = "offset < 0"; 699 goto exit; 700 } 701 _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 702 attrib_list_base = (EGLint *) 703 _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 704 attrib_list = attrib_list_base + offset; 705 attrib_list_sentinel = false; 706 for (int i = _remaining - 1; i >= 0; i--) { 707 if (attrib_list[i] == EGL_NONE){ 708 attrib_list_sentinel = true; 709 break; 710 } 711 } 712 if (attrib_list_sentinel == false) { 713 _exception = 1; 714 _exceptionType = "java/lang/IllegalArgumentException"; 715 _exceptionMessage = "attrib_list must contain EGL_NONE!"; 716 goto exit; 717 } 718 719 _returnValue = eglCreatePbufferSurface( 720 (EGLDisplay)dpy_native, 721 (EGLConfig)config_native, 722 (EGLint *)attrib_list 723 ); 724 725exit: 726 if (attrib_list_base) { 727 _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 728 JNI_ABORT); 729 } 730 if (_exception) { 731 jniThrowException(_env, _exceptionType, _exceptionMessage); 732 } 733 return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 734} 735 736/* EGLSurface eglCreatePixmapSurface ( EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list ) */ 737static jobject 738android_eglCreatePixmapSurface 739 (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint pixmap, jintArray attrib_list_ref, jint offset) { 740 jniThrowException(_env, "java/lang/UnsupportedOperationException", 741 "eglCreatePixmapSurface"); 742 return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, (EGLSurface) 0); 743} 744 745/* EGLBoolean eglDestroySurface ( EGLDisplay dpy, EGLSurface surface ) */ 746static jboolean 747android_eglDestroySurface 748 (JNIEnv *_env, jobject _this, jobject dpy, jobject surface) { 749 EGLBoolean _returnValue = (EGLBoolean) 0; 750 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 751 EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 752 753 _returnValue = eglDestroySurface( 754 (EGLDisplay)dpy_native, 755 (EGLSurface)surface_native 756 ); 757 return _returnValue; 758} 759 760/* EGLBoolean eglQuerySurface ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value ) */ 761static jboolean 762android_eglQuerySurface 763 (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jintArray value_ref, jint offset) { 764 jint _exception = 0; 765 const char * _exceptionType; 766 const char * _exceptionMessage; 767 EGLBoolean _returnValue = (EGLBoolean) 0; 768 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 769 EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 770 EGLint *value_base = (EGLint *) 0; 771 jint _remaining; 772 EGLint *value = (EGLint *) 0; 773 774 if (!value_ref) { 775 _exception = 1; 776 _exceptionType = "java/lang/IllegalArgumentException"; 777 _exceptionMessage = "value == null"; 778 goto exit; 779 } 780 if (offset < 0) { 781 _exception = 1; 782 _exceptionType = "java/lang/IllegalArgumentException"; 783 _exceptionMessage = "offset < 0"; 784 goto exit; 785 } 786 _remaining = _env->GetArrayLength(value_ref) - offset; 787 if (_remaining < 1) { 788 _exception = 1; 789 _exceptionType = "java/lang/IllegalArgumentException"; 790 _exceptionMessage = "length - offset < 1 < needed"; 791 goto exit; 792 } 793 value_base = (EGLint *) 794 _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0); 795 value = value_base + offset; 796 797 _returnValue = eglQuerySurface( 798 (EGLDisplay)dpy_native, 799 (EGLSurface)surface_native, 800 (EGLint)attribute, 801 (EGLint *)value 802 ); 803 804exit: 805 if (value_base) { 806 _env->ReleasePrimitiveArrayCritical(value_ref, value_base, 807 _exception ? JNI_ABORT: 0); 808 } 809 if (_exception) { 810 jniThrowException(_env, _exceptionType, _exceptionMessage); 811 } 812 return _returnValue; 813} 814 815/* EGLBoolean eglBindAPI ( EGLenum api ) */ 816static jboolean 817android_eglBindAPI 818 (JNIEnv *_env, jobject _this, jint api) { 819 EGLBoolean _returnValue = (EGLBoolean) 0; 820 _returnValue = eglBindAPI( 821 (EGLenum)api 822 ); 823 return _returnValue; 824} 825 826/* EGLenum eglQueryAPI ( void ) */ 827static jint 828android_eglQueryAPI 829 (JNIEnv *_env, jobject _this) { 830 EGLenum _returnValue = (EGLenum) 0; 831 _returnValue = eglQueryAPI(); 832 return _returnValue; 833} 834 835/* EGLBoolean eglWaitClient ( void ) */ 836static jboolean 837android_eglWaitClient 838 (JNIEnv *_env, jobject _this) { 839 EGLBoolean _returnValue = (EGLBoolean) 0; 840 _returnValue = eglWaitClient(); 841 return _returnValue; 842} 843 844/* EGLBoolean eglReleaseThread ( void ) */ 845static jboolean 846android_eglReleaseThread 847 (JNIEnv *_env, jobject _this) { 848 EGLBoolean _returnValue = (EGLBoolean) 0; 849 _returnValue = eglReleaseThread(); 850 return _returnValue; 851} 852 853/* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */ 854static jobject 855android_eglCreatePbufferFromClientBuffer 856 (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) { 857 jint _exception = 0; 858 const char * _exceptionType; 859 const char * _exceptionMessage; 860 EGLSurface _returnValue = (EGLSurface) 0; 861 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 862 EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 863 bool attrib_list_sentinel = false; 864 EGLint *attrib_list_base = (EGLint *) 0; 865 jint _remaining; 866 EGLint *attrib_list = (EGLint *) 0; 867 868 if (!attrib_list_ref) { 869 _exception = 1; 870 _exceptionType = "java/lang/IllegalArgumentException"; 871 _exceptionMessage = "attrib_list == null"; 872 goto exit; 873 } 874 if (offset < 0) { 875 _exception = 1; 876 _exceptionType = "java/lang/IllegalArgumentException"; 877 _exceptionMessage = "offset < 0"; 878 goto exit; 879 } 880 _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 881 attrib_list_base = (EGLint *) 882 _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 883 attrib_list = attrib_list_base + offset; 884 attrib_list_sentinel = false; 885 for (int i = _remaining - 1; i >= 0; i--) { 886 if (attrib_list[i] == EGL_NONE){ 887 attrib_list_sentinel = true; 888 break; 889 } 890 } 891 if (attrib_list_sentinel == false) { 892 _exception = 1; 893 _exceptionType = "java/lang/IllegalArgumentException"; 894 _exceptionMessage = "attrib_list must contain EGL_NONE!"; 895 goto exit; 896 } 897 898 _returnValue = eglCreatePbufferFromClientBuffer( 899 (EGLDisplay)dpy_native, 900 (EGLenum)buftype, 901 (EGLClientBuffer)buffer, 902 (EGLConfig)config_native, 903 (EGLint *)attrib_list 904 ); 905 906exit: 907 if (attrib_list_base) { 908 _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 909 JNI_ABORT); 910 } 911 if (_exception) { 912 jniThrowException(_env, _exceptionType, _exceptionMessage); 913 } 914 return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 915} 916 917/* EGLBoolean eglSurfaceAttrib ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value ) */ 918static jboolean 919android_eglSurfaceAttrib 920 (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jint value) { 921 EGLBoolean _returnValue = (EGLBoolean) 0; 922 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 923 EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 924 925 _returnValue = eglSurfaceAttrib( 926 (EGLDisplay)dpy_native, 927 (EGLSurface)surface_native, 928 (EGLint)attribute, 929 (EGLint)value 930 ); 931 return _returnValue; 932} 933 934/* EGLBoolean eglBindTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */ 935static jboolean 936android_eglBindTexImage 937 (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) { 938 EGLBoolean _returnValue = (EGLBoolean) 0; 939 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 940 EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 941 942 _returnValue = eglBindTexImage( 943 (EGLDisplay)dpy_native, 944 (EGLSurface)surface_native, 945 (EGLint)buffer 946 ); 947 return _returnValue; 948} 949 950/* EGLBoolean eglReleaseTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */ 951static jboolean 952android_eglReleaseTexImage 953 (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) { 954 EGLBoolean _returnValue = (EGLBoolean) 0; 955 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 956 EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 957 958 _returnValue = eglReleaseTexImage( 959 (EGLDisplay)dpy_native, 960 (EGLSurface)surface_native, 961 (EGLint)buffer 962 ); 963 return _returnValue; 964} 965 966/* EGLBoolean eglSwapInterval ( EGLDisplay dpy, EGLint interval ) */ 967static jboolean 968android_eglSwapInterval 969 (JNIEnv *_env, jobject _this, jobject dpy, jint interval) { 970 EGLBoolean _returnValue = (EGLBoolean) 0; 971 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 972 973 _returnValue = eglSwapInterval( 974 (EGLDisplay)dpy_native, 975 (EGLint)interval 976 ); 977 return _returnValue; 978} 979 980/* EGLContext eglCreateContext ( EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list ) */ 981static jobject 982android_eglCreateContext 983 (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject share_context, jintArray attrib_list_ref, jint offset) { 984 jint _exception = 0; 985 const char * _exceptionType; 986 const char * _exceptionMessage; 987 EGLContext _returnValue = (EGLContext) 0; 988 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 989 EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 990 EGLContext share_context_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, share_context); 991 bool attrib_list_sentinel = false; 992 EGLint *attrib_list_base = (EGLint *) 0; 993 jint _remaining; 994 EGLint *attrib_list = (EGLint *) 0; 995 996 if (!attrib_list_ref) { 997 _exception = 1; 998 _exceptionType = "java/lang/IllegalArgumentException"; 999 _exceptionMessage = "attrib_list == null"; 1000 goto exit; 1001 } 1002 if (offset < 0) { 1003 _exception = 1; 1004 _exceptionType = "java/lang/IllegalArgumentException"; 1005 _exceptionMessage = "offset < 0"; 1006 goto exit; 1007 } 1008 _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 1009 attrib_list_base = (EGLint *) 1010 _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 1011 attrib_list = attrib_list_base + offset; 1012 attrib_list_sentinel = false; 1013 for (int i = _remaining - 1; i >= 0; i--) { 1014 if (attrib_list[i] == EGL_NONE){ 1015 attrib_list_sentinel = true; 1016 break; 1017 } 1018 } 1019 if (attrib_list_sentinel == false) { 1020 _exception = 1; 1021 _exceptionType = "java/lang/IllegalArgumentException"; 1022 _exceptionMessage = "attrib_list must contain EGL_NONE!"; 1023 goto exit; 1024 } 1025 1026 _returnValue = eglCreateContext( 1027 (EGLDisplay)dpy_native, 1028 (EGLConfig)config_native, 1029 (EGLContext)share_context_native, 1030 (EGLint *)attrib_list 1031 ); 1032 1033exit: 1034 if (attrib_list_base) { 1035 _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 1036 JNI_ABORT); 1037 } 1038 if (_exception) { 1039 jniThrowException(_env, _exceptionType, _exceptionMessage); 1040 } 1041 return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue); 1042} 1043 1044/* EGLBoolean eglDestroyContext ( EGLDisplay dpy, EGLContext ctx ) */ 1045static jboolean 1046android_eglDestroyContext 1047 (JNIEnv *_env, jobject _this, jobject dpy, jobject ctx) { 1048 EGLBoolean _returnValue = (EGLBoolean) 0; 1049 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 1050 EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx); 1051 1052 _returnValue = eglDestroyContext( 1053 (EGLDisplay)dpy_native, 1054 (EGLContext)ctx_native 1055 ); 1056 return _returnValue; 1057} 1058 1059/* EGLBoolean eglMakeCurrent ( EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx ) */ 1060static jboolean 1061android_eglMakeCurrent 1062 (JNIEnv *_env, jobject _this, jobject dpy, jobject draw, jobject read, jobject ctx) { 1063 EGLBoolean _returnValue = (EGLBoolean) 0; 1064 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 1065 EGLSurface draw_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, draw); 1066 EGLSurface read_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, read); 1067 EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx); 1068 1069 _returnValue = eglMakeCurrent( 1070 (EGLDisplay)dpy_native, 1071 (EGLSurface)draw_native, 1072 (EGLSurface)read_native, 1073 (EGLContext)ctx_native 1074 ); 1075 return _returnValue; 1076} 1077 1078/* EGLContext eglGetCurrentContext ( void ) */ 1079static jobject 1080android_eglGetCurrentContext 1081 (JNIEnv *_env, jobject _this) { 1082 EGLContext _returnValue = (EGLContext) 0; 1083 _returnValue = eglGetCurrentContext(); 1084 return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue); 1085} 1086 1087/* EGLSurface eglGetCurrentSurface ( EGLint readdraw ) */ 1088static jobject 1089android_eglGetCurrentSurface 1090 (JNIEnv *_env, jobject _this, jint readdraw) { 1091 EGLSurface _returnValue = (EGLSurface) 0; 1092 _returnValue = eglGetCurrentSurface( 1093 (EGLint)readdraw 1094 ); 1095 return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 1096} 1097 1098/* EGLDisplay eglGetCurrentDisplay ( void ) */ 1099static jobject 1100android_eglGetCurrentDisplay 1101 (JNIEnv *_env, jobject _this) { 1102 EGLDisplay _returnValue = (EGLDisplay) 0; 1103 _returnValue = eglGetCurrentDisplay(); 1104 return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue); 1105} 1106 1107/* EGLBoolean eglQueryContext ( EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value ) */ 1108static jboolean 1109android_eglQueryContext 1110 (JNIEnv *_env, jobject _this, jobject dpy, jobject ctx, jint attribute, jintArray value_ref, jint offset) { 1111 jint _exception = 0; 1112 const char * _exceptionType; 1113 const char * _exceptionMessage; 1114 EGLBoolean _returnValue = (EGLBoolean) 0; 1115 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 1116 EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx); 1117 EGLint *value_base = (EGLint *) 0; 1118 jint _remaining; 1119 EGLint *value = (EGLint *) 0; 1120 1121 if (!value_ref) { 1122 _exception = 1; 1123 _exceptionType = "java/lang/IllegalArgumentException"; 1124 _exceptionMessage = "value == null"; 1125 goto exit; 1126 } 1127 if (offset < 0) { 1128 _exception = 1; 1129 _exceptionType = "java/lang/IllegalArgumentException"; 1130 _exceptionMessage = "offset < 0"; 1131 goto exit; 1132 } 1133 _remaining = _env->GetArrayLength(value_ref) - offset; 1134 if (_remaining < 1) { 1135 _exception = 1; 1136 _exceptionType = "java/lang/IllegalArgumentException"; 1137 _exceptionMessage = "length - offset < 1 < needed"; 1138 goto exit; 1139 } 1140 value_base = (EGLint *) 1141 _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0); 1142 value = value_base + offset; 1143 1144 _returnValue = eglQueryContext( 1145 (EGLDisplay)dpy_native, 1146 (EGLContext)ctx_native, 1147 (EGLint)attribute, 1148 (EGLint *)value 1149 ); 1150 1151exit: 1152 if (value_base) { 1153 _env->ReleasePrimitiveArrayCritical(value_ref, value_base, 1154 _exception ? JNI_ABORT: 0); 1155 } 1156 if (_exception) { 1157 jniThrowException(_env, _exceptionType, _exceptionMessage); 1158 } 1159 return _returnValue; 1160} 1161 1162/* EGLBoolean eglWaitGL ( void ) */ 1163static jboolean 1164android_eglWaitGL 1165 (JNIEnv *_env, jobject _this) { 1166 EGLBoolean _returnValue = (EGLBoolean) 0; 1167 _returnValue = eglWaitGL(); 1168 return _returnValue; 1169} 1170 1171/* EGLBoolean eglWaitNative ( EGLint engine ) */ 1172static jboolean 1173android_eglWaitNative 1174 (JNIEnv *_env, jobject _this, jint engine) { 1175 EGLBoolean _returnValue = (EGLBoolean) 0; 1176 _returnValue = eglWaitNative( 1177 (EGLint)engine 1178 ); 1179 return _returnValue; 1180} 1181 1182/* EGLBoolean eglSwapBuffers ( EGLDisplay dpy, EGLSurface surface ) */ 1183static jboolean 1184android_eglSwapBuffers 1185 (JNIEnv *_env, jobject _this, jobject dpy, jobject surface) { 1186 EGLBoolean _returnValue = (EGLBoolean) 0; 1187 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 1188 EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 1189 1190 _returnValue = eglSwapBuffers( 1191 (EGLDisplay)dpy_native, 1192 (EGLSurface)surface_native 1193 ); 1194 return _returnValue; 1195} 1196 1197/* EGLBoolean eglCopyBuffers ( EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target ) */ 1198static jboolean 1199android_eglCopyBuffers 1200 (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint target) { 1201 jniThrowException(_env, "java/lang/UnsupportedOperationException", 1202 "eglCopyBuffers"); 1203 return (EGLBoolean) 0; 1204} 1205 1206static const char *classPathName = "android/opengl/EGL14"; 1207 1208static JNINativeMethod methods[] = { 1209{"_nativeClassInit", "()V", (void*)nativeClassInit }, 1210{"eglGetError", "()I", (void *) android_eglGetError }, 1211{"eglGetDisplay", "(I)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplay }, 1212{"eglInitialize", "(Landroid/opengl/EGLDisplay;[II[II)Z", (void *) android_eglInitialize }, 1213{"eglTerminate", "(Landroid/opengl/EGLDisplay;)Z", (void *) android_eglTerminate }, 1214{"eglQueryString", "(Landroid/opengl/EGLDisplay;I)Ljava/lang/String;", (void *) android_eglQueryString__Landroind_opengl_EGLDisplay_2I }, 1215{"eglGetConfigs", "(Landroid/opengl/EGLDisplay;[Landroid/opengl/EGLConfig;II[II)Z", (void *) android_eglGetConfigs }, 1216{"eglChooseConfig", "(Landroid/opengl/EGLDisplay;[II[Landroid/opengl/EGLConfig;II[II)Z", (void *) android_eglChooseConfig }, 1217{"eglGetConfigAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;I[II)Z", (void *) android_eglGetConfigAttrib }, 1218{"_eglCreateWindowSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/lang/Object;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreateWindowSurface }, 1219{"_eglCreateWindowSurfaceTexture", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/lang/Object;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreateWindowSurfaceTexture }, 1220{"eglCreatePbufferSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferSurface }, 1221{"eglCreatePixmapSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;I[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePixmapSurface }, 1222{"eglDestroySurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;)Z", (void *) android_eglDestroySurface }, 1223{"eglQuerySurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I[II)Z", (void *) android_eglQuerySurface }, 1224{"eglBindAPI", "(I)Z", (void *) android_eglBindAPI }, 1225{"eglQueryAPI", "()I", (void *) android_eglQueryAPI }, 1226{"eglWaitClient", "()Z", (void *) android_eglWaitClient }, 1227{"eglReleaseThread", "()Z", (void *) android_eglReleaseThread }, 1228{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IILandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBuffer }, 1229{"eglSurfaceAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;II)Z", (void *) android_eglSurfaceAttrib }, 1230{"eglBindTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglBindTexImage }, 1231{"eglReleaseTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglReleaseTexImage }, 1232{"eglSwapInterval", "(Landroid/opengl/EGLDisplay;I)Z", (void *) android_eglSwapInterval }, 1233{"eglCreateContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Landroid/opengl/EGLContext;[II)Landroid/opengl/EGLContext;", (void *) android_eglCreateContext }, 1234{"eglDestroyContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;)Z", (void *) android_eglDestroyContext }, 1235{"eglMakeCurrent", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;Landroid/opengl/EGLSurface;Landroid/opengl/EGLContext;)Z", (void *) android_eglMakeCurrent }, 1236{"eglGetCurrentContext", "()Landroid/opengl/EGLContext;", (void *) android_eglGetCurrentContext }, 1237{"eglGetCurrentSurface", "(I)Landroid/opengl/EGLSurface;", (void *) android_eglGetCurrentSurface }, 1238{"eglGetCurrentDisplay", "()Landroid/opengl/EGLDisplay;", (void *) android_eglGetCurrentDisplay }, 1239{"eglQueryContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;I[II)Z", (void *) android_eglQueryContext }, 1240{"eglWaitGL", "()Z", (void *) android_eglWaitGL }, 1241{"eglWaitNative", "(I)Z", (void *) android_eglWaitNative }, 1242{"eglSwapBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;)Z", (void *) android_eglSwapBuffers }, 1243{"eglCopyBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglCopyBuffers }, 1244}; 1245 1246int register_android_opengl_jni_EGL14(JNIEnv *_env) 1247{ 1248 int err; 1249 err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods)); 1250 return err; 1251} 1252