Update metrics verification for dev-proxy.
[chromium-blink-merge.git] / ui / gl / gl_fence.cc
blob5186f23fd99c1fee6228be46820251bf9e9f257a
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
3 // found in the LICENSE file.
5 #include "ui/gl/gl_fence.h"
7 #include "base/compiler_specific.h"
8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/gl_context.h"
10 #include "ui/gl/gl_fence_arb.h"
11 #include "ui/gl/gl_fence_egl.h"
12 #include "ui/gl/gl_fence_nv.h"
13 #include "ui/gl/gl_gl_api_implementation.h"
14 #include "ui/gl/gl_version_info.h"
16 namespace gfx {
18 namespace {
20 // static
21 GLFence* CreateFence(bool flush) {
22 DCHECK(GLContext::GetCurrent())
23 << "Trying to create fence with no context";
25 scoped_ptr<GLFence> fence;
26 // Prefer ARB_sync which supports server-side wait.
27 if (g_driver_gl.ext.b_GL_ARB_sync ||
28 GetGLVersionInfo()->is_es3) {
29 fence.reset(new GLFenceARB(flush));
30 #if !defined(OS_MACOSX)
31 } else if (g_driver_egl.ext.b_EGL_KHR_fence_sync) {
32 fence.reset(new GLFenceEGL(flush));
33 #endif
34 } else if (g_driver_gl.ext.b_GL_NV_fence) {
35 fence.reset(new GLFenceNV(flush));
38 DCHECK_EQ(!!fence.get(), GLFence::IsSupported());
39 return fence.release();
42 } // namespace
44 GLFence::GLFence() {
47 GLFence::~GLFence() {
50 bool GLFence::IsSupported() {
51 DCHECK(GetGLVersionInfo());
52 return g_driver_gl.ext.b_GL_ARB_sync || GetGLVersionInfo()->is_es3 ||
53 #if !defined(OS_MACOSX)
54 g_driver_egl.ext.b_EGL_KHR_fence_sync ||
55 #endif
56 g_driver_gl.ext.b_GL_NV_fence;
59 GLFence* GLFence::Create() {
60 return CreateFence(true);
63 GLFence* GLFence::CreateWithoutFlush() {
64 return CreateFence(false);
67 } // namespace gfx