OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "ui/gl/gl_fence.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
9 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 // We will arbitrarily return TRUE for consistency. | 25 // We will arbitrarily return TRUE for consistency. |
26 glGenFencesNV(1, &fence_); | 26 glGenFencesNV(1, &fence_); |
27 glSetFenceNV(fence_, GL_ALL_COMPLETED_NV); | 27 glSetFenceNV(fence_, GL_ALL_COMPLETED_NV); |
28 glFlush(); | 28 glFlush(); |
29 } | 29 } |
30 | 30 |
31 virtual bool HasCompleted() OVERRIDE { | 31 virtual bool HasCompleted() OVERRIDE { |
32 return !!glTestFenceNV(fence_); | 32 return !!glTestFenceNV(fence_); |
33 } | 33 } |
34 | 34 |
35 virtual void ClientWait() { | |
36 NOTIMPLEMENTED(); | |
apatrick_chromium
2013/06/18 22:15:01
glFinishFenceNV(fence_);
epenner
2013/06/18 22:37:25
Done.
| |
37 } | |
38 | |
35 private: | 39 private: |
36 virtual ~GLFenceNVFence() { | 40 virtual ~GLFenceNVFence() { |
37 glDeleteFencesNV(1, &fence_); | 41 glDeleteFencesNV(1, &fence_); |
38 } | 42 } |
39 | 43 |
40 GLuint fence_; | 44 GLuint fence_; |
41 }; | 45 }; |
42 | 46 |
43 class GLFenceARBSync: public gfx::GLFence { | 47 class GLFenceARBSync: public gfx::GLFence { |
44 public: | 48 public: |
(...skipping 10 matching lines...) Expand all Loading... | |
55 GLsizei length = 0; | 59 GLsizei length = 0; |
56 GLsizei value = 0; | 60 GLsizei value = 0; |
57 glGetSynciv(sync_, | 61 glGetSynciv(sync_, |
58 GL_SYNC_STATUS, | 62 GL_SYNC_STATUS, |
59 1, // bufSize | 63 1, // bufSize |
60 &length, | 64 &length, |
61 &value); | 65 &value); |
62 return length == 1 && value == GL_SIGNALED; | 66 return length == 1 && value == GL_SIGNALED; |
63 } | 67 } |
64 | 68 |
69 virtual void ClientWait() { | |
70 NOTIMPLEMENTED(); | |
apatrick_chromium
2013/06/18 22:15:01
glClientWaitSyncARB(sync_, SYNC_FLUSH_COMMANDS_BIT
epenner
2013/06/18 22:37:25
Done. Note there is no ARB, and added GL_ to const
| |
71 } | |
72 | |
65 private: | 73 private: |
66 virtual ~GLFenceARBSync() { | 74 virtual ~GLFenceARBSync() { |
67 glDeleteSync(sync_); | 75 glDeleteSync(sync_); |
68 } | 76 } |
69 | 77 |
70 GLsync sync_; | 78 GLsync sync_; |
71 }; | 79 }; |
72 | 80 |
81 class EglFenceSync : public gfx::GLFence { | |
apatrick_chromium
2013/06/18 22:15:01
We've been using "EGL" (all caps) everywhere else.
epenner
2013/06/18 22:37:25
Done.
| |
82 public: | |
83 EglFenceSync() { | |
84 sync_ = eglCreateSyncKHR(eglGetCurrentDisplay(), | |
apatrick_chromium
2013/06/18 22:15:01
nit: make first arg display_ and move the statemen
epenner
2013/06/18 22:37:25
Done.
| |
85 EGL_SYNC_FENCE_KHR, NULL); | |
86 display_ = eglGetCurrentDisplay(); | |
87 } | |
88 | |
89 virtual bool HasCompleted() OVERRIDE { | |
90 EGLint value = 0; | |
91 eglGetSyncAttribKHR(display_, sync_, EGL_SYNC_STATUS_KHR, &value); | |
92 DCHECK(value == EGL_SIGNALED_KHR || value == EGL_UNSIGNALED_KHR); | |
93 return !value || value == EGL_SIGNALED_KHR; | |
94 } | |
95 | |
96 virtual void ClientWait() OVERRIDE { | |
97 EGLint flags = EGL_SYNC_FLUSH_COMMANDS_BIT_KHR; | |
98 EGLTimeKHR time = EGL_FOREVER_KHR; | |
99 eglClientWaitSyncKHR(display_, sync_, flags, time); | |
100 } | |
101 | |
102 private: | |
103 virtual ~EglFenceSync() { | |
104 eglDestroySyncKHR(display_, sync_); | |
105 } | |
106 | |
107 EGLSyncKHR sync_; | |
108 EGLDisplay display_; | |
109 }; | |
110 | |
73 } // namespace | 111 } // namespace |
74 | 112 |
75 namespace gfx { | 113 namespace gfx { |
76 | 114 |
77 GLFence::GLFence() { | 115 GLFence::GLFence() { |
78 } | 116 } |
79 | 117 |
80 GLFence::~GLFence() { | 118 GLFence::~GLFence() { |
81 } | 119 } |
82 | 120 |
83 // static | 121 // static |
84 GLFence* GLFence::Create() { | 122 GLFence* GLFence::Create() { |
85 if (gfx::g_driver_gl.ext.b_GL_NV_fence) { | 123 if (gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync) { |
124 return new EglFenceSync(); | |
125 } else if (gfx::g_driver_gl.ext.b_GL_NV_fence) { | |
86 return new GLFenceNVFence(); | 126 return new GLFenceNVFence(); |
87 } else if (gfx::g_driver_gl.ext.b_GL_ARB_sync) { | 127 } else if (gfx::g_driver_gl.ext.b_GL_ARB_sync) { |
88 return new GLFenceARBSync(); | 128 return new GLFenceARBSync(); |
89 } else { | 129 } else { |
90 return NULL; | 130 return NULL; |
91 } | 131 } |
92 } | 132 } |
93 | 133 |
94 } // namespace gfx | 134 } // namespace gfx |
OLD | NEW |