• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
19 #pragma GCC diagnostic ignored "-Wunused-variable"
20 #pragma GCC diagnostic ignored "-Wunused-function"
21 
22 #include "jni.h"
23 #include <nativehelper/JNIPlatformHelp.h>
24 #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 
39 static jclass egldisplayClass;
40 static jclass eglsurfaceClass;
41 static jclass eglsyncClass;
42 
43 static jmethodID egldisplayGetHandleID;
44 static jmethodID eglsurfaceGetHandleID;
45 static jmethodID eglsyncGetHandleID;
46 
47 /* Cache method IDs each time the class is loaded. */
48 
49 static void
nativeClassInit(JNIEnv * _env,jclass glImplClass)50 nativeClassInit(JNIEnv *_env, jclass glImplClass)
51 {
52     jclass egldisplayClassLocal = _env->FindClass("android/opengl/EGLDisplay");
53     egldisplayClass = (jclass) _env->NewGlobalRef(egldisplayClassLocal);
54     jclass eglsurfaceClassLocal = _env->FindClass("android/opengl/EGLSurface");
55     eglsurfaceClass = (jclass) _env->NewGlobalRef(eglsurfaceClassLocal);
56     jclass eglsyncClassLocal = _env->FindClass("android/opengl/EGLSync");
57     eglsyncClass = (jclass)_env->NewGlobalRef(eglsyncClassLocal);
58 
59     egldisplayGetHandleID = _env->GetMethodID(egldisplayClass, "getNativeHandle", "()J");
60     eglsurfaceGetHandleID = _env->GetMethodID(eglsurfaceClass, "getNativeHandle", "()J");
61     eglsyncGetHandleID = _env->GetMethodID(eglsyncClassLocal, "getNativeHandle", "()J");
62 }
63 
64 static void *
fromEGLHandle(JNIEnv * _env,jmethodID mid,jobject obj)65 fromEGLHandle(JNIEnv *_env, jmethodID mid, jobject obj) {
66     if (obj == NULL){
67         jniThrowException(_env, "java/lang/IllegalArgumentException",
68                           "Object is set to null.");
69         return nullptr;
70     }
71 
72     return reinterpret_cast<void*>(_env->CallLongMethod(obj, mid));
73 }
74 
75 // --------------------------------------------------------------------------
76 /* EGLBoolean eglPresentationTimeANDROID ( EGLDisplay dpy, EGLSurface sur, EGLnsecsANDROID time ) */
77 static jboolean
android_eglPresentationTimeANDROID(JNIEnv * _env,jobject _this,jobject dpy,jobject sur,jlong time)78 android_eglPresentationTimeANDROID
79   (JNIEnv *_env, jobject _this, jobject dpy, jobject sur, jlong time) {
80     EGLBoolean _returnValue = (EGLBoolean) 0;
81     EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy);
82     EGLSurface sur_native = (EGLSurface) fromEGLHandle(_env, eglsurfaceGetHandleID, sur);
83 
84     _returnValue = eglPresentationTimeANDROID(
85         (EGLDisplay)dpy_native,
86         (EGLSurface)sur_native,
87         (EGLnsecsANDROID)time
88     );
89     return (jboolean)_returnValue;
90 }
91 
android_eglDupNativeFenceFDANDROID(JNIEnv * env,jobject,jobject dpy,jobject sync)92 static jint android_eglDupNativeFenceFDANDROID(JNIEnv *env, jobject, jobject dpy, jobject sync) {
93     EGLDisplay dpy_native = (EGLDisplay)fromEGLHandle(env, egldisplayGetHandleID, dpy);
94     EGLSync sync_native = (EGLSync)fromEGLHandle(env, eglsyncGetHandleID, sync);
95 
96     return eglDupNativeFenceFDANDROID(dpy_native, sync_native);
97 }
98 
99 static const char *classPathName = "android/opengl/EGLExt";
100 
101 static const JNINativeMethod methods[] = {
102         {"_nativeClassInit", "()V", (void *)nativeClassInit},
103         {"eglPresentationTimeANDROID", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSurface;J)Z",
104          (void *)android_eglPresentationTimeANDROID},
105         {"eglDupNativeFenceFDANDROIDImpl", "(Landroid/opengl/EGLDisplay;Landroid/opengl/EGLSync;)I",
106          (void *)android_eglDupNativeFenceFDANDROID},
107 };
108 
register_android_opengl_jni_EGLExt(JNIEnv * _env)109 int register_android_opengl_jni_EGLExt(JNIEnv *_env)
110 {
111     int err;
112     err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));
113     return err;
114 }
115