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
3 // found in the LICENSE file.
5 #include "ui/gl/gl_fence_nv.h"
7 #include "ui/gl/gl_bindings.h"
11 GLFenceNV::GLFenceNV() {
12 // What if either of these GL calls fails? TestFenceNV will return true.
14 // http://www.opengl.org/registry/specs/NV/fence.txt
16 // What should happen if TestFenceNV is called for a name before SetFenceNV
18 // We generate an INVALID_OPERATION error, and return TRUE.
19 // This follows the semantics for texture object names before
20 // they are bound, in that they acquire their state upon binding.
21 // We will arbitrarily return TRUE for consistency.
22 glGenFencesNV(1, &fence_
);
23 glSetFenceNV(fence_
, GL_ALL_COMPLETED_NV
);
24 DCHECK(glIsFenceNV(fence_
));
28 bool GLFenceNV::HasCompleted() {
29 DCHECK(glIsFenceNV(fence_
));
30 return !!glTestFenceNV(fence_
);
33 void GLFenceNV::ClientWait() {
34 DCHECK(glIsFenceNV(fence_
));
35 glFinishFenceNV(fence_
);
38 void GLFenceNV::ServerWait() {
39 DCHECK(glIsFenceNV(fence_
));
43 GLFenceNV::~GLFenceNV() {
44 DCHECK(glIsFenceNV(fence_
));
45 glDeleteFencesNV(1, &fence_
);