16b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* 26b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** Copyright 2012, The Android Open Source Project 36b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** 46b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** Licensed under the Apache License, Version 2.0 (the "License"); 56b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** you may not use this file except in compliance with the License. 66b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** You may obtain a copy of the License at 76b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** 86b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** http://www.apache.org/licenses/LICENSE-2.0 96b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** 106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** Unless required by applicable law or agreed to in writing, software 116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** distributed under the License is distributed on an "AS IS" BASIS, 126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** See the License for the specific language governing permissions and 146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer** limitations under the License. 156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer*/ 166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer// This source file is automatically generated 186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include "jni.h" 206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include "JNIHelp.h" 216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <android_runtime/AndroidRuntime.h> 226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <android_runtime/android_view_Surface.h> 236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <android_runtime/android_graphics_SurfaceTexture.h> 246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <utils/misc.h> 256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <assert.h> 276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <EGL/egl.h> 286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <gui/Surface.h> 30d47f7d8b5fe3a3861d7cbdc5f912235407823c8eAndy McFadden#include <gui/GLConsumer.h> 3152800617946c456e78ed010c82d0ec4358368164Mathias Agopian#include <gui/Surface.h> 326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <ui/ANativeObjectBase.h> 346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic int initialized = 0; 366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass egldisplayClass; 386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass eglcontextClass; 396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass eglsurfaceClass; 406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass eglconfigClass; 416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID egldisplayGetHandleID; 436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglcontextGetHandleID; 446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglsurfaceGetHandleID; 456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglconfigGetHandleID; 466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID egldisplayConstructor; 486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglcontextConstructor; 496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglsurfaceConstructor; 506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglconfigConstructor; 516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject eglNoContextObject; 536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject eglNoDisplayObject; 546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject eglNoSurfaceObject; 556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* Cache method IDs each time the class is loaded. */ 596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic void 616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas TafertshofernativeClassInit(JNIEnv *_env, jclass glImplClass) 626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{ 636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay"); 646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal); 656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext"); 666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal); 676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface"); 686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal); 696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig"); 706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal); 716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getHandle", "()I"); 736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getHandle", "()I"); 746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getHandle", "()I"); 756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getHandle", "()I"); 766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(I)V"); 796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(I)V"); 806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(I)V"); 816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(I)V"); 826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, (jint)EGL_NO_CONTEXT); 846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject); 856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, (jint)EGL_NO_DISPLAY); 866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject); 876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, (jint)EGL_NO_SURFACE); 886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject); 896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jclass eglClass = _env->FindClass("android/opengl/EGL14"); 926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;"); 936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->SetStaticObjectField(eglClass, noContextFieldID, eglNoContextObject); 946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;"); 966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->SetStaticObjectField(eglClass, noDisplayFieldID, eglNoDisplayObject); 976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;"); 996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->SetStaticObjectField(eglClass, noSurfaceFieldID, eglNoSurfaceObject); 1006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 1016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic void * 1036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas TafertshoferfromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) { 1046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (obj == NULL){ 1056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, "java/lang/IllegalArgumentException", 1066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer "Object is set to null."); 1076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return (void*) (_env->CallIntMethod(obj, mid)); 1106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 1116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 1136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas TafertshofertoEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) { 1146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (cls == eglcontextClass && 1156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLContext)handle == EGL_NO_CONTEXT) { 1166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return eglNoContextObject; 1176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (cls == egldisplayClass && 1206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)handle == EGL_NO_DISPLAY) { 1216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return eglNoDisplayObject; 1226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (cls == eglsurfaceClass && 1256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)handle == EGL_NO_SURFACE) { 1266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return eglNoSurfaceObject; 1276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return _env->NewObject(cls, con, (jint)handle); 1306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 1316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer// -------------------------------------------------------------------------- 1336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLint eglGetError ( void ) */ 1346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jint 1356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetError 1366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this) { 1376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint _returnValue = (EGLint) 0; 1386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglGetError(); 139cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jint)_returnValue; 1406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 1416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */ 1436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 1446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetDisplay 1456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jint display_id) { 1466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay _returnValue = (EGLDisplay) 0; 1476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglGetDisplay( 1486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLNativeDisplayType)display_id 1496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 1506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue); 1516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 1526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglInitialize ( EGLDisplay dpy, EGLint *major, EGLint *minor ) */ 1546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 1556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglInitialize 1566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jintArray major_ref, jint majorOffset, jintArray minor_ref, jint minorOffset) { 1576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 15815284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 15915284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 1606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 1616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 1626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *major_base = (EGLint *) 0; 1636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _majorRemaining; 1646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *major = (EGLint *) 0; 1656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *minor_base = (EGLint *) 0; 1666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _minorRemaining; 1676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *minor = (EGLint *) 0; 1686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!major_ref) { 1706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 1716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 1726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "major == null"; 1736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 1746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (majorOffset < 0) { 1766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 1776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 1786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "majorOffset < 0"; 1796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 1806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _majorRemaining = _env->GetArrayLength(major_ref) - majorOffset; 1826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_majorRemaining < 1) { 1836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 1846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 1856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - majorOffset < 1 < needed"; 1866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 1876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer major_base = (EGLint *) 1896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(major_ref, (jboolean *)0); 1906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer major = major_base + majorOffset; 1916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 1926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!minor_ref) { 1936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 1946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 1956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "minor == null"; 1966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 1976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (minorOffset < 0) { 1996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 2006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 2016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "minorOffset < 0"; 2026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 2036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 2046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _minorRemaining = _env->GetArrayLength(minor_ref) - minorOffset; 2056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_minorRemaining < 1) { 2066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 2076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 2086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - minorOffset < 1 < needed"; 2096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 2106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 2116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer minor_base = (EGLint *) 2126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(minor_ref, (jboolean *)0); 2136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer minor = minor_base + minorOffset; 2146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 2156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglInitialize( 2166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 2176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)major, 2186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)minor 2196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 2206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 2216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 2226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (minor_base) { 2236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(minor_ref, minor_base, 2246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception ? JNI_ABORT: 0); 2256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 2266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (major_base) { 2276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(major_ref, major_base, 2286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception ? JNI_ABORT: 0); 2296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 2306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 2316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 2326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 233cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 2346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 2356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 2366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglTerminate ( EGLDisplay dpy ) */ 2376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 2386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglTerminate 2396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy) { 2406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 2416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 2426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 2436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglTerminate( 2446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native 2456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 246cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 2476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 2486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 2496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* const char * eglQueryString ( EGLDisplay dpy, EGLint name ) */ 2506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jstring 2516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQueryString__Landroind_opengl_EGLDisplay_2I 2526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jint name) { 2536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer const char* chars = (const char*) eglQueryString( 2546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)fromEGLHandle(_env, egldisplayGetHandleID, dpy), 2556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)name 2566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 2576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return _env->NewStringUTF(chars); 2586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 2596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglGetConfigs ( EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */ 2606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 2616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetConfigs 2626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) { 2636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 26415284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 26515284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 2666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 2676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 2686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _configsRemaining; 2696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig *configs = (EGLConfig *) 0; 2706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *num_config_base = (EGLint *) 0; 2716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _num_configRemaining; 2726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *num_config = (EGLint *) 0; 2736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 2746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!configs_ref) { 2756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 2766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 2776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "configs == null"; 2786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 2796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 2806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (configsOffset < 0) { 2816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 2826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 2836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "configsOffset < 0"; 2846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 2856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 2866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset; 2876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_configsRemaining < config_size) { 2886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 2896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 2906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - configsOffset < config_size < needed"; 2916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 2926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 2936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer configs = new EGLConfig[_configsRemaining]; 2946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 2956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!num_config_ref) { 2966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 2976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 2986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "num_config == null"; 2996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 3006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (num_configOffset < 0) { 3026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 3036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 3046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "num_configOffset < 0"; 3056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 3066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset; 3086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer num_config_base = (EGLint *) 3096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(num_config_ref, (jboolean *)0); 3106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer num_config = num_config_base + num_configOffset; 3116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 3126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglGetConfigs( 3136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 3146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig *)configs, 3156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)config_size, 3166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)num_config 3176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 3186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 3196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 3206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (num_config_base) { 3216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(num_config_ref, num_config_base, 3226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception ? JNI_ABORT: 0); 3236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (configs) { 3256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = 0; i < _configsRemaining; i++) { 3266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]); 3276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new); 3286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer delete[] configs; 3306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 3326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 3336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 334cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 3356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 3366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 3376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglChooseConfig ( EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */ 3386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 3396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglChooseConfig 3406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (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) { 3416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 34215284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 34315284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 3446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 3456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 3466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer bool attrib_list_sentinel = false; 3476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list_base = (EGLint *) 0; 3486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _attrib_listRemaining; 3496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list = (EGLint *) 0; 3506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _configsRemaining; 3516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig *configs = (EGLConfig *) 0; 3526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *num_config_base = (EGLint *) 0; 3536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _num_configRemaining; 3546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *num_config = (EGLint *) 0; 3556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 3566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!attrib_list_ref) { 3576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 3586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 3596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list == null"; 3606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 3616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_listOffset < 0) { 3636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 3646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 3656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_listOffset < 0"; 3666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 3676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _attrib_listRemaining = _env->GetArrayLength(attrib_list_ref) - attrib_listOffset; 3696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_base = (EGLint *) 3706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 3716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list = attrib_list_base + attrib_listOffset; 3726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = false; 3736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = _attrib_listRemaining - 1; i >= 0; i--) { 3746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list[i] == EGL_NONE){ 3756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = true; 3766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer break; 3776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_sentinel == false) { 3806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 3816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 3826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list must contain EGL_NONE!"; 3836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 3846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 3866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!configs_ref) { 3876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 3886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 3896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "configs == null"; 3906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 3916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (configsOffset < 0) { 3936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 3946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 3956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "configsOffset < 0"; 3966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 3976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 3986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset; 3996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_configsRemaining < config_size) { 4006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 4016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 4026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - configsOffset < config_size < needed"; 4036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 4046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer configs = new EGLConfig[_configsRemaining]; 4066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 4076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!num_config_ref) { 4086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 4096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 4106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "num_config == null"; 4116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 4126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (num_configOffset < 0) { 4146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 4156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 4166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "num_configOffset < 0"; 4176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 4186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset; 4206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_num_configRemaining < 1) { 4216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 4226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 4236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - num_configOffset < 1 < needed"; 4246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 4256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer num_config_base = (EGLint *) 4276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(num_config_ref, (jboolean *)0); 4286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer num_config = num_config_base + num_configOffset; 4296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 4306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglChooseConfig( 4316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 4326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)attrib_list, 4336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig *)configs, 4346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)config_size, 4356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)num_config 4366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 4376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 4386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 4396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (num_config_base) { 4406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(num_config_ref, num_config_base, 4416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception ? JNI_ABORT: 0); 4426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_base) { 4446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 4456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer JNI_ABORT); 4466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (configs) { 4486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = 0; i < _configsRemaining; i++) { 4496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]); 4506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new); 4516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer delete[] configs; 4536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 4556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 4566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 457cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 4586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 4596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 4606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglGetConfigAttrib ( EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value ) */ 4616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 4626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetConfigAttrib 4636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint attribute, jintArray value_ref, jint offset) { 4646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 46515284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 46615284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 4676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 4686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 4696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 4706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *value_base = (EGLint *) 0; 4716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 4726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *value = (EGLint *) 0; 4736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 4746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!value_ref) { 4756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 4766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 4776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "value == null"; 4786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 4796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 4816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 4826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 4836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 4846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 4856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(value_ref) - offset; 4876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_remaining < 1) { 4886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 4896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 4906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - offset < 1 < needed"; 4916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 4926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 4936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer value_base = (EGLint *) 4946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0); 4956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer value = value_base + offset; 4966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 4976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglGetConfigAttrib( 4986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 4996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig)config_native, 5006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)attribute, 5016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)value 5026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 5036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 5056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (value_base) { 5066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(value_ref, value_base, 5076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception ? JNI_ABORT: 0); 5086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 5106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 5116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 512cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 5136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 5146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */ 5166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 5176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreateWindowSurface 5186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) { 5196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 5206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer const char * _exceptionType = ""; 5216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer const char * _exceptionMessage = ""; 5226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface _returnValue = (EGLSurface) 0; 5236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 5246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 5256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer int attrib_list_sentinel = 0; 5266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list_base = (EGLint *) 0; 5276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 5286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list = (EGLint *) 0; 5296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer android::sp<ANativeWindow> window; 5306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!attrib_list_ref) { 5326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 5336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 5346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list == null"; 5356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 5366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 5386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 5396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 5406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 5416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 5426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (win == NULL) { 5446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofernot_valid_surface: 5456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 5466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 5476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"; 5486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 5496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 55164a55af0ac700baecb0877235eb42caac59a3560Jeff Brown window = android::android_view_Surface_getNativeWindow(_env, win); 5526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (window == NULL) 5546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto not_valid_surface; 5556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 5576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_base = (EGLint *) 5586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 5596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list = attrib_list_base + offset; 5606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = 0; 5616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = _remaining - 1; i >= 0; i--) { 5626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (*((EGLint*)(attrib_list + i)) == EGL_NONE){ 5636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = 1; 5646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer break; 5656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_sentinel == 0) { 5686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 5696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 5706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list must contain EGL_NONE!"; 5716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 5726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglCreateWindowSurface( 5756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 5766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig)config_native, 5776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLNativeWindowType)window.get(), 5786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)attrib_list 5796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 5806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 5826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_base) { 5836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 5846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer JNI_ABORT); 5856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 5876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 5886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 5896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 5906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 5916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 5926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */ 5936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 5946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreateWindowSurfaceTexture 5956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) { 5966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 5976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer const char * _exceptionType = ""; 5986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer const char * _exceptionMessage = ""; 5996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface _returnValue = (EGLSurface) 0; 6006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 6016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 6026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer int attrib_list_sentinel = 0; 6036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list_base = (EGLint *) 0; 6046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 6056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list = (EGLint *) 0; 6066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer android::sp<ANativeWindow> window; 60752a9a10b6b8c7b7a9f97777541841b94d4fd9754Mathias Agopian android::sp<android::IGraphicBufferProducer> producer; 6086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 6096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!attrib_list_ref) { 6106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 6116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 6126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list == null"; 6136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 6146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 6166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 6176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 6186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 6196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 6206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (win == NULL) { 6226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofernot_valid_surface: 6236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 6246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 6256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"; 6266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 6276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 62852a9a10b6b8c7b7a9f97777541841b94d4fd9754Mathias Agopian producer = android::SurfaceTexture_getProducer(_env, win); 62982bb813f112d9565faa990e32dbe833f96461892Jamie Gennis 63052a9a10b6b8c7b7a9f97777541841b94d4fd9754Mathias Agopian if (producer == NULL) 63182bb813f112d9565faa990e32dbe833f96461892Jamie Gennis goto not_valid_surface; 63282bb813f112d9565faa990e32dbe833f96461892Jamie Gennis 63352a9a10b6b8c7b7a9f97777541841b94d4fd9754Mathias Agopian window = new android::Surface(producer); 6346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 6356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (window == NULL) 6366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto not_valid_surface; 6376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 6386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 6396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_base = (EGLint *) 6406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 6416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list = attrib_list_base + offset; 6426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = 0; 6436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = _remaining - 1; i >= 0; i--) { 6446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (*((EGLint*)(attrib_list + i)) == EGL_NONE){ 6456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = 1; 6466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer break; 6476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_sentinel == 0) { 6506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 6516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 6526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list must contain EGL_NONE!"; 6536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 6546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 6566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglCreateWindowSurface( 6576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 6586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig)config_native, 6596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLNativeWindowType)window.get(), 6606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)attrib_list 6616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 6626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 6636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 6646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_base) { 6656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 6666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer JNI_ABORT); 6676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 6696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 6706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 6726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 6736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreatePbufferSurface ( EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list ) */ 6746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 6756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreatePbufferSurface 6766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jintArray attrib_list_ref, jint offset) { 6776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 67815284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 67915284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 6806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface _returnValue = (EGLSurface) 0; 6816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 6826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 6836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer bool attrib_list_sentinel = false; 6846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list_base = (EGLint *) 0; 6856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 6866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list = (EGLint *) 0; 6876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 6886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!attrib_list_ref) { 6896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 6906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 6916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list == null"; 6926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 6936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 6946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 6956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 6966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 6976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 6986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 6996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 7016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_base = (EGLint *) 7026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 7036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list = attrib_list_base + offset; 7046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = false; 7056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = _remaining - 1; i >= 0; i--) { 7066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list[i] == EGL_NONE){ 7076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = true; 7086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer break; 7096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_sentinel == false) { 7126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 7136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 7146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list must contain EGL_NONE!"; 7156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 7166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglCreatePbufferSurface( 7196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 7206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig)config_native, 7216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)attrib_list 7226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 7236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 7256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_base) { 7266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 7276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer JNI_ABORT); 7286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 7306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 7316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 7336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 7346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreatePixmapSurface ( EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list ) */ 7366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 7376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreatePixmapSurface 7386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint pixmap, jintArray attrib_list_ref, jint offset) { 7396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, "java/lang/UnsupportedOperationException", 7406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer "eglCreatePixmapSurface"); 7416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, (EGLSurface) 0); 7426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 7436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglDestroySurface ( EGLDisplay dpy, EGLSurface surface ) */ 7456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 7466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglDestroySurface 7476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject surface) { 7486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 7496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 7506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 7516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglDestroySurface( 7536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 7546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)surface_native 7556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 756cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 7576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 7586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglQuerySurface ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value ) */ 7606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 7616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQuerySurface 7626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jintArray value_ref, jint offset) { 7636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 76415284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 76515284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 7666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 7676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 7686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 7696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *value_base = (EGLint *) 0; 7706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 7716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *value = (EGLint *) 0; 7726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!value_ref) { 7746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 7756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 7766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "value == null"; 7776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 7786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 7806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 7816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 7826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 7836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 7846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(value_ref) - offset; 7866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_remaining < 1) { 7876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 7886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 7896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - offset < 1 < needed"; 7906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 7916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 7926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer value_base = (EGLint *) 7936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0); 7946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer value = value_base + offset; 7956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 7966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglQuerySurface( 7976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 7986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)surface_native, 7996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)attribute, 8006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)value 8016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 8026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 8046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (value_base) { 8056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(value_ref, value_base, 8066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception ? JNI_ABORT: 0); 8076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 8086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 8096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 8106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 811cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 8126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 8136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglBindAPI ( EGLenum api ) */ 8156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 8166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglBindAPI 8176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jint api) { 8186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 8196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglBindAPI( 8206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLenum)api 8216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 822cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 8236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 8246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLenum eglQueryAPI ( void ) */ 8266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jint 8276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQueryAPI 8286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this) { 8296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLenum _returnValue = (EGLenum) 0; 8306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglQueryAPI(); 831cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jint)_returnValue; 8326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 8336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglWaitClient ( void ) */ 8356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 8366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglWaitClient 8376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this) { 8386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 8396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglWaitClient(); 840cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 8416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 8426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglReleaseThread ( void ) */ 8446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 8456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglReleaseThread 8466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this) { 8476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 8486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglReleaseThread(); 849cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 8506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 8516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */ 8536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 8546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreatePbufferFromClientBuffer 8556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) { 8566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 85715284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 85815284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 8596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface _returnValue = (EGLSurface) 0; 8606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 8616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 8626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer bool attrib_list_sentinel = false; 8636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list_base = (EGLint *) 0; 8646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 8656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list = (EGLint *) 0; 8666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!attrib_list_ref) { 8686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 8696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 8706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list == null"; 8716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 8726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 8736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 8746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 8756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 8766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 8776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 8786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 8796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 8806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_base = (EGLint *) 8816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 8826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list = attrib_list_base + offset; 8836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = false; 8846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = _remaining - 1; i >= 0; i--) { 8856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list[i] == EGL_NONE){ 8866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = true; 8876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer break; 8886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 8896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 8906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_sentinel == false) { 8916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 8926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 8936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list must contain EGL_NONE!"; 8946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 8956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 8966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 8976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglCreatePbufferFromClientBuffer( 8986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 8996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLenum)buftype, 9006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLClientBuffer)buffer, 9016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig)config_native, 9026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)attrib_list 9036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 9046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 9066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_base) { 9076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 9086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer JNI_ABORT); 9096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 9106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 9116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 9126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 9136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 9146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 9156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglSurfaceAttrib ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value ) */ 9176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 9186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglSurfaceAttrib 9196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jint value) { 9206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 9216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 9226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 9236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglSurfaceAttrib( 9256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 9266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)surface_native, 9276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)attribute, 9286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)value 9296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 930cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 9316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 9326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglBindTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */ 9346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 9356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglBindTexImage 9366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) { 9376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 9386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 9396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 9406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglBindTexImage( 9426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 9436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)surface_native, 9446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)buffer 9456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 946cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 9476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 9486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglReleaseTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */ 9506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 9516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglReleaseTexImage 9526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) { 9536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 9546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 9556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 9566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglReleaseTexImage( 9586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 9596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)surface_native, 9606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)buffer 9616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 962cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 9636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 9646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglSwapInterval ( EGLDisplay dpy, EGLint interval ) */ 9666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 9676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglSwapInterval 9686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jint interval) { 9696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 9706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 9716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglSwapInterval( 9736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 9746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)interval 9756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 976cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 9776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 9786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLContext eglCreateContext ( EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list ) */ 9806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 9816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreateContext 9826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject share_context, jintArray attrib_list_ref, jint offset) { 9836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 98415284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 98515284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 9866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLContext _returnValue = (EGLContext) 0; 9876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 9886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); 9896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLContext share_context_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, share_context); 9906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer bool attrib_list_sentinel = false; 9916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list_base = (EGLint *) 0; 9926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 9936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *attrib_list = (EGLint *) 0; 9946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 9956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!attrib_list_ref) { 9966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 9976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 9986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list == null"; 9996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 10006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 10016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 10026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 10036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 10046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 10056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 10066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 10076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(attrib_list_ref) - offset; 10086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_base = (EGLint *) 10096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(attrib_list_ref, (jboolean *)0); 10106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list = attrib_list_base + offset; 10116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = false; 10126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer for (int i = _remaining - 1; i >= 0; i--) { 10136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list[i] == EGL_NONE){ 10146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer attrib_list_sentinel = true; 10156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer break; 10166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 10176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 10186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_sentinel == false) { 10196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 10206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 10216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "attrib_list must contain EGL_NONE!"; 10226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 10236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 10246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglCreateContext( 10266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 10276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLConfig)config_native, 10286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLContext)share_context_native, 10296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)attrib_list 10306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 10316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 10336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (attrib_list_base) { 10346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(attrib_list_ref, attrib_list_base, 10356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer JNI_ABORT); 10366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 10376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 10386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 10396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 10406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue); 10416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 10426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglDestroyContext ( EGLDisplay dpy, EGLContext ctx ) */ 10446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 10456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglDestroyContext 10466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject ctx) { 10476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 10486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 10496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx); 10506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglDestroyContext( 10526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 10536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLContext)ctx_native 10546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 1055cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 10566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 10576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglMakeCurrent ( EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx ) */ 10596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 10606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglMakeCurrent 10616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject draw, jobject read, jobject ctx) { 10626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 10636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 10646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface draw_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, draw); 10656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface read_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, read); 10666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx); 10676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglMakeCurrent( 10696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 10706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)draw_native, 10716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)read_native, 10726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLContext)ctx_native 10736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 1074cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 10756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 10766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLContext eglGetCurrentContext ( void ) */ 10786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 10796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetCurrentContext 10806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this) { 10816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLContext _returnValue = (EGLContext) 0; 10826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglGetCurrentContext(); 10836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue); 10846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 10856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglGetCurrentSurface ( EGLint readdraw ) */ 10876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 10886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetCurrentSurface 10896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jint readdraw) { 10906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface _returnValue = (EGLSurface) 0; 10916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglGetCurrentSurface( 10926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)readdraw 10936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 10946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); 10956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 10966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 10976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLDisplay eglGetCurrentDisplay ( void ) */ 10986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject 10996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetCurrentDisplay 11006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this) { 11016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay _returnValue = (EGLDisplay) 0; 11026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglGetCurrentDisplay(); 11036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue); 11046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 11056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglQueryContext ( EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value ) */ 11076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 11086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQueryContext 11096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject ctx, jint attribute, jintArray value_ref, jint offset) { 11106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _exception = 0; 111115284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionType = NULL; 111215284dee8efe6b4d1441ab040962077614b5061aMathias Agopian const char * _exceptionMessage = NULL; 11136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 11146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 11156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx); 11166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *value_base = (EGLint *) 0; 11176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jint _remaining; 11186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLint *value = (EGLint *) 0; 11196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (!value_ref) { 11216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 11226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 11236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "value == null"; 11246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 11256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 11266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (offset < 0) { 11276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 11286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 11296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "offset < 0"; 11306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 11316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 11326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _remaining = _env->GetArrayLength(value_ref) - offset; 11336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_remaining < 1) { 11346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception = 1; 11356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionType = "java/lang/IllegalArgumentException"; 11366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exceptionMessage = "length - offset < 1 < needed"; 11376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer goto exit; 11386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 11396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer value_base = (EGLint *) 11406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->GetPrimitiveArrayCritical(value_ref, (jboolean *)0); 11416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer value = value_base + offset; 11426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglQueryContext( 11446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 11456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLContext)ctx_native, 11466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)attribute, 11476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint *)value 11486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 11496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit: 11516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (value_base) { 11526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _env->ReleasePrimitiveArrayCritical(value_ref, value_base, 11536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _exception ? JNI_ABORT: 0); 11546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 11556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer if (_exception) { 11566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, _exceptionType, _exceptionMessage); 11576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer } 1158cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 11596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 11606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglWaitGL ( void ) */ 11626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 11636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglWaitGL 11646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this) { 11656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 11666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglWaitGL(); 1167cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 11686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 11696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglWaitNative ( EGLint engine ) */ 11716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 11726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglWaitNative 11736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jint engine) { 11746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 11756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglWaitNative( 11766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLint)engine 11776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 1178cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 11796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 11806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglSwapBuffers ( EGLDisplay dpy, EGLSurface surface ) */ 11826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 11836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglSwapBuffers 11846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject surface) { 11856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLBoolean _returnValue = (EGLBoolean) 0; 11866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); 11876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface); 11886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer _returnValue = eglSwapBuffers( 11906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLDisplay)dpy_native, 11916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (EGLSurface)surface_native 11926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer ); 1193cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden return (jboolean)_returnValue; 11946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 11956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 11966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglCopyBuffers ( EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target ) */ 11976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean 11986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCopyBuffers 11996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint target) { 12006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer jniThrowException(_env, "java/lang/UnsupportedOperationException", 12016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer "eglCopyBuffers"); 12026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return (EGLBoolean) 0; 12036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 12046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 12056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic const char *classPathName = "android/opengl/EGL14"; 12066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 12076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic JNINativeMethod methods[] = { 12086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"_nativeClassInit", "()V", (void*)nativeClassInit }, 12096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetError", "()I", (void *) android_eglGetError }, 12106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetDisplay", "(I)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplay }, 12116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglInitialize", "(Landroid/opengl/EGLDisplay;[II[II)Z", (void *) android_eglInitialize }, 12126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglTerminate", "(Landroid/opengl/EGLDisplay;)Z", (void *) android_eglTerminate }, 12136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglQueryString", "(Landroid/opengl/EGLDisplay;I)Ljava/lang/String;", (void *) android_eglQueryString__Landroind_opengl_EGLDisplay_2I }, 12146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetConfigs", "(Landroid/opengl/EGLDisplay;[Landroid/opengl/EGLConfig;II[II)Z", (void *) android_eglGetConfigs }, 12156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglChooseConfig", "(Landroid/opengl/EGLDisplay;[II[Landroid/opengl/EGLConfig;II[II)Z", (void *) android_eglChooseConfig }, 12166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetConfigAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;I[II)Z", (void *) android_eglGetConfigAttrib }, 12176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"_eglCreateWindowSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/lang/Object;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreateWindowSurface }, 12186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"_eglCreateWindowSurfaceTexture", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/lang/Object;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreateWindowSurfaceTexture }, 12196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglCreatePbufferSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferSurface }, 12206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglCreatePixmapSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;I[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePixmapSurface }, 12216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglDestroySurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;)Z", (void *) android_eglDestroySurface }, 12226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglQuerySurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I[II)Z", (void *) android_eglQuerySurface }, 12236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglBindAPI", "(I)Z", (void *) android_eglBindAPI }, 12246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglQueryAPI", "()I", (void *) android_eglQueryAPI }, 12256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglWaitClient", "()Z", (void *) android_eglWaitClient }, 12266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglReleaseThread", "()Z", (void *) android_eglReleaseThread }, 12276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IILandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBuffer }, 12286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglSurfaceAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;II)Z", (void *) android_eglSurfaceAttrib }, 12296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglBindTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglBindTexImage }, 12306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglReleaseTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglReleaseTexImage }, 12316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglSwapInterval", "(Landroid/opengl/EGLDisplay;I)Z", (void *) android_eglSwapInterval }, 12326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglCreateContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Landroid/opengl/EGLContext;[II)Landroid/opengl/EGLContext;", (void *) android_eglCreateContext }, 12336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglDestroyContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;)Z", (void *) android_eglDestroyContext }, 12346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglMakeCurrent", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;Landroid/opengl/EGLSurface;Landroid/opengl/EGLContext;)Z", (void *) android_eglMakeCurrent }, 12356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetCurrentContext", "()Landroid/opengl/EGLContext;", (void *) android_eglGetCurrentContext }, 12366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetCurrentSurface", "(I)Landroid/opengl/EGLSurface;", (void *) android_eglGetCurrentSurface }, 12376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetCurrentDisplay", "()Landroid/opengl/EGLDisplay;", (void *) android_eglGetCurrentDisplay }, 12386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglQueryContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;I[II)Z", (void *) android_eglQueryContext }, 12396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglWaitGL", "()Z", (void *) android_eglWaitGL }, 12406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglWaitNative", "(I)Z", (void *) android_eglWaitNative }, 12416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglSwapBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;)Z", (void *) android_eglSwapBuffers }, 12426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglCopyBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglCopyBuffers }, 12436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}; 12446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer 12456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferint register_android_opengl_jni_EGL14(JNIEnv *_env) 12466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{ 12476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer int err; 12486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods)); 12496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer return err; 12506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer} 1251