Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / gl / gl_fence_egl.cc
blob641b8c2e3fc6772cd467975b5031ee7bc5c6a042
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gl/gl_fence_egl.h"
7 #include "ui/gl/egl_util.h"
8 #include "ui/gl/gl_bindings.h"
10 namespace gfx {
12 namespace {
14 bool g_ignore_egl_sync_failures = false;
16 } // namespace
18 // static
19 void GLFenceEGL::SetIgnoreFailures() {
20 g_ignore_egl_sync_failures = true;
23 GLFenceEGL::GLFenceEGL() {
24 display_ = eglGetCurrentDisplay();
25 sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL);
26 DCHECK(sync_ != EGL_NO_SYNC_KHR);
27 glFlush();
30 bool GLFenceEGL::HasCompleted() {
31 EGLint value = 0;
32 if (eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value) !=
33 EGL_TRUE) {
34 LOG(ERROR) << "Failed to get EGLSync attribute. error code:"
35 << eglGetError();
36 return true;
39 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR);
40 return !value || value == EGL_SIGNALED_KHR;
43 void GLFenceEGL::ClientWait() {
44 EGLint flags = 0;
45 EGLTimeKHR time = EGL_FOREVER_KHR;
46 EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time);
47 DCHECK_IMPLIES(!g_ignore_egl_sync_failures,
48 EGL_TIMEOUT_EXPIRED_KHR != result);
49 if (result == EGL_FALSE) {
50 LOG(ERROR) << "Failed to wait for EGLSync. error:"
51 << ui::GetLastEGLErrorString();
52 CHECK(g_ignore_egl_sync_failures);
56 void GLFenceEGL::ServerWait() {
57 if (!gfx::g_driver_egl.ext.b_EGL_KHR_wait_sync) {
58 ClientWait();
59 return;
61 EGLint flags = 0;
62 if (eglWaitSyncKHR(display_, sync_, flags) == EGL_FALSE) {
63 LOG(ERROR) << "Failed to wait for EGLSync. error:"
64 << ui::GetLastEGLErrorString();
65 CHECK(g_ignore_egl_sync_failures);
69 GLFenceEGL::~GLFenceEGL() {
70 eglDestroySyncKHR(display_, sync_);
73 } // namespace gfx