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

Unified Diff: ui/gl/gl_fence.cc

Issue 14358014: gpu: Add EGL fence support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac (it doesn't include EGL). Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_fence.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_fence.cc
diff --git a/ui/gl/gl_fence.cc b/ui/gl/gl_fence.cc
index 9a40ec2a8b652f11135be687c46aeef9a22216fb..68aa88b4229756965bbb48352502e3bbabab53d9 100644
--- a/ui/gl/gl_fence.cc
+++ b/ui/gl/gl_fence.cc
@@ -32,6 +32,10 @@ class GLFenceNVFence: public gfx::GLFence {
return !!glTestFenceNV(fence_);
}
+ virtual void ClientWait() OVERRIDE {
+ glFinishFenceNV(fence_);
+ }
+
private:
virtual ~GLFenceNVFence() {
glDeleteFencesNV(1, &fence_);
@@ -62,6 +66,10 @@ class GLFenceARBSync: public gfx::GLFence {
return length == 1 && value == GL_SIGNALED;
}
+ virtual void ClientWait() OVERRIDE {
+ glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
+ }
+
private:
virtual ~GLFenceARBSync() {
glDeleteSync(sync_);
@@ -70,6 +78,37 @@ class GLFenceARBSync: public gfx::GLFence {
GLsync sync_;
};
+#if !defined(OS_MACOSX)
+class EGLFenceSync : public gfx::GLFence {
+ public:
+ EGLFenceSync() {
+ display_ = eglGetCurrentDisplay();
+ sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL);
+ }
+
+ virtual bool HasCompleted() OVERRIDE {
+ EGLint value = 0;
+ eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value);
+ DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR);
+ return !value || value == EGL_SIGNALED_KHR;
+ }
+
+ virtual void ClientWait() OVERRIDE {
+ EGLint flags = EGL_SYNC_FLUSH_COMMANDS_BIT_KHR;
+ EGLTimeKHR time = EGL_FOREVER_KHR;
+ eglClientWaitSyncKHR(display_, sync_, flags, time);
+ }
+
+ private:
+ virtual ~EGLFenceSync() {
+ eglDestroySyncKHR(display_, sync_);
+ }
+
+ EGLSyncKHR sync_;
+ EGLDisplay display_;
+};
+#endif // !OS_MACOSX
+
} // namespace
namespace gfx {
@@ -82,13 +121,15 @@ GLFence::~GLFence() {
// static
GLFence* GLFence::Create() {
- if (gfx::g_driver_gl.ext.b_GL_NV_fence) {
+#if !defined(OS_MACOSX)
+ if (gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync)
+ return new EGLFenceSync();
+#endif
+ if (gfx::g_driver_gl.ext.b_GL_NV_fence)
return new GLFenceNVFence();
- } else if (gfx::g_driver_gl.ext.b_GL_ARB_sync) {
+ if (gfx::g_driver_gl.ext.b_GL_ARB_sync)
return new GLFenceARBSync();
- } else {
- return NULL;
- }
+ return NULL;
}
} // namespace gfx
« no previous file with comments | « ui/gl/gl_fence.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698