Update to EGL 1.5

Test: compile
Bug: 80239516
Change-Id: I1c00ac5e55900260b724e1c298edca15f87f3a01
(cherry picked from commit 63584195b9d15daa9973d280381fd619cd7a0f89)
This commit is contained in:
Courtney Goeltzenleuchter
2018-07-18 10:45:37 -06:00
parent 325dd4b6df
commit 367ed8b190
8 changed files with 849 additions and 0 deletions

View File

@@ -29714,6 +29714,65 @@ package android.opengl {
field public static final int EGL_WINDOW_BIT = 4; // 0x4
}
public class EGL15 {
ctor public EGL15();
method public static int eglClientWaitSync(android.opengl.EGLDisplay, android.opengl.EGLSync, int, long);
method public static android.opengl.EGLSurface eglCreatePlatformPixmapSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, java.nio.Buffer, long[], int);
method public static android.opengl.EGLSurface eglCreatePlatformWindowSurface(android.opengl.EGLDisplay, android.opengl.EGLConfig, java.nio.Buffer, long[], int);
method public static android.opengl.EGLSync eglCreateSync(android.opengl.EGLDisplay, int, long[], int);
method public static boolean eglDestroySync(android.opengl.EGLDisplay, android.opengl.EGLSync);
method public static android.opengl.EGLDisplay eglGetPlatformDisplay(int, long, long[], int);
method public static boolean eglGetSyncAttrib(android.opengl.EGLDisplay, android.opengl.EGLSync, int, long[], int);
method public static boolean eglWaitSync(android.opengl.EGLDisplay, android.opengl.EGLSync, int);
field public static final int EGL_CL_EVENT_HANDLE = 12444; // 0x309c
field public static final int EGL_CONDITION_SATISFIED = 12534; // 0x30f6
field public static final int EGL_CONTEXT_MAJOR_VERSION = 12440; // 0x3098
field public static final int EGL_CONTEXT_MINOR_VERSION = 12539; // 0x30fb
field public static final int EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT = 2; // 0x2
field public static final int EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT = 1; // 0x1
field public static final int EGL_CONTEXT_OPENGL_DEBUG = 12720; // 0x31b0
field public static final int EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE = 12721; // 0x31b1
field public static final int EGL_CONTEXT_OPENGL_PROFILE_MASK = 12541; // 0x30fd
field public static final int EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY = 12733; // 0x31bd
field public static final int EGL_CONTEXT_OPENGL_ROBUST_ACCESS = 12722; // 0x31b2
field public static final long EGL_FOREVER = -1L; // 0xffffffffffffffffL
field public static final int EGL_GL_COLORSPACE = 12445; // 0x309d
field public static final int EGL_GL_COLORSPACE_LINEAR = 12426; // 0x308a
field public static final int EGL_GL_COLORSPACE_SRGB = 12425; // 0x3089
field public static final int EGL_GL_RENDERBUFFER = 12473; // 0x30b9
field public static final int EGL_GL_TEXTURE_2D = 12465; // 0x30b1
field public static final int EGL_GL_TEXTURE_3D = 12466; // 0x30b2
field public static final int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 12468; // 0x30b4
field public static final int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 12470; // 0x30b6
field public static final int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 12472; // 0x30b8
field public static final int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X = 12467; // 0x30b3
field public static final int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 12469; // 0x30b5
field public static final int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 12471; // 0x30b7
field public static final int EGL_GL_TEXTURE_LEVEL = 12476; // 0x30bc
field public static final int EGL_GL_TEXTURE_ZOFFSET = 12477; // 0x30bd
field public static final int EGL_IMAGE_PRESERVED = 12498; // 0x30d2
field public static final int EGL_LOSE_CONTEXT_ON_RESET = 12735; // 0x31bf
field public static final android.opengl.EGLContext EGL_NO_CONTEXT;
field public static final android.opengl.EGLDisplay EGL_NO_DISPLAY;
field public static final android.opengl.EGLImage EGL_NO_IMAGE;
field public static final int EGL_NO_RESET_NOTIFICATION = 12734; // 0x31be
field public static final android.opengl.EGLSurface EGL_NO_SURFACE;
field public static final android.opengl.EGLSync EGL_NO_SYNC;
field public static final int EGL_OPENGL_ES3_BIT = 64; // 0x40
field public static final int EGL_PLATFORM_ANDROID_KHR = 12609; // 0x3141
field public static final int EGL_SIGNALED = 12530; // 0x30f2
field public static final int EGL_SYNC_CL_EVENT = 12542; // 0x30fe
field public static final int EGL_SYNC_CL_EVENT_COMPLETE = 12543; // 0x30ff
field public static final int EGL_SYNC_CONDITION = 12536; // 0x30f8
field public static final int EGL_SYNC_FENCE = 12537; // 0x30f9
field public static final int EGL_SYNC_FLUSH_COMMANDS_BIT = 1; // 0x1
field public static final int EGL_SYNC_PRIOR_COMMANDS_COMPLETE = 12528; // 0x30f0
field public static final int EGL_SYNC_STATUS = 12529; // 0x30f1
field public static final int EGL_SYNC_TYPE = 12535; // 0x30f7
field public static final int EGL_TIMEOUT_EXPIRED = 12533; // 0x30f5
field public static final int EGL_UNSIGNALED = 12531; // 0x30f3
}
public class EGLConfig extends android.opengl.EGLObjectHandle {
}
@@ -29733,6 +29792,9 @@ package android.opengl {
field public static final int EGL_RECORDABLE_ANDROID = 12610; // 0x3142
}
public class EGLImage extends android.opengl.EGLObjectHandle {
}
public abstract class EGLObjectHandle {
ctor protected deprecated EGLObjectHandle(int);
ctor protected EGLObjectHandle(long);
@@ -29743,6 +29805,9 @@ package android.opengl {
public class EGLSurface extends android.opengl.EGLObjectHandle {
}
public class EGLSync extends android.opengl.EGLObjectHandle {
}
public class ETC1 {
ctor public ETC1();
method public static void decodeBlock(java.nio.Buffer, java.nio.Buffer);

View File

@@ -2354,6 +2354,7 @@ android.nfc.NfcAdapter$1
android.nfc.NfcAdapter$CreateNdefMessageCallback
android.nfc.NfcManager
android.opengl.EGL14
android.opengl.EGL15
android.opengl.EGLConfig
android.opengl.EGLContext
android.opengl.EGLDisplay

View File

@@ -45,6 +45,7 @@ cc_library_shared {
"android_app_NativeActivity.cpp",
"android_app_admin_SecurityLog.cpp",
"android_opengl_EGL14.cpp",
"android_opengl_EGL15.cpp",
"android_opengl_EGLExt.cpp",
"android_opengl_GLES10.cpp",
"android_opengl_GLES10Ext.cpp",

View File

@@ -77,6 +77,7 @@ extern int register_android_graphics_YuvImage(JNIEnv* env);
extern int register_com_google_android_gles_jni_EGLImpl(JNIEnv* env);
extern int register_com_google_android_gles_jni_GLImpl(JNIEnv* env);
extern int register_android_opengl_jni_EGL14(JNIEnv* env);
extern int register_android_opengl_jni_EGL15(JNIEnv* env);
extern int register_android_opengl_jni_EGLExt(JNIEnv* env);
extern int register_android_opengl_jni_GLES10(JNIEnv* env);
extern int register_android_opengl_jni_GLES10Ext(JNIEnv* env);
@@ -1367,6 +1368,7 @@ static const RegJNIRec gRegJNI[] = {
REG_JNI(register_com_google_android_gles_jni_EGLImpl),
REG_JNI(register_com_google_android_gles_jni_GLImpl),
REG_JNI(register_android_opengl_jni_EGL14),
REG_JNI(register_android_opengl_jni_EGL15),
REG_JNI(register_android_opengl_jni_EGLExt),
REG_JNI(register_android_opengl_jni_GLES10),
REG_JNI(register_android_opengl_jni_GLES10Ext),

View File

@@ -0,0 +1,557 @@
/*
** Copyright 2018, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-function"
#include "jni.h"
#include <nativehelper/JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
#include <assert.h>
#include <EGL/egl.h>
#include <ui/ANativeObjectBase.h>
static int initialized = 0;
// classes from EGL 1.4
static jclass egldisplayClass;
static jclass eglsurfaceClass;
static jclass eglconfigClass;
static jclass eglcontextClass;
static jclass bufferClass;
static jclass nioAccessClass;
static jfieldID positionID;
static jfieldID limitID;
static jfieldID elementSizeShiftID;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
static jmethodID egldisplayGetHandleID;
static jmethodID eglconfigGetHandleID;
static jmethodID eglcontextGetHandleID;
static jmethodID eglsurfaceGetHandleID;
static jmethodID egldisplayConstructor;
static jmethodID eglcontextConstructor;
static jmethodID eglsurfaceConstructor;
static jmethodID eglconfigConstructor;
static jobject eglNoContextObject;
static jobject eglNoDisplayObject;
static jobject eglNoSurfaceObject;
// classes from EGL 1.5
static jclass eglimageClass;
static jclass eglsyncClass;
static jmethodID eglimageGetHandleID;
static jmethodID eglsyncGetHandleID;
static jmethodID eglimageConstructor;
static jmethodID eglsyncConstructor;
static jobject eglNoImageObject;
static jobject eglNoSyncObject;
/* Cache method IDs each time the class is loaded. */
static void
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
// EGL 1.4 Init
jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext");
eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal);
jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay");
egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal);
jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface");
eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal);
eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
jobject localeglNoContextObject = _env->NewObject(eglcontextClass, eglcontextConstructor, reinterpret_cast<jlong>(EGL_NO_CONTEXT));
eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
jobject localeglNoDisplayObject = _env->NewObject(egldisplayClass, egldisplayConstructor, reinterpret_cast<jlong>(EGL_NO_DISPLAY));
eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
jobject localeglNoSurfaceObject = _env->NewObject(eglsurfaceClass, eglsurfaceConstructor, reinterpret_cast<jlong>(EGL_NO_SURFACE));
eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
jclass eglClass = _env->FindClass("android/opengl/EGL15");
jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;");
_env->SetStaticObjectField(eglClass, noContextFieldID, eglNoContextObject);
jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;");
_env->SetStaticObjectField(eglClass, noDisplayFieldID, eglNoDisplayObject);
jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;");
_env->SetStaticObjectField(eglClass, noSurfaceFieldID, eglNoSurfaceObject);
// EGL 1.5 init
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
jclass bufferClassLocal = _env->FindClass("java/nio/Buffer");
bufferClass = (jclass) _env->NewGlobalRef(bufferClassLocal);
getBasePointerID = _env->GetStaticMethodID(nioAccessClass,
"getBasePointer", "(Ljava/nio/Buffer;)J");
getBaseArrayID = _env->GetStaticMethodID(nioAccessClass,
"getBaseArray", "(Ljava/nio/Buffer;)Ljava/lang/Object;");
getBaseArrayOffsetID = _env->GetStaticMethodID(nioAccessClass,
"getBaseArrayOffset", "(Ljava/nio/Buffer;)I");
positionID = _env->GetFieldID(bufferClass, "position", "I");
limitID = _env->GetFieldID(bufferClass, "limit", "I");
elementSizeShiftID =
_env->GetFieldID(bufferClass, "_elementSizeShift", "I");
jclass eglimageClassLocal = _env->FindClass("android/opengl/EGLImage");
eglimageClass = (jclass) _env->NewGlobalRef(eglimageClassLocal);
jclass eglsyncClassLocal = _env->FindClass("android/opengl/EGLSync");
eglsyncClass = (jclass) _env->NewGlobalRef(eglsyncClassLocal);
eglimageGetHandleID = _env->GetMethodID(eglimageClass, "getNativeHandle", "()J");
eglsyncGetHandleID = _env->GetMethodID(eglsyncClass, "getNativeHandle", "()J");
eglimageConstructor = _env->GetMethodID(eglimageClass, "<init>", "(J)V");
eglsyncConstructor = _env->GetMethodID(eglsyncClass, "<init>", "(J)V");
jfieldID noImageFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_IMAGE", "Landroid/opengl/EGLImage;");
_env->SetStaticObjectField(eglClass, noImageFieldID, eglNoImageObject);
jfieldID noSyncFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SYNC", "Landroid/opengl/EGLSync;");
_env->SetStaticObjectField(eglClass, noSyncFieldID, eglNoSyncObject);
}
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
position = _env->GetIntField(buffer, positionID);
limit = _env->GetIntField(buffer, limitID);
elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
*remaining = (limit - position) << elementSizeShift;
pointer = _env->CallStaticLongMethod(nioAccessClass,
getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
return reinterpret_cast<void*>(pointer);
}
eglimageGetHandleID = _env->GetMethodID(eglimageClass, "getNativeHandle", "()J");
eglsyncGetHandleID = _env->GetMethodID(eglsyncClass, "getNativeHandle", "()J");
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
*offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
return NULL;
}
static void
releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
{
_env->ReleasePrimitiveArrayCritical(array, data,
commit ? 0 : JNI_ABORT);
}
static void *
fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
if (obj == NULL){
jniThrowException(_env, "java/lang/IllegalArgumentException",
"Object is set to null.");
}
jlong handle = _env->CallLongMethod(obj, mid);
return reinterpret_cast<void*>(handle);
}
static jobject
toEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) {
if (cls == eglimageClass &&
(EGLImage)handle == EGL_NO_IMAGE) {
return eglNoImageObject;
}
return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
}
// --------------------------------------------------------------------------
/* EGLSync eglCreateSync ( EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list ) */
static jobject
android_eglCreateSync
(JNIEnv *_env, jobject _this, jobject dpy, jint type, jlongArray attrib_list_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
EGLSync _returnValue = (EGLSync) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLAttrib *attrib_list_base = (EGLAttrib *) 0;
jint _remaining;
EGLAttrib *attrib_list = (EGLAttrib *) 0;
if (!attrib_list_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(attrib_list_ref) - offset;
attrib_list_base = (EGLAttrib *)
_env->GetLongArrayElements(attrib_list_ref, (jboolean *)0);
attrib_list = attrib_list_base + offset;
_returnValue = eglCreateSync(
(EGLDisplay)dpy_native,
(EGLenum)type,
(EGLAttrib *)attrib_list
);
exit:
if (attrib_list_base) {
_env->ReleaseLongArrayElements(attrib_list_ref, (jlong*)attrib_list_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return toEGLHandle(_env, eglsyncClass, eglsyncConstructor, _returnValue);
}
/* EGLBoolean eglDestroySync ( EGLDisplay dpy, EGLSync sync ) */
static jboolean
android_eglDestroySync
(JNIEnv *_env, jobject _this, jobject dpy, jobject sync) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSync sync_native = (EGLSync) fromEGLHandle(_env, eglsyncGetHandleID, sync);
_returnValue = eglDestroySync(
(EGLDisplay)dpy_native,
(EGLSync)sync_native
);
return (jboolean)_returnValue;
}
/* EGLint eglClientWaitSync ( EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout ) */
static jint
android_eglClientWaitSync
(JNIEnv *_env, jobject _this, jobject dpy, jobject sync, jint flags, jlong timeout) {
EGLint _returnValue = (EGLint) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSync sync_native = (EGLSync) fromEGLHandle(_env, eglsyncGetHandleID, sync);
_returnValue = eglClientWaitSync(
(EGLDisplay)dpy_native,
(EGLSync)sync_native,
(EGLint)flags,
(EGLTime)timeout
);
return (jint)_returnValue;
}
/* EGLBoolean eglGetSyncAttrib ( EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value ) */
static jboolean
android_eglGetSyncAttrib
(JNIEnv *_env, jobject _this, jobject dpy, jobject sync, jint attribute, jlongArray value_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSync sync_native = (EGLSync) fromEGLHandle(_env, eglsyncGetHandleID, sync);
EGLAttrib *value_base = (EGLAttrib *) 0;
jint _remaining;
EGLAttrib *value = (EGLAttrib *) 0;
if (!value_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "value == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(value_ref) - offset;
value_base = (EGLAttrib *)
_env->GetLongArrayElements(value_ref, (jboolean *)0);
value = value_base + offset;
_returnValue = eglGetSyncAttrib(
(EGLDisplay)dpy_native,
(EGLSync)sync_native,
(EGLint)attribute,
(EGLAttrib *)value
);
exit:
if (value_base) {
_env->ReleaseLongArrayElements(value_ref, (jlong*)value_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return (jboolean)_returnValue;
}
/* EGLDisplay eglGetPlatformDisplay ( EGLenum platform, EGLAttrib native_display, const EGLAttrib *attrib_list ) */
static jobject
android_eglGetPlatformDisplay
(JNIEnv *_env, jobject _this, jint platform, jlong native_display, jlongArray attrib_list_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
EGLDisplay _returnValue = (EGLDisplay) 0;
EGLAttrib *attrib_list_base = (EGLAttrib *) 0;
jint _remaining;
EGLAttrib *attrib_list = (EGLAttrib *) 0;
if (!attrib_list_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(attrib_list_ref) - offset;
attrib_list_base = (EGLAttrib *)
_env->GetLongArrayElements(attrib_list_ref, (jboolean *)0);
attrib_list = attrib_list_base + offset;
_returnValue = eglGetPlatformDisplay(
(EGLenum)platform,
(void *)native_display,
(EGLAttrib *)attrib_list
);
exit:
if (attrib_list_base) {
_env->ReleaseLongArrayElements(attrib_list_ref, (jlong*)attrib_list_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return toEGLHandle(_env, egldisplayClass, egldisplayConstructor, _returnValue);
}
/* EGLSurface eglCreatePlatformWindowSurface ( EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list ) */
static jobject
android_eglCreatePlatformWindowSurface
(JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject native_window_buf, jlongArray attrib_list_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jarray _array = (jarray) 0;
jint _bufferOffset = (jint) 0;
EGLSurface _returnValue = (EGLSurface) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
jint _native_windowRemaining;
void *native_window = (void *) 0;
EGLAttrib *attrib_list_base = (EGLAttrib *) 0;
jint _attrib_listRemaining;
EGLAttrib *attrib_list = (EGLAttrib *) 0;
if (!native_window_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "native_window == null";
goto exit;
}
native_window = (void *)getPointer(_env, native_window_buf, (jarray*)&_array, &_native_windowRemaining, &_bufferOffset);
if (!attrib_list_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_attrib_listRemaining = _env->GetArrayLength(attrib_list_ref) - offset;
attrib_list_base = (EGLAttrib *)
_env->GetLongArrayElements(attrib_list_ref, (jboolean *)0);
attrib_list = attrib_list_base + offset;
if (native_window == NULL) {
char * _native_windowBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
native_window = (void *) (_native_windowBase + _bufferOffset);
}
_returnValue = eglCreatePlatformWindowSurface(
(EGLDisplay)dpy_native,
(EGLConfig)config_native,
(void *)native_window,
(EGLAttrib *)attrib_list
);
exit:
if (attrib_list_base) {
_env->ReleaseLongArrayElements(attrib_list_ref, (jlong*)attrib_list_base,
JNI_ABORT);
}
if (_array) {
releasePointer(_env, _array, native_window, _exception ? JNI_FALSE : JNI_TRUE);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
/* EGLSurface eglCreatePlatformPixmapSurface ( EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list ) */
static jobject
android_eglCreatePlatformPixmapSurface
(JNIEnv *_env, jobject _this, jobject dpy, jobject config, jobject native_pixmap_buf, jlongArray attrib_list_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jarray _array = (jarray) 0;
jint _bufferOffset = (jint) 0;
EGLSurface _returnValue = (EGLSurface) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config);
jint _native_pixmapRemaining;
void *native_pixmap = (void *) 0;
EGLAttrib *attrib_list_base = (EGLAttrib *) 0;
jint _attrib_listRemaining;
EGLAttrib *attrib_list = (EGLAttrib *) 0;
if (!native_pixmap_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "native_pixmap == null";
goto exit;
}
native_pixmap = (void *)getPointer(_env, native_pixmap_buf, (jarray*)&_array, &_native_pixmapRemaining, &_bufferOffset);
if (!attrib_list_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "attrib_list == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_attrib_listRemaining = _env->GetArrayLength(attrib_list_ref) - offset;
attrib_list_base = (EGLAttrib *)
_env->GetLongArrayElements(attrib_list_ref, (jboolean *)0);
attrib_list = attrib_list_base + offset;
if (native_pixmap == NULL) {
char * _native_pixmapBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
native_pixmap = (void *) (_native_pixmapBase + _bufferOffset);
}
_returnValue = eglCreatePlatformPixmapSurface(
(EGLDisplay)dpy_native,
(EGLConfig)config_native,
(void *)native_pixmap,
(EGLAttrib *)attrib_list
);
exit:
if (attrib_list_base) {
_env->ReleaseLongArrayElements(attrib_list_ref, (jlong*)attrib_list_base,
JNI_ABORT);
}
if (_array) {
releasePointer(_env, _array, native_pixmap, _exception ? JNI_FALSE : JNI_TRUE);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue);
}
/* EGLBoolean eglWaitSync ( EGLDisplay dpy, EGLSync sync, EGLint flags ) */
static jboolean
android_eglWaitSync
(JNIEnv *_env, jobject _this, jobject dpy, jobject sync, jint flags) {
EGLBoolean _returnValue = (EGLBoolean) 0;
EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
EGLSync sync_native = (EGLSync) fromEGLHandle(_env, eglsyncGetHandleID, sync);
_returnValue = eglWaitSync(
(EGLDisplay)dpy_native,
(EGLSync)sync_native,
(EGLint)flags
);
return (jboolean)_returnValue;
}
static const char *classPathName = "android/opengl/EGL15";
static const JNINativeMethod methods[] = {
{"_nativeClassInit", "()V", (void*)nativeClassInit },
{"eglCreateSync", "(Landroid/opengl/EGLDisplay;I[JI)Landroid/opengl/EGLSync;", (void *) android_eglCreateSync },
{"eglDestroySync", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSync;)Z", (void *) android_eglDestroySync },
{"eglClientWaitSync", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSync;IJ)I", (void *) android_eglClientWaitSync },
{"eglGetSyncAttrib", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSync;I[JI)Z", (void *) android_eglGetSyncAttrib },
{"eglGetPlatformDisplay", "(IJ[JI)Landroid/opengl/EGLDisplay;", (void *) android_eglGetPlatformDisplay },
{"eglCreatePlatformWindowSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/nio/Buffer;[JI)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePlatformWindowSurface },
{"eglCreatePlatformPixmapSurface", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLConfig;Ljava/nio/Buffer;[JI)Landroid/opengl/EGLSurface;", (void *) android_eglCreatePlatformPixmapSurface },
{"eglWaitSync", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSync;I)Z", (void *) android_eglWaitSync },
};
int register_android_opengl_jni_EGL15(JNIEnv *_env)
{
int err;
err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));
return err;
}

View File

@@ -0,0 +1,149 @@
/*
** Copyright 2018, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package android.opengl;
/**
* EGL 1.5
*
*/
public class EGL15 {
public static final int EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT = 0x00000001;
public static final int EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT = 0x00000002;
public static final int EGL_OPENGL_ES3_BIT = 0x00000040;
public static final int EGL_SYNC_FLUSH_COMMANDS_BIT = 0x0001;
public static final int EGL_GL_COLORSPACE_SRGB = 0x3089;
public static final int EGL_GL_COLORSPACE_LINEAR = 0x308A;
public static final int EGL_CONTEXT_MAJOR_VERSION = 0x3098;
public static final int EGL_CL_EVENT_HANDLE = 0x309C;
public static final int EGL_GL_COLORSPACE = 0x309D;
public static final int EGL_GL_TEXTURE_2D = 0x30B1;
public static final int EGL_GL_TEXTURE_3D = 0x30B2;
public static final int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x30B3;
public static final int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x30B4;
public static final int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x30B5;
public static final int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x30B6;
public static final int EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x30B7;
public static final int EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x30B8;
public static final int EGL_GL_RENDERBUFFER = 0x30B9;
public static final int EGL_GL_TEXTURE_LEVEL = 0x30BC;
public static final int EGL_GL_TEXTURE_ZOFFSET = 0x30BD;
public static final int EGL_IMAGE_PRESERVED = 0x30D2;
public static final int EGL_SYNC_PRIOR_COMMANDS_COMPLETE = 0x30F0;
public static final int EGL_SYNC_STATUS = 0x30F1;
public static final int EGL_SIGNALED = 0x30F2;
public static final int EGL_UNSIGNALED = 0x30F3;
public static final int EGL_TIMEOUT_EXPIRED = 0x30F5;
public static final int EGL_CONDITION_SATISFIED = 0x30F6;
public static final int EGL_SYNC_TYPE = 0x30F7;
public static final int EGL_SYNC_CONDITION = 0x30F8;
public static final int EGL_SYNC_FENCE = 0x30F9;
public static final int EGL_CONTEXT_MINOR_VERSION = 0x30FB;
public static final int EGL_CONTEXT_OPENGL_PROFILE_MASK = 0x30FD;
public static final int EGL_SYNC_CL_EVENT = 0x30FE;
public static final int EGL_SYNC_CL_EVENT_COMPLETE = 0x30FF;
public static final int EGL_CONTEXT_OPENGL_DEBUG = 0x31B0;
public static final int EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE = 0x31B1;
public static final int EGL_CONTEXT_OPENGL_ROBUST_ACCESS = 0x31B2;
public static final int EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY = 0x31BD;
public static final int EGL_NO_RESET_NOTIFICATION = 0x31BE;
public static final int EGL_LOSE_CONTEXT_ON_RESET = 0x31BF;
public static final int EGL_PLATFORM_ANDROID_KHR = 0x3141;
public static final long EGL_FOREVER = 0xFFFFFFFFFFFFFFFFL;
public static final EGLImage EGL_NO_IMAGE = null;
public static final EGLSync EGL_NO_SYNC = null;
public static final EGLContext EGL_NO_CONTEXT = null;
public static final EGLDisplay EGL_NO_DISPLAY = null;
public static final EGLSurface EGL_NO_SURFACE = null;
native private static void _nativeClassInit();
static {
_nativeClassInit();
}
// C function EGLSync eglCreateSync ( EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list )
public static native EGLSync eglCreateSync(
EGLDisplay dpy,
int type,
long[] attrib_list,
int offset
);
// C function EGLBoolean eglDestroySync ( EGLDisplay dpy, EGLSync sync )
public static native boolean eglDestroySync(
EGLDisplay dpy,
EGLSync sync
);
// C function EGLint eglClientWaitSync ( EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout )
public static native int eglClientWaitSync(
EGLDisplay dpy,
EGLSync sync,
int flags,
long timeout
);
// C function EGLBoolean eglGetSyncAttrib ( EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value )
public static native boolean eglGetSyncAttrib(
EGLDisplay dpy,
EGLSync sync,
int attribute,
long[] value,
int offset
);
// C function EGLDisplay eglGetPlatformDisplay ( EGLenum platform, EGLAttrib native_display, const EGLAttrib *attrib_list )
public static native EGLDisplay eglGetPlatformDisplay(
int platform,
long native_display,
long[] attrib_list,
int offset
);
// C function EGLSurface eglCreatePlatformWindowSurface ( EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list )
public static native EGLSurface eglCreatePlatformWindowSurface(
EGLDisplay dpy,
EGLConfig config,
java.nio.Buffer native_window,
long[] attrib_list,
int offset
);
// C function EGLSurface eglCreatePlatformPixmapSurface ( EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list )
public static native EGLSurface eglCreatePlatformPixmapSurface(
EGLDisplay dpy,
EGLConfig config,
java.nio.Buffer native_pixmap,
long[] attrib_list,
int offset
);
// C function EGLBoolean eglWaitSync ( EGLDisplay dpy, EGLSync sync, EGLint flags )
public static native boolean eglWaitSync(
EGLDisplay dpy,
EGLSync sync,
int flags
);
}

View File

@@ -0,0 +1,37 @@
/*
**
** Copyright 2018, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package android.opengl;
/**
* Wrapper class for native EGLImage objects.
*
*/
public class EGLImage extends EGLObjectHandle {
private EGLImage(long handle) {
super(handle);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof EGLImage)) return false;
EGLImage that = (EGLImage) o;
return getNativeHandle() == that.getNativeHandle();
}
}

View File

@@ -0,0 +1,37 @@
/*
**
** Copyright 2018, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
package android.opengl;
/**
* Wrapper class for native EGLSync objects.
*
*/
public class EGLSync extends EGLObjectHandle {
private EGLSync(long handle) {
super(handle);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof EGLSync)) return false;
EGLSync that = (EGLSync) o;
return getNativeHandle() == that.getNativeHandle();
}
}