OSDN Git Service

Merge "Update the screen nail size even if screen nail is still the same one." into...
[android-x86/packages-apps-Gallery2.git] / jni / jni_egl_fence.cpp
1 /*
2  * Copyright (C) 2012 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 #include "jni_egl_fence.h"
18
19 #include <cutils/log.h>
20 #include <EGL/egl.h>
21 #include <EGL/eglext.h>
22
23 void
24 Java_com_android_gallery3d_photoeditor_FilterStack_nativeEglSetFenceAndWait(JNIEnv* env,
25                                                                           jobject thiz) {
26   EGLDisplay display = eglGetCurrentDisplay();
27
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) {
33     return;
34   }
35
36   EGLint result = eglClientWaitSyncKHR(display,
37                                        fence,
38                                        EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
39                                        EGL_FOREVER_KHR);
40   if (result == EGL_FALSE) {
41     ALOGE("EGL FENCE: error waiting for fence: %#x", eglGetError());
42   }
43   eglDestroySyncKHR(display, fence);
44 }