Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: ui/gl/gl_fence_egl.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_fence_arb.cc ('k') | ui/gl/gl_implementation_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_fence_egl.h" 5 #include "ui/gl/gl_fence_egl.h"
6 6
7 #include "ui/gl/egl_util.h"
7 #include "ui/gl/gl_bindings.h" 8 #include "ui/gl/gl_bindings.h"
8 #include "ui/gl/gl_context.h" 9 #include "ui/gl/gl_context.h"
9 10
10 namespace gfx { 11 namespace gfx {
11 12
12 GLFenceEGL::GLFenceEGL(bool flush) { 13 GLFenceEGL::GLFenceEGL(bool flush) {
13 display_ = eglGetCurrentDisplay(); 14 display_ = eglGetCurrentDisplay();
14 sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL); 15 sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL);
15 DCHECK(sync_ != EGL_NO_SYNC_KHR); 16 DCHECK(sync_ != EGL_NO_SYNC_KHR);
16 if (flush) { 17 if (flush) {
17 glFlush(); 18 glFlush();
18 } else { 19 } else {
19 flush_event_ = GLContext::GetCurrent()->SignalFlush(); 20 flush_event_ = GLContext::GetCurrent()->SignalFlush();
20 } 21 }
21 } 22 }
22 23
23 bool GLFenceEGL::HasCompleted() { 24 bool GLFenceEGL::HasCompleted() {
24 EGLint value = 0; 25 EGLint value = 0;
25 if (eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value) != 26 if (eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value) !=
26 EGL_TRUE) { 27 EGL_TRUE) {
28 LOG(ERROR) << "Failed to get EGLSync attribute. error code:"
29 << eglGetError();
27 return true; 30 return true;
28 } 31 }
29 32
30 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR); 33 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR);
31 return !value || value == EGL_SIGNALED_KHR; 34 return !value || value == EGL_SIGNALED_KHR;
32 } 35 }
33 36
34 void GLFenceEGL::ClientWait() { 37 void GLFenceEGL::ClientWait() {
35 if (!flush_event_.get() || flush_event_->IsSignaled()) { 38 if (!flush_event_.get() || flush_event_->IsSignaled()) {
36 EGLint flags = 0; 39 EGLint flags = 0;
37 EGLTimeKHR time = EGL_FOREVER_KHR; 40 EGLTimeKHR time = EGL_FOREVER_KHR;
38 eglClientWaitSyncKHR(display_, sync_, flags, time); 41 EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time);
42 DCHECK_NE(EGL_TIMEOUT_EXPIRED_KHR, result);
43 if (result == EGL_FALSE) {
44 LOG(FATAL) << "Failed to wait for EGLSync. error:"
45 << ui::GetLastEGLErrorString();
46 }
39 } else { 47 } else {
40 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping..."; 48 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
41 } 49 }
42 } 50 }
43 51
44 void GLFenceEGL::ServerWait() { 52 void GLFenceEGL::ServerWait() {
45 if (!gfx::g_driver_egl.ext.b_EGL_KHR_wait_sync) { 53 if (!gfx::g_driver_egl.ext.b_EGL_KHR_wait_sync) {
46 ClientWait(); 54 ClientWait();
47 return; 55 return;
48 } 56 }
49 if (!flush_event_.get() || flush_event_->IsSignaled()) { 57 if (!flush_event_.get() || flush_event_->IsSignaled()) {
50 EGLint flags = 0; 58 EGLint flags = 0;
51 eglWaitSyncKHR(display_, sync_, flags); 59 if (eglWaitSyncKHR(display_, sync_, flags) == EGL_FALSE) {
60 LOG(FATAL) << "Failed to wait for EGLSync. error:"
61 << ui::GetLastEGLErrorString();
62 }
52 } else { 63 } else {
53 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping..."; 64 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
54 } 65 }
55 } 66 }
56 67
57 GLFenceEGL::~GLFenceEGL() { 68 GLFenceEGL::~GLFenceEGL() {
58 eglDestroySyncKHR(display_, sync_); 69 eglDestroySyncKHR(display_, sync_);
59 } 70 }
60 71
61 } // namespace gfx 72 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_fence_arb.cc ('k') | ui/gl/gl_implementation_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698