blob: fef8116dc93a29fc8f812c87de5209f153b3ee51 [file] [log] [blame]
Jesse Hall0c79d802013-04-30 13:46:28 -07001/*
2** Copyright 2013, The Android Open Source Project
3**
4** Licensed under the Apache License, Version 2.0 (the "License");
5** you may not use this file except in compliance with the License.
6** You may obtain a copy of the License at
7**
8** http://www.apache.org/licenses/LICENSE-2.0
9**
10** Unless required by applicable law or agreed to in writing, software
11** distributed under the License is distributed on an "AS IS" BASIS,
12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** See the License for the specific language governing permissions and
14** limitations under the License.
15*/
16
17// This source file is automatically generated
18
Andreas Gampebfe63332014-11-12 14:12:45 -080019#pragma GCC diagnostic ignored "-Wunused-variable"
Andreas Gampebfe63332014-11-12 14:12:45 -080020#pragma GCC diagnostic ignored "-Wunused-function"
21
Jesse Hall0c79d802013-04-30 13:46:28 -070022#include "jni.h"
Steven Moreland2279b252017-07-19 09:50:45 -070023#include <nativehelper/JNIHelp.h>
Jesse Hall0c79d802013-04-30 13:46:28 -070024#include <android_runtime/AndroidRuntime.h>
25#include <android_runtime/android_view_Surface.h>
26#include <android_runtime/android_graphics_SurfaceTexture.h>
27#include <utils/misc.h>
28
29#include <assert.h>
30#include <EGL/egl.h>
31#include <EGL/eglext.h>
32
33#include <gui/Surface.h>
34#include <gui/GLConsumer.h>
35#include <gui/Surface.h>
36
37#include <ui/ANativeObjectBase.h>
38
Jesse Hall0c79d802013-04-30 13:46:28 -070039static jclass egldisplayClass;
40static jclass eglcontextClass;
41static jclass eglsurfaceClass;
42static jclass eglconfigClass;
43
44static jmethodID egldisplayGetHandleID;
45static jmethodID eglcontextGetHandleID;
46static jmethodID eglsurfaceGetHandleID;
47static jmethodID eglconfigGetHandleID;
48
49static jmethodID egldisplayConstructor;
50static jmethodID eglcontextConstructor;
51static jmethodID eglsurfaceConstructor;
52static jmethodID eglconfigConstructor;
53
54static jobject eglNoContextObject;
55static jobject eglNoDisplayObject;
56static jobject eglNoSurfaceObject;
57
58
59
60/* Cache method IDs each time the class is loaded. */
61
62static void
63nativeClassInit(JNIEnv *_env, jclass glImplClass)
64{
65 jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay");
66 egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal);
67 jclass eglcontextClassLocal = _env->FindClass("android/opengl/EGLContext");
68 eglcontextClass = (jclass) _env->NewGlobalRef(eglcontextClassLocal);
69 jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface");
70 eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal);
71 jclass eglconfigClassLocal = _env->FindClass("android/opengl/EGLConfig");
72 eglconfigClass = (jclass) _env->NewGlobalRef(eglconfigClassLocal);
73
Ashok Bhat84bbeb92014-02-24 10:06:55 +000074 egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
75 eglcontextGetHandleID = _env->GetMethodID(eglcontextClass, "getNativeHandle", "()J");
76 eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
77 eglconfigGetHandleID = _env->GetMethodID(eglconfigClass, "getNativeHandle", "()J");
Jesse Hall0c79d802013-04-30 13:46:28 -070078
79
Ashok Bhat84bbeb92014-02-24 10:06:55 +000080 egldisplayConstructor = _env->GetMethodID(egldisplayClass, "<init>", "(J)V");
81 eglcontextConstructor = _env->GetMethodID(eglcontextClass, "<init>", "(J)V");
82 eglsurfaceConstructor = _env->GetMethodID(eglsurfaceClass, "<init>", "(J)V");
83 eglconfigConstructor = _env->GetMethodID(eglconfigClass, "<init>", "(J)V");
Jesse Hall0c79d802013-04-30 13:46:28 -070084
Jesse Hall0c79d802013-04-30 13:46:28 -070085
86 jclass eglClass = _env->FindClass("android/opengl/EGL14");
87 jfieldID noContextFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_CONTEXT", "Landroid/opengl/EGLContext;");
Sangkyu Leec56c7012014-11-07 18:54:59 +090088 jobject localeglNoContextObject = _env->GetStaticObjectField(eglClass, noContextFieldID);
89 eglNoContextObject = _env->NewGlobalRef(localeglNoContextObject);
Jesse Hall0c79d802013-04-30 13:46:28 -070090
91 jfieldID noDisplayFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_DISPLAY", "Landroid/opengl/EGLDisplay;");
Sangkyu Leec56c7012014-11-07 18:54:59 +090092 jobject localeglNoDisplayObject = _env->GetStaticObjectField(eglClass, noDisplayFieldID);
93 eglNoDisplayObject = _env->NewGlobalRef(localeglNoDisplayObject);
Jesse Hall0c79d802013-04-30 13:46:28 -070094
95 jfieldID noSurfaceFieldID = _env->GetStaticFieldID(eglClass, "EGL_NO_SURFACE", "Landroid/opengl/EGLSurface;");
Sangkyu Leec56c7012014-11-07 18:54:59 +090096 jobject localeglNoSurfaceObject = _env->GetStaticObjectField(eglClass, noSurfaceFieldID);
97 eglNoSurfaceObject = _env->NewGlobalRef(localeglNoSurfaceObject);
Jesse Hall0c79d802013-04-30 13:46:28 -070098}
99
100static void *
101fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
102 if (obj == NULL){
103 jniThrowException(_env, "java/lang/IllegalArgumentException",
104 "Object is set to null.");
Orion Hodsonc240f222019-02-26 18:05:03 +0000105 return nullptr;
Jesse Hall0c79d802013-04-30 13:46:28 -0700106 }
107
Ashok Bhat84bbeb92014-02-24 10:06:55 +0000108 return reinterpret_cast<void*>(_env->CallLongMethod(obj, mid));
Jesse Hall0c79d802013-04-30 13:46:28 -0700109}
110
111static jobject
112toEGLHandle(JNIEnv *_env, jclass cls, jmethodID con, void * handle) {
113 if (cls == eglcontextClass &&
114 (EGLContext)handle == EGL_NO_CONTEXT) {
115 return eglNoContextObject;
116 }
117
118 if (cls == egldisplayClass &&
119 (EGLDisplay)handle == EGL_NO_DISPLAY) {
120 return eglNoDisplayObject;
121 }
122
123 if (cls == eglsurfaceClass &&
124 (EGLSurface)handle == EGL_NO_SURFACE) {
125 return eglNoSurfaceObject;
126 }
127
Ashok Bhat84bbeb92014-02-24 10:06:55 +0000128 return _env->NewObject(cls, con, reinterpret_cast<jlong>(handle));
Jesse Hall0c79d802013-04-30 13:46:28 -0700129}
130
131// --------------------------------------------------------------------------
132/* EGLBoolean eglPresentationTimeANDROID ( EGLDisplay dpy, EGLSurface sur, EGLnsecsANDROID time ) */
133static jboolean
134android_eglPresentationTimeANDROID
135 (JNIEnv *_env, jobject _this, jobject dpy, jobject sur, jlong time) {
136 EGLBoolean _returnValue = (EGLBoolean) 0;
137 EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
138 EGLSurface sur_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, sur);
139
140 _returnValue = eglPresentationTimeANDROID(
141 (EGLDisplay)dpy_native,
142 (EGLSurface)sur_native,
143 (EGLnsecsANDROID)time
144 );
145 return (jboolean)_returnValue;
146}
147
148static const char *classPathName = "android/opengl/EGLExt";
149
Daniel Micay76f6a862015-09-19 17:31:01 -0400150static const JNINativeMethod methods[] = {
Jesse Hall0c79d802013-04-30 13:46:28 -0700151{"_nativeClassInit", "()V", (void*)nativeClassInit },
152{"eglPresentationTimeANDROID", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;J)Z", (void *) android_eglPresentationTimeANDROID },
153};
154
155int register_android_opengl_jni_EGLExt(JNIEnv *_env)
156{
157 int err;
158 err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));
159 return err;
160}