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 package android.opengl;
20 
21 import android.annotation.NonNull;
22 import android.hardware.SyncFence;
23 import android.os.ParcelFileDescriptor;
24 import android.util.Log;
25 
26 /**
27  * EGL Extensions
28  */
29 public class EGLExt {
30 
31     // EGL_KHR_create_context
32     public static final int EGL_CONTEXT_MAJOR_VERSION_KHR   = 0x3098;
33     public static final int EGL_CONTEXT_MINOR_VERSION_KHR   = 0x30FB;
34     public static final int EGL_CONTEXT_FLAGS_KHR           = 0x30FC;
35     public static final int EGL_OPENGL_ES3_BIT_KHR          = 0x0040;
36     public static final int EGL_RECORDABLE_ANDROID          = 0x3142;
37 
38     // EGL_ANDROID_native_fence_sync
39     public static final int EGL_SYNC_NATIVE_FENCE_ANDROID     = 0x3144;
40     public static final int EGL_SYNC_NATIVE_FENCE_FD_ANDROID  = 0x3145;
41     public static final int EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID = 0x3146;
42     public static final int EGL_NO_NATIVE_FENCE_FD_ANDROID    = -1;
43 
_nativeClassInit()44     native private static void _nativeClassInit();
45     static {
_nativeClassInit()46         _nativeClassInit();
47     }
48 
49     // C function EGLBoolean eglPresentationTimeANDROID ( EGLDisplay dpy, EGLSurface sur, EGLnsecsANDROID time )
50 
eglPresentationTimeANDROID( EGLDisplay dpy, EGLSurface sur, long time )51     public static native boolean eglPresentationTimeANDROID(
52         EGLDisplay dpy,
53         EGLSurface sur,
54         long time
55     );
56 
57     /**
58      * Retrieves the SyncFence for an EGLSync created with EGL_SYNC_NATIVE_FENCE_ANDROID
59      *
60      * See <a href="https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_native_fence_sync.txt">
61      *     EGL_ANDROID_native_fence_sync</a> extension for more details
62      * @param display The EGLDisplay connection
63      * @param sync The EGLSync to fetch the SyncFence from
64      * @return A SyncFence representing the native fence.
65      *       * If <sync> is not a valid sync object for <display>,
66      *         an {@link SyncFence#isValid() invalid} SyncFence is returned and an EGL_BAD_PARAMETER
67      *         error is generated.
68      *       * If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute of <sync> is
69      *         EGL_NO_NATIVE_FENCE_FD_ANDROID, an {@link SyncFence#isValid() invalid} SyncFence is
70      *         returned and an EGL_BAD_PARAMETER error is generated.
71      *       * If <display> does not match the display passed to eglCreateSync
72      *         when <sync> was created, the behaviour is undefined.
73      */
eglDupNativeFenceFDANDROID(@onNull EGLDisplay display, @NonNull EGLSync sync)74     public static @NonNull SyncFence eglDupNativeFenceFDANDROID(@NonNull EGLDisplay display,
75             @NonNull EGLSync sync) {
76         int fd = eglDupNativeFenceFDANDROIDImpl(display, sync);
77         Log.d("EGL", "eglDupNativeFence returned " + fd);
78         if (fd >= 0) {
79             return SyncFence.create(ParcelFileDescriptor.adoptFd(fd));
80         } else {
81             return SyncFence.createEmpty();
82         }
83     }
84 
eglDupNativeFenceFDANDROIDImpl(EGLDisplay display, EGLSync sync)85     private static native int eglDupNativeFenceFDANDROIDImpl(EGLDisplay display, EGLSync sync);
86 }
87