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

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

Issue 898543002: Remove GLFence::CreateWithoutFlush (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove flush event Created 5 years, 10 months 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_egl.h ('k') | ui/gl/gl_fence_nv.h » ('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/egl_util.h"
8 #include "ui/gl/gl_bindings.h" 8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/gl_context.h"
10 9
11 namespace gfx { 10 namespace gfx {
12 11
13 GLFenceEGL::GLFenceEGL(bool flush) { 12 GLFenceEGL::GLFenceEGL() {
14 display_ = eglGetCurrentDisplay(); 13 display_ = eglGetCurrentDisplay();
15 sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL); 14 sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL);
16 DCHECK(sync_ != EGL_NO_SYNC_KHR); 15 DCHECK(sync_ != EGL_NO_SYNC_KHR);
17 if (flush) { 16 glFlush();
18 glFlush();
19 } else {
20 flush_event_ = GLContext::GetCurrent()->SignalFlush();
21 }
22 } 17 }
23 18
24 bool GLFenceEGL::HasCompleted() { 19 bool GLFenceEGL::HasCompleted() {
25 EGLint value = 0; 20 EGLint value = 0;
26 if (eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value) != 21 if (eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value) !=
27 EGL_TRUE) { 22 EGL_TRUE) {
28 LOG(ERROR) << "Failed to get EGLSync attribute. error code:" 23 LOG(ERROR) << "Failed to get EGLSync attribute. error code:"
29 << eglGetError(); 24 << eglGetError();
30 return true; 25 return true;
31 } 26 }
32 27
33 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR); 28 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR);
34 return !value || value == EGL_SIGNALED_KHR; 29 return !value || value == EGL_SIGNALED_KHR;
35 } 30 }
36 31
37 void GLFenceEGL::ClientWait() { 32 void GLFenceEGL::ClientWait() {
38 if (!flush_event_.get() || flush_event_->IsSignaled()) { 33 EGLint flags = 0;
39 EGLint flags = 0; 34 EGLTimeKHR time = EGL_FOREVER_KHR;
40 EGLTimeKHR time = EGL_FOREVER_KHR; 35 EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time);
41 EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time); 36 DCHECK_NE(EGL_TIMEOUT_EXPIRED_KHR, result);
42 DCHECK_NE(EGL_TIMEOUT_EXPIRED_KHR, result); 37 if (result == EGL_FALSE) {
43 if (result == EGL_FALSE) { 38 LOG(FATAL) << "Failed to wait for EGLSync. error:"
44 LOG(FATAL) << "Failed to wait for EGLSync. error:" 39 << ui::GetLastEGLErrorString();
45 << ui::GetLastEGLErrorString();
46 }
47 } else {
48 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
49 } 40 }
50 } 41 }
51 42
52 void GLFenceEGL::ServerWait() { 43 void GLFenceEGL::ServerWait() {
53 if (!gfx::g_driver_egl.ext.b_EGL_KHR_wait_sync) { 44 if (!gfx::g_driver_egl.ext.b_EGL_KHR_wait_sync) {
54 ClientWait(); 45 ClientWait();
55 return; 46 return;
56 } 47 }
57 if (!flush_event_.get() || flush_event_->IsSignaled()) { 48 EGLint flags = 0;
58 EGLint flags = 0; 49 if (eglWaitSyncKHR(display_, sync_, flags) == EGL_FALSE) {
59 if (eglWaitSyncKHR(display_, sync_, flags) == EGL_FALSE) { 50 LOG(FATAL) << "Failed to wait for EGLSync. error:"
60 LOG(FATAL) << "Failed to wait for EGLSync. error:" 51 << ui::GetLastEGLErrorString();
61 << ui::GetLastEGLErrorString();
62 }
63 } else {
64 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
65 } 52 }
66 } 53 }
67 54
68 GLFenceEGL::~GLFenceEGL() { 55 GLFenceEGL::~GLFenceEGL() {
69 eglDestroySyncKHR(display_, sync_); 56 eglDestroySyncKHR(display_, sync_);
70 } 57 }
71 58
72 } // namespace gfx 59 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_fence_egl.h ('k') | ui/gl/gl_fence_nv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698