2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "jni_egl_fence.h"
19 #include <cutils/log.h>
21 #include <EGL/eglext.h>
24 Java_com_android_gallery3d_photoeditor_FilterStack_nativeEglSetFenceAndWait(JNIEnv* env,
26 EGLDisplay display = eglGetCurrentDisplay();
28 // Create a egl fence and wait for egl to return it.
29 // Additional reference on egl fence sync can be found in:
30 // http://www.khronos.org/registry/vg/extensions/KHR/EGL_KHR_fence_sync.txt
31 EGLSyncKHR fence = eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL);
32 if (fence == EGL_NO_SYNC_KHR) {
36 EGLint result = eglClientWaitSyncKHR(display,
38 EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
40 if (result == EGL_FALSE) {
41 ALOGE("EGL FENCE: error waiting for fence: %#x", eglGetError());
43 eglDestroySyncKHR(display, fence);