OLD | NEW |
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_nv.h" | 5 #include "ui/gl/gl_fence_nv.h" |
6 | 6 |
7 #include "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
8 | 8 |
9 namespace gfx { | 9 namespace gfx { |
10 | 10 |
11 GLFenceNV::GLFenceNV() { | 11 GLFenceNV::GLFenceNV() { |
12 // What if either of these GL calls fails? TestFenceNV will return true. | 12 // What if either of these GL calls fails? TestFenceNV will return true. |
13 // See spec: | 13 // See spec: |
14 // http://www.opengl.org/registry/specs/NV/fence.txt | 14 // http://www.opengl.org/registry/specs/NV/fence.txt |
15 // | 15 // |
16 // What should happen if TestFenceNV is called for a name before SetFenceNV | 16 // What should happen if TestFenceNV is called for a name before SetFenceNV |
17 // is called? | 17 // is called? |
18 // We generate an INVALID_OPERATION error, and return TRUE. | 18 // We generate an INVALID_OPERATION error, and return TRUE. |
19 // This follows the semantics for texture object names before | 19 // This follows the semantics for texture object names before |
20 // they are bound, in that they acquire their state upon binding. | 20 // they are bound, in that they acquire their state upon binding. |
21 // We will arbitrarily return TRUE for consistency. | 21 // We will arbitrarily return TRUE for consistency. |
22 glGenFencesNV(1, &fence_); | 22 glGenFencesNV(1, &fence_); |
| 23 ResetState(); |
| 24 } |
| 25 |
| 26 bool GLFenceNV::ResetSupported() { |
| 27 return true; |
| 28 } |
| 29 |
| 30 void GLFenceNV::ResetState() { |
23 glSetFenceNV(fence_, GL_ALL_COMPLETED_NV); | 31 glSetFenceNV(fence_, GL_ALL_COMPLETED_NV); |
24 DCHECK(glIsFenceNV(fence_)); | 32 DCHECK(glIsFenceNV(fence_)); |
25 glFlush(); | 33 glFlush(); |
26 } | 34 } |
27 | 35 |
28 bool GLFenceNV::HasCompleted() { | 36 bool GLFenceNV::HasCompleted() { |
29 DCHECK(glIsFenceNV(fence_)); | 37 DCHECK(glIsFenceNV(fence_)); |
30 return !!glTestFenceNV(fence_); | 38 return !!glTestFenceNV(fence_); |
31 } | 39 } |
32 | 40 |
33 void GLFenceNV::ClientWait() { | 41 void GLFenceNV::ClientWait() { |
34 DCHECK(glIsFenceNV(fence_)); | 42 DCHECK(glIsFenceNV(fence_)); |
35 glFinishFenceNV(fence_); | 43 glFinishFenceNV(fence_); |
36 } | 44 } |
37 | 45 |
38 void GLFenceNV::ServerWait() { | 46 void GLFenceNV::ServerWait() { |
39 DCHECK(glIsFenceNV(fence_)); | 47 DCHECK(glIsFenceNV(fence_)); |
40 ClientWait(); | 48 ClientWait(); |
41 } | 49 } |
42 | 50 |
43 GLFenceNV::~GLFenceNV() { | 51 GLFenceNV::~GLFenceNV() { |
44 DCHECK(glIsFenceNV(fence_)); | 52 DCHECK(glIsFenceNV(fence_)); |
45 glDeleteFencesNV(1, &fence_); | 53 glDeleteFencesNV(1, &fence_); |
46 } | 54 } |
47 | 55 |
48 } // namespace gfx | 56 } // namespace gfx |
OLD | NEW |