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
19bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe#pragma GCC diagnostic ignored "-Wunused-variable"
20bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
21bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe#pragma GCC diagnostic ignored "-Wunused-function"
22bfe6333c3cf529600f41f14e3b8c5846e632c9a2Andreas Gampe
236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include "jni.h"
246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include "JNIHelp.h"
256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <android_runtime/AndroidRuntime.h>
266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <android_runtime/android_view_Surface.h>
276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <android_runtime/android_graphics_SurfaceTexture.h>
286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <utils/misc.h>
296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <assert.h>
316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <EGL/egl.h>
326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <gui/Surface.h>
34d47f7d8b5fe3a3861d7cbdc5f912235407823c8eAndy McFadden#include <gui/GLConsumer.h>
3552800617946c456e78ed010c82d0ec4358368164Mathias Agopian#include <gui/Surface.h>
366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer#include <ui/ANativeObjectBase.h>
386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic int initialized = 0;
406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass egldisplayClass;
426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass eglcontextClass;
436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass eglsurfaceClass;
446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jclass eglconfigClass;
456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID egldisplayGetHandleID;
476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglcontextGetHandleID;
486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglsurfaceGetHandleID;
496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglconfigGetHandleID;
506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID egldisplayConstructor;
526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglcontextConstructor;
536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglsurfaceConstructor;
546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jmethodID eglconfigConstructor;
556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject eglNoContextObject;
576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject eglNoDisplayObject;
586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject eglNoSurfaceObject;
596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* Cache method IDs each time the class is loaded. */
636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic void
656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas TafertshofernativeClassInit(JNIEnv *_env, jclass glImplClass)
666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{
676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay");
686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal);
696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext");
706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal);
716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface");
726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal);
736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7684bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
7784bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
7884bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
7984bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8284bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
8384bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
8484bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
8584bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8784bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, reinterpret_cast<jlong>(EGL_NO_CONTEXT));
886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
8984bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, reinterpret_cast<jlong>(EGL_NO_DISPLAY));
906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
9184bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, reinterpret_cast<jlong>(EGL_NO_SURFACE));
926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jclass eglClass = _env->FindClass("android/opengl/EGL14");
966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;");
976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _env->SetStaticObjectField(eglClass, noContextFieldID, eglNoContextObject);
986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;");
1006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _env->SetStaticObjectField(eglClass, noDisplayFieldID, eglNoDisplayObject);
1016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;");
1036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _env->SetStaticObjectField(eglClass, noSurfaceFieldID, eglNoSurfaceObject);
1046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
1056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic void *
1076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas TafertshoferfromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
1086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (obj == NULL){
1096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, "java/lang/IllegalArgumentException",
1106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer                          "Object is set to null.");
1116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
1126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11384bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    jlong handle = _env->CallLongMethod(obj, mid);
11484bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    return reinterpret_cast<void*>(handle);
1156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
1166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
1186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas TafertshofertoEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) {
1196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (cls == eglcontextClass &&
1206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer       (EGLContext)handle == EGL_NO_CONTEXT) {
1216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer           return eglNoContextObject;
1226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
1236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (cls == egldisplayClass &&
1256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer       (EGLDisplay)handle == EGL_NO_DISPLAY) {
1266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer           return eglNoDisplayObject;
1276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
1286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (cls == eglsurfaceClass &&
1306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer       (EGLSurface)handle == EGL_NO_SURFACE) {
1316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer           return eglNoSurfaceObject;
1326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
1336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
13484bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
1356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
1366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer// --------------------------------------------------------------------------
1386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLint eglGetError ( void ) */
1396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jint
1406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetError
1416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this) {
1426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint _returnValue = (EGLint) 0;
1436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglGetError();
144cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jint)_returnValue;
1456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
1466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */
1486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
1496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetDisplay
15084bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat  (JNIEnv *_env, jobject _this, jlong display_id) {
1516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay _returnValue = (EGLDisplay) 0;
1526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglGetDisplay(
15384bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat        reinterpret_cast<EGLNativeDisplayType>(display_id)
1546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
1556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
1566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
1576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
15884bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat/* EGLDisplay eglGetDisplay ( EGLNativeDisplayType display_id ) */
15984bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhatstatic jobject
16084bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhatandroid_eglGetDisplayInt
16184bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat  (JNIEnv *_env, jobject _this, jint display_id) {
16284bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat
16310caf0390d39f0bd46876eee6ab2c9a73d4e1d39Dan Albert    if (static_cast<uintptr_t>(display_id) !=
16410caf0390d39f0bd46876eee6ab2c9a73d4e1d39Dan Albert        reinterpret_cast<uintptr_t>(EGL_DEFAULT_DISPLAY)) {
16584bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat        jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglGetDisplay");
16684bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat        return 0;
16784bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    }
16884bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    return android_eglGetDisplay(_env, _this, display_id);
16984bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat}
17084bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat
1716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglInitialize ( EGLDisplay dpy, EGLint *major, EGLint *minor ) */
1726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
1736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglInitialize
1746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jintArray major_ref, jint majorOffset, jintArray minor_ref, jint minorOffset) {
1756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
17615284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
17715284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
1786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
1796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
1806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *major_base = (EGLint *) 0;
1816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _majorRemaining;
1826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *major = (EGLint *) 0;
1836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *minor_base = (EGLint *) 0;
1846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _minorRemaining;
1856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *minor = (EGLint *) 0;
1866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
1876aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos    if (major_ref) {
1886aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (majorOffset < 0) {
1896aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
1906aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
1916aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "majorOffset < 0";
1926aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
1936aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
1946aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        _majorRemaining = _env->GetArrayLength(major_ref) - majorOffset;
1956aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (_majorRemaining < 1) {
1966aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
1976aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
1986aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "length - majorOffset < 1 < needed";
1996aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
2006aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
2016aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        major_base = (EGLint *)
2026aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _env->GetIntArrayElements(major_ref, (jboolean *)0);
2036aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        major = major_base + majorOffset;
2046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
2056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
2066aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos    if (minor_ref) {
2076aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (minorOffset < 0) {
2086aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
2096aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
2106aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "minorOffset < 0";
2116aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
2126aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
2136aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        _minorRemaining = _env->GetArrayLength(minor_ref) - minorOffset;
2146aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (_minorRemaining < 1) {
2156aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
2166aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
2176aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "length - minorOffset < 1 < needed";
2186aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
2196aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
2206aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        minor_base = (EGLint *)
2216aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _env->GetIntArrayElements(minor_ref, (jboolean *)0);
2226aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        minor = minor_base + minorOffset;
2236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
2246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
2256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglInitialize(
2266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
2276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)major,
2286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)minor
2296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
2306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
2316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
2326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (minor_base) {
2333b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(minor_ref, (jint*)minor_base,
2346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _exception ? JNI_ABORT: 0);
2356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
2366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (major_base) {
2373b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(major_ref, (jint*)major_base,
2386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _exception ? JNI_ABORT: 0);
2396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
2406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
2416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
2426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
243cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
2446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
2456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
2466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglTerminate ( EGLDisplay dpy ) */
2476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
2486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglTerminate
2496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy) {
2506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
2516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
2526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
2536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglTerminate(
2546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native
2556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
256cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
2576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
2586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
2596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* const char * eglQueryString ( EGLDisplay dpy, EGLint name ) */
2606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jstring
2616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQueryString__Landroind_opengl_EGLDisplay_2I
2626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jint name) {
2636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    const char* chars = (const char*) eglQueryString(
2646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)fromEGLHandle(_env, egldisplayGetHandleID, dpy),
2656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)name
2666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
2676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return _env->NewStringUTF(chars);
2686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
2696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglGetConfigs ( EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */
2706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
2716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetConfigs
2726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobjectArray configs_ref, jint configsOffset, jint config_size, jintArray num_config_ref, jint num_configOffset) {
2736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
27415284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
27515284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
2766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
2776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
2786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _configsRemaining;
2796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig *configs = (EGLConfig *) 0;
2806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *num_config_base = (EGLint *) 0;
2816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _num_configRemaining;
2826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *num_config = (EGLint *) 0;
2836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
2846aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos    if (configs_ref) {
2856aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (configsOffset < 0) {
2866aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
2876aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
2886aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "configsOffset < 0";
2896aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
2906aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
2916aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        _configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset;
2926aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (_configsRemaining < config_size) {
2936aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
2946aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
2956aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "length - configsOffset < config_size < needed";
2966aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
2976aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
2986aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        configs = new EGLConfig[_configsRemaining];
2996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
3016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!num_config_ref) {
3026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
3036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
3046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "num_config == null";
3056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
3066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (num_configOffset < 0) {
3086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
3096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
3106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "num_configOffset < 0";
3116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
3126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset;
3146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    num_config_base = (EGLint *)
3153b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(num_config_ref, (jboolean *)0);
3166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    num_config = num_config_base + num_configOffset;
3176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
3186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglGetConfigs(
3196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
3206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig *)configs,
3216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)config_size,
3226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)num_config
3236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
3246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
3256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
3266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (num_config_base) {
3273b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(num_config_ref, (jint*)num_config_base,
3286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _exception ? JNI_ABORT: 0);
3296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (configs) {
3316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        for (int i = 0; i < _configsRemaining; i++) {
3326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]);
3336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new);
3346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        }
3356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        delete[] configs;
3366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
3386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
3396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
340cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
3416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
3426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
3436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglChooseConfig ( EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config ) */
3446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
3456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglChooseConfig
3466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas 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) {
3476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
34815284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
34915284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
3506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
3516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
3526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    bool attrib_list_sentinel = false;
3536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list_base = (EGLint *) 0;
3546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _attrib_listRemaining;
3556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list = (EGLint *) 0;
3566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _configsRemaining;
3576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig *configs = (EGLConfig *) 0;
3586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *num_config_base = (EGLint *) 0;
3596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _num_configRemaining;
3606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *num_config = (EGLint *) 0;
3616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
3626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!attrib_list_ref) {
3636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
3646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
3656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "attrib_list == null";
3666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
3676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_listOffset < 0) {
3696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
3706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
3716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "attrib_listOffset < 0";
3726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
3736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _attrib_listRemaining = _env->GetArrayLength(attrib_list_ref) - attrib_listOffset;
3756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list_base = (EGLint *)
3763b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
3776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list = attrib_list_base + attrib_listOffset;
3786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list_sentinel = false;
3796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    for (int i = _attrib_listRemaining - 1; i >= 0; i--)  {
3806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        if (attrib_list[i] == EGL_NONE){
3816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            attrib_list_sentinel = true;
3826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            break;
3836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        }
3846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_sentinel == false) {
3866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
3876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
3886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "attrib_list must contain EGL_NONE!";
3896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
3906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
3916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
3926aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos    if (configs_ref) {
3936aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (configsOffset < 0) {
3946aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
3956aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
3966aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "configsOffset < 0";
3976aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
3986aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
3996aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        _configsRemaining = _env->GetArrayLength(configs_ref) - configsOffset;
4006aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (_configsRemaining < config_size) {
4016aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
4026aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
4036aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "length - configsOffset < config_size < needed";
4046aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
4056aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
4066aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        configs = new EGLConfig[_configsRemaining];
4076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
4096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!num_config_ref) {
4106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
4116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
4126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "num_config == null";
4136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
4146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (num_configOffset < 0) {
4166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
4176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
4186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "num_configOffset < 0";
4196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
4206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _num_configRemaining = _env->GetArrayLength(num_config_ref) - num_configOffset;
4226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_num_configRemaining < 1) {
4236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
4246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
4256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "length - num_configOffset < 1 < needed";
4266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
4276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    num_config_base = (EGLint *)
4293b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(num_config_ref, (jboolean *)0);
4306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    num_config = num_config_base + num_configOffset;
4316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
4326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglChooseConfig(
4336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
4346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)attrib_list,
4356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig *)configs,
4366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)config_size,
4376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)num_config
4386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
4396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
4406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
4416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (num_config_base) {
4423b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(num_config_ref, (jint*)num_config_base,
4436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _exception ? JNI_ABORT: 0);
4446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_base) {
4463b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(attrib_list_ref, (jint*)attrib_list_base,
4476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            JNI_ABORT);
4486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (configs) {
4506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        for (int i = 0; i < _configsRemaining; i++) {
4516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            jobject configs_new = toEGLHandle(_env, eglconfigClass, eglconfigConstructor, configs[i]);
4526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _env->SetObjectArrayElement(configs_ref, i + configsOffset, configs_new);
4536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        }
4546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        delete[] configs;
4556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
4576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
4586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
459cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
4606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
4616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
4626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglGetConfigAttrib ( EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value ) */
4636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
4646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetConfigAttrib
4656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint attribute, jintArray value_ref, jint offset) {
4666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
46715284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
46815284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
4696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
4706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
4716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
4726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *value_base = (EGLint *) 0;
4736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
4746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *value = (EGLint *) 0;
4756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
4766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!value_ref) {
4776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
4786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
4796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "value == null";
4806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
4816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (offset < 0) {
4836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
4846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
4856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "offset < 0";
4866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
4876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _remaining = _env->GetArrayLength(value_ref) - offset;
4896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_remaining < 1) {
4906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
4916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
4926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "length - offset < 1 < needed";
4936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
4946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
4956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    value_base = (EGLint *)
4963b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(value_ref, (jboolean *)0);
4976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    value = value_base + offset;
4986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
4996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglGetConfigAttrib(
5006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
5016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig)config_native,
5026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)attribute,
5036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)value
5046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
5056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
5066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
5076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (value_base) {
5083b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(value_ref, (jint*)value_base,
5096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _exception ? JNI_ABORT: 0);
5106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
5116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
5126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
5136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
514cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
5156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
5166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
5176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */
5186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
5196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreateWindowSurface
5206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) {
5216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
5226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    const char * _exceptionType = "";
5236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    const char * _exceptionMessage = "";
5246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface _returnValue = (EGLSurface) 0;
5256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
5266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
5276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    int attrib_list_sentinel = 0;
5286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list_base = (EGLint *) 0;
5296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
5306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list = (EGLint *) 0;
5316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    android::sp<ANativeWindow> window;
5326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
5336aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos    if (attrib_list_ref) {
5346aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (offset < 0) {
5356aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
5366aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
5376aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "offset < 0";
5386aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
5396aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
5406aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
5416aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list_base = (EGLint *)
5426aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
5436aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list = attrib_list_base + offset;
5446aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list_sentinel = 0;
5456aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        for (int i = _remaining - 1; i >= 0; i--)  {
5466aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            if (*((EGLint*)(attrib_list + i)) == EGL_NONE){
5476aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos                attrib_list_sentinel = 1;
5486aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos                break;
5496aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            }
5506aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
5516aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (attrib_list_sentinel == 0) {
5526aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
5536aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
5546aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "attrib_list must contain EGL_NONE!";
5556aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
5566aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
5576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
5586aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos
5596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (win == NULL) {
5606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofernot_valid_surface:
5616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
5626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
5636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface";
5646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
5656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
5666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
56764a55af0ac700baecb0877235eb42caac59a3560Jeff Brown    window = android::android_view_Surface_getNativeWindow(_env, win);
5686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
5696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (window == NULL)
5706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto not_valid_surface;
5716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
5726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglCreateWindowSurface(
5736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
5746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig)config_native,
5756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLNativeWindowType)window.get(),
5766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)attrib_list
5776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
5786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
5796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
5806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_base) {
5813b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
5826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            JNI_ABORT);
5836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
5846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
5856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
5866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
5876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
5886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
5896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
5906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreateWindowSurface ( EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list ) */
5916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
5926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreateWindowSurfaceTexture
5936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject win, jintArray attrib_list_ref, jint offset) {
5946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
5956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    const char * _exceptionType = "";
5966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    const char * _exceptionMessage = "";
5976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface _returnValue = (EGLSurface) 0;
5986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
5996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
6006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    int attrib_list_sentinel = 0;
6016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list_base = (EGLint *) 0;
6026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
6036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list = (EGLint *) 0;
6046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    android::sp<ANativeWindow> window;
60552a9a10b6b8c7b7a9f97777541841b94d4fd9754Mathias Agopian    android::sp<android::IGraphicBufferProducer> producer;
6066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
6076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!attrib_list_ref) {
6086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
6096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
6106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "attrib_list == null";
6116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
6126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
6136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (offset < 0) {
6146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
6156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
6166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "offset < 0";
6176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
6186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
6196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (win == NULL) {
6206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofernot_valid_surface:
6216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
6226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
6236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface";
6246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
6256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
62652a9a10b6b8c7b7a9f97777541841b94d4fd9754Mathias Agopian    producer = android::SurfaceTexture_getProducer(_env, win);
62782bb813f112d9565faa990e32dbe833f96461892Jamie Gennis
62852a9a10b6b8c7b7a9f97777541841b94d4fd9754Mathias Agopian    if (producer == NULL)
62982bb813f112d9565faa990e32dbe833f96461892Jamie Gennis        goto not_valid_surface;
63082bb813f112d9565faa990e32dbe833f96461892Jamie Gennis
631f933737784bea4e27b70522cfd34ddaa45481d12Takahiro Aizawa    window = new android::Surface(producer, true);
6326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
6336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (window == NULL)
6346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto not_valid_surface;
6356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
6366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
6376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list_base = (EGLint *)
6383b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
6396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list = attrib_list_base + offset;
6406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list_sentinel = 0;
6416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    for (int i = _remaining - 1; i >= 0; i--)  {
6426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        if (*((EGLint*)(attrib_list + i)) == EGL_NONE){
6436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            attrib_list_sentinel = 1;
6446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            break;
6456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        }
6466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
6476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_sentinel == 0) {
6486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
6496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
6506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "attrib_list must contain EGL_NONE!";
6516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
6526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
6536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
6546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglCreateWindowSurface(
6556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
6566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig)config_native,
6576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLNativeWindowType)window.get(),
6586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)attrib_list
6596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
6606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
6616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
6626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_base) {
6633b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
6646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            JNI_ABORT);
6656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
6666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
6676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
6686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
6696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
6706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
6716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreatePbufferSurface ( EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list ) */
6726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
6736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreatePbufferSurface
6746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jintArray attrib_list_ref, jint offset) {
6756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
67615284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
67715284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
6786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface _returnValue = (EGLSurface) 0;
6796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
6806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
6816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    bool attrib_list_sentinel = false;
6826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list_base = (EGLint *) 0;
6836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
6846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list = (EGLint *) 0;
6856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
6866aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos    if (attrib_list_ref) {
6876aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (offset < 0) {
6886aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
6896aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
6906aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "offset < 0";
6916aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
6926aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
6936aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
6946aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list_base = (EGLint *)
6956aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
6966aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list = attrib_list_base + offset;
6976aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list_sentinel = false;
6986aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        for (int i = _remaining - 1; i >= 0; i--)  {
6996aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            if (attrib_list[i] == EGL_NONE){
7006aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos                attrib_list_sentinel = true;
7016aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos                break;
7026aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            }
7036aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
7046aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (attrib_list_sentinel == false) {
7056aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
7066aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
7076aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "attrib_list must contain EGL_NONE!";
7086aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
7096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        }
7106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
7116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglCreatePbufferSurface(
7136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
7146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig)config_native,
7156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)attrib_list
7166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
7176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
7196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_base) {
7203b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(attrib_list_ref, (jint*)attrib_list_base,
7216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            JNI_ABORT);
7226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
7236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
7246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
7256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
7266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
7276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
7286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreatePixmapSurface ( EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list ) */
7306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
7316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreatePixmapSurface
7326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jint pixmap, jintArray attrib_list_ref, jint offset) {
7336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jniThrowException(_env, "java/lang/UnsupportedOperationException",
7346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        "eglCreatePixmapSurface");
7356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, (EGLSurface) 0);
7366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
7376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglDestroySurface ( EGLDisplay dpy, EGLSurface surface ) */
7396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
7406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglDestroySurface
7416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject surface) {
7426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
7436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
7446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
7456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglDestroySurface(
7476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
7486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)surface_native
7496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
750cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
7516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
7526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglQuerySurface ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value ) */
7546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
7556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQuerySurface
7566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jintArray value_ref, jint offset) {
7576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
75815284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
75915284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
7606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
7616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
7626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
7636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *value_base = (EGLint *) 0;
7646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
7656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *value = (EGLint *) 0;
7666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!value_ref) {
7686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
7696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
7706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "value == null";
7716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
7726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
7736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (offset < 0) {
7746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
7756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
7766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "offset < 0";
7776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
7786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
7796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _remaining = _env->GetArrayLength(value_ref) - offset;
7806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_remaining < 1) {
7816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
7826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
7836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "length - offset < 1 < needed";
7846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
7856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
7866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    value_base = (EGLint *)
7873b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(value_ref, (jboolean *)0);
7886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    value = value_base + offset;
7896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglQuerySurface(
7916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
7926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)surface_native,
7936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)attribute,
7946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)value
7956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
7966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
7976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
7986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (value_base) {
7993b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(value_ref, (jint*)value_base,
8006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _exception ? JNI_ABORT: 0);
8016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
8026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
8036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
8046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
805cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
8066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
8076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglBindAPI ( EGLenum api ) */
8096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
8106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglBindAPI
8116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jint api) {
8126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
8136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglBindAPI(
8146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLenum)api
8156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
816cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
8176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
8186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLenum eglQueryAPI ( void ) */
8206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jint
8216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQueryAPI
8226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this) {
8236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLenum _returnValue = (EGLenum) 0;
8246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglQueryAPI();
825cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jint)_returnValue;
8266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
8276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglWaitClient ( void ) */
8296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
8306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglWaitClient
8316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this) {
8326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
8336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglWaitClient();
834cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
8356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
8366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglReleaseThread ( void ) */
8386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
8396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglReleaseThread
8406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this) {
8416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
8426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglReleaseThread();
843cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
8446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
8456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */
8476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
8486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreatePbufferFromClientBuffer
84984bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat  (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jlong buffer, jobject config, jintArray attrib_list_ref, jint offset) {
8506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
85115284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
85215284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
8536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface _returnValue = (EGLSurface) 0;
8546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
8556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
8566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    bool attrib_list_sentinel = false;
8576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list_base = (EGLint *) 0;
8586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
8596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list = (EGLint *) 0;
8606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8616aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos    if (attrib_list_ref) {
8626aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (offset < 0) {
8636aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
8646aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
8656aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "offset < 0";
8666aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
8676aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
8686aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
8696aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list_base = (EGLint *)
8706aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
8716aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list = attrib_list_base + offset;
8726aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        attrib_list_sentinel = false;
8736aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        for (int i = _remaining - 1; i >= 0; i--)  {
8746aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            if (attrib_list[i] == EGL_NONE){
8756aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos                attrib_list_sentinel = true;
8766aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos                break;
8776aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            }
8786aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        }
8796aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos        if (attrib_list_sentinel == false) {
8806aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exception = 1;
8816aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionType = "java/lang/IllegalArgumentException";
8826aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            _exceptionMessage = "attrib_list must contain EGL_NONE!";
8836aff9068f91fdfef0bc55fda0721c180c0de9284Pablo Ceballos            goto exit;
8846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        }
8856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
8866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglCreatePbufferFromClientBuffer(
8886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
8896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLenum)buftype,
89084bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat        reinterpret_cast<EGLClientBuffer>(buffer),
8916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig)config_native,
8926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)attrib_list
8936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
8946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
8956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
8966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_base) {
8973b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base,
8986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            JNI_ABORT);
8996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
9006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
9016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
9026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
9036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
9046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
9056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
90684bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhatstatic jobject
90784bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhatandroid_eglCreatePbufferFromClientBufferInt
90884bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat  (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) {
90984bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    if(sizeof(void*) != sizeof(uint32_t)) {
91084bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat        jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePbufferFromClientBuffer");
91184bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat        return 0;
91284bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    }
91384bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat    return android_eglCreatePbufferFromClientBuffer(_env, _this, dpy, buftype, buffer, config, attrib_list_ref, offset);
91484bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat}
9156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglSurfaceAttrib ( EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value ) */
9166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
9176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglSurfaceAttrib
9186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint attribute, jint value) {
9196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
9206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
9216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
9226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglSurfaceAttrib(
9246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
9256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)surface_native,
9266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)attribute,
9276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)value
9286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
929cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
9306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
9316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglBindTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */
9336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
9346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglBindTexImage
9356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) {
9366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
9376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
9386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
9396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglBindTexImage(
9416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
9426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)surface_native,
9436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)buffer
9446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
945cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
9466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
9476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglReleaseTexImage ( EGLDisplay dpy, EGLSurface surface, EGLint buffer ) */
9496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
9506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglReleaseTexImage
9516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint buffer) {
9526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
9536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
9546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
9556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglReleaseTexImage(
9576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
9586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)surface_native,
9596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)buffer
9606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
961cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
9626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
9636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglSwapInterval ( EGLDisplay dpy, EGLint interval ) */
9656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
9666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglSwapInterval
9676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jint interval) {
9686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
9696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
9706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglSwapInterval(
9726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
9736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)interval
9746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
975cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
9766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
9776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLContext eglCreateContext ( EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list ) */
9796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
9806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCreateContext
9816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject share_context, jintArray attrib_list_ref, jint offset) {
9826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
98315284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
98415284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
9856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLContext _returnValue = (EGLContext) 0;
9866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
9876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
9886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLContext share_context_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, share_context);
9896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    bool attrib_list_sentinel = false;
9906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list_base = (EGLint *) 0;
9916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
9926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *attrib_list = (EGLint *) 0;
9936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
9946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!attrib_list_ref) {
9956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
9966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
9976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "attrib_list == null";
9986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
9996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
10006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (offset < 0) {
10016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
10026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
10036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "offset < 0";
10046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
10056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
10066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _remaining = _env->GetArrayLength(attrib_list_ref) - offset;
10076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list_base = (EGLint *)
10083b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0);
10096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list = attrib_list_base + offset;
10106b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    attrib_list_sentinel = false;
10116b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    for (int i = _remaining - 1; i >= 0; i--)  {
10126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        if (attrib_list[i] == EGL_NONE){
10136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            attrib_list_sentinel = true;
10146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            break;
10156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        }
10166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
10176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_sentinel == false) {
10186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
10196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
10206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "attrib_list must contain EGL_NONE!";
10216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
10226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
10236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglCreateContext(
10256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
10266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLConfig)config_native,
10276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLContext)share_context_native,
10286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)attrib_list
10296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
10306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
10326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (attrib_list_base) {
10333b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(attrib_list_ref, (jint*)attrib_list_base,
10346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            JNI_ABORT);
10356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
10366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
10376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
10386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
10396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue);
10406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
10416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglDestroyContext ( EGLDisplay dpy, EGLContext ctx ) */
10436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
10446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglDestroyContext
10456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject ctx) {
10466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
10476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
10486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx);
10496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglDestroyContext(
10516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
10526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLContext)ctx_native
10536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
1054cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
10556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
10566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10576b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglMakeCurrent ( EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx ) */
10586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
10596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglMakeCurrent
10606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject draw, jobject read, jobject ctx) {
10616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
10626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
10636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface draw_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, draw);
10646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface read_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, read);
10656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx);
10666b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglMakeCurrent(
10686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
10696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)draw_native,
10706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)read_native,
10716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLContext)ctx_native
10726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
1073cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
10746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
10756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLContext eglGetCurrentContext ( void ) */
10776b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
10786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetCurrentContext
10796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this) {
10806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLContext _returnValue = (EGLContext) 0;
10816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglGetCurrentContext();
10826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglcontextClass, eglcontextConstructor, _returnValue);
10836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
10846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLSurface eglGetCurrentSurface ( EGLint readdraw ) */
10866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
10876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetCurrentSurface
10886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jint readdraw) {
10896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface _returnValue = (EGLSurface) 0;
10906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglGetCurrentSurface(
10916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)readdraw
10926b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
10936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
10946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
10956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
10966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLDisplay eglGetCurrentDisplay ( void ) */
10976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jobject
10986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglGetCurrentDisplay
10996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this) {
11006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay _returnValue = (EGLDisplay) 0;
11016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglGetCurrentDisplay();
11026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
11036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
11046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglQueryContext ( EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value ) */
11066b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
11076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglQueryContext
11086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject ctx, jint attribute, jintArray value_ref, jint offset) {
11096b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _exception = 0;
111015284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionType = NULL;
111115284dee8efe6b4d1441ab040962077614b5061aMathias Agopian    const char * _exceptionMessage = NULL;
11126b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
11136b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
11146b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLContext ctx_native = (EGLContext) fromEGLHandle(_env, eglcontextGetHandleID, ctx);
11156b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *value_base = (EGLint *) 0;
11166b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jint _remaining;
11176b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLint *value = (EGLint *) 0;
11186b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11196b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (!value_ref) {
11206b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
11216b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
11226b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "value == null";
11236b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
11246b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
11256b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (offset < 0) {
11266b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
11276b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
11286b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "offset < 0";
11296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
11306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
11316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _remaining = _env->GetArrayLength(value_ref) - offset;
11326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_remaining < 1) {
11336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exception = 1;
11346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionType = "java/lang/IllegalArgumentException";
11356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        _exceptionMessage = "length - offset < 1 < needed";
11366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        goto exit;
11376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
11386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    value_base = (EGLint *)
11393b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->GetIntArrayElements(value_ref, (jboolean *)0);
11406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    value = value_base + offset;
11416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglQueryContext(
11436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
11446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLContext)ctx_native,
11456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)attribute,
11466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint *)value
11476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
11486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferexit:
11506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (value_base) {
11513b1d46e809ed38cd5662c110c511b8d98868ed72Hiroshi Yamauchi        _env->ReleaseIntArrayElements(value_ref, (jint*)value_base,
11526b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer            _exception ? JNI_ABORT: 0);
11536b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
11546b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    if (_exception) {
11556b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        jniThrowException(_env, _exceptionType, _exceptionMessage);
11566b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    }
1157cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
11586b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
11596b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11606b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglWaitGL ( void ) */
11616b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
11626b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglWaitGL
11636b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this) {
11646b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
11656b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglWaitGL();
1166cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
11676b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
11686b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11696b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglWaitNative ( EGLint engine ) */
11706b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
11716b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglWaitNative
11726b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jint engine) {
11736b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
11746b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglWaitNative(
11756b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLint)engine
11766b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
1177cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
11786b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
11796b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11806b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglSwapBuffers ( EGLDisplay dpy, EGLSurface surface ) */
11816b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
11826b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglSwapBuffers
11836b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject surface) {
11846b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLBoolean _returnValue = (EGLBoolean) 0;
11856b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
11866b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    EGLSurface surface_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, surface);
11876b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11886b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    _returnValue = eglSwapBuffers(
11896b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLDisplay)dpy_native,
11906b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        (EGLSurface)surface_native
11916b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    );
1192cee5198e7199fcbb131ff0d30165fb1d5c0107cfAndy McFadden    return (jboolean)_returnValue;
11936b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
11946b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
11956b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer/* EGLBoolean eglCopyBuffers ( EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target ) */
11966b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic jboolean
11976b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferandroid_eglCopyBuffers
11986b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer  (JNIEnv *_env, jobject _this, jobject dpy, jobject surface, jint target) {
11996b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    jniThrowException(_env, "java/lang/UnsupportedOperationException",
12006b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer        "eglCopyBuffers");
12016b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return (EGLBoolean) 0;
12026b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
12036b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
12046b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferstatic const char *classPathName = "android/opengl/EGL14";
12056b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
120676f6a86de25e1bf74717e047e55fd44b089673f3Daniel Micaystatic const JNINativeMethod methods[] = {
12076b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"_nativeClassInit", "()V", (void*)nativeClassInit },
12086b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetError", "()I", (void *) android_eglGetError },
120984bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat{"eglGetDisplay", "(I)Landroid/opengl/EGLDisplay;", (void *) android_eglGetDisplayInt },
121084bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat{"eglGetDisplay", "(J)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 },
122784bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IILandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBufferInt },
122884bbeb9e0c9c185a22d4882b79e0bc8a598642abAshok Bhat{"eglCreatePbufferFromClientBuffer", "(Landroid/opengl/EGLDisplay;IJLandroid/opengl/EGLConfig;[II)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePbufferFromClientBuffer },
12296b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglSurfaceAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;II)Z", (void *) android_eglSurfaceAttrib },
12306b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglBindTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglBindTexImage },
12316b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglReleaseTexImage", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglReleaseTexImage },
12326b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglSwapInterval", "(Landroid/opengl/EGLDisplay;I)Z", (void *) android_eglSwapInterval },
12336b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglCreateContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Landroid/opengl/EGLContext;[II)Landroid/opengl/EGLContext;", (void *) android_eglCreateContext },
12346b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglDestroyContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;)Z", (void *) android_eglDestroyContext },
12356b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglMakeCurrent", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;Landroid/opengl/EGLSurface;Landroid/opengl/EGLContext;)Z", (void *) android_eglMakeCurrent },
12366b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetCurrentContext", "()Landroid/opengl/EGLContext;", (void *) android_eglGetCurrentContext },
12376b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetCurrentSurface", "(I)Landroid/opengl/EGLSurface;", (void *) android_eglGetCurrentSurface },
12386b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglGetCurrentDisplay", "()Landroid/opengl/EGLDisplay;", (void *) android_eglGetCurrentDisplay },
12396b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglQueryContext", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLContext;I[II)Z", (void *) android_eglQueryContext },
12406b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglWaitGL", "()Z", (void *) android_eglWaitGL },
12416b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglWaitNative", "(I)Z", (void *) android_eglWaitNative },
12426b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglSwapBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;)Z", (void *) android_eglSwapBuffers },
12436b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{"eglCopyBuffers", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;I)Z", (void *) android_eglCopyBuffers },
12446b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer};
12456b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer
12466b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshoferint register_android_opengl_jni_EGL14(JNIEnv *_env)
12476b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer{
12486b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    int err;
12496b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));
12506b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer    return err;
12516b1e838fc16d397359f82c3a4f5700f1ed7dd910Thomas Tafertshofer}
1252