Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / gl / gl_fence_egl.cc
index ebc33bf..c96d6d8 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "ui/gl/gl_fence_egl.h"
 
+#include "ui/gl/egl_util.h"
 #include "ui/gl/gl_bindings.h"
 #include "ui/gl/gl_context.h"
 
@@ -24,6 +25,8 @@ bool GLFenceEGL::HasCompleted() {
   EGLint value = 0;
   if (eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value) !=
       EGL_TRUE) {
+    LOG(ERROR) << "Failed to get EGLSync attribute. error code:"
+               << eglGetError();
     return true;
   }
 
@@ -35,16 +38,28 @@ void GLFenceEGL::ClientWait() {
   if (!flush_event_.get() || flush_event_->IsSignaled()) {
     EGLint flags = 0;
     EGLTimeKHR time = EGL_FOREVER_KHR;
-    eglClientWaitSyncKHR(display_, sync_, flags, time);
+    EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time);
+    DCHECK_NE(EGL_TIMEOUT_EXPIRED_KHR, result);
+    if (result == EGL_FALSE) {
+      LOG(FATAL) << "Failed to wait for EGLSync. error:"
+                 << ui::GetLastEGLErrorString();
+    }
   } else {
     LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
   }
 }
 
 void GLFenceEGL::ServerWait() {
+  if (!gfx::g_driver_egl.ext.b_EGL_KHR_wait_sync) {
+    ClientWait();
+    return;
+  }
   if (!flush_event_.get() || flush_event_->IsSignaled()) {
     EGLint flags = 0;
-    eglWaitSyncKHR(display_, sync_, flags);
+    if (eglWaitSyncKHR(display_, sync_, flags) == EGL_FALSE) {
+      LOG(FATAL) << "Failed to wait for EGLSync. error:"
+                 << ui::GetLastEGLErrorString();
+    }
   } else {
     LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
   }