NaCl: Update revision in DEPS, e8fbd4b -> 9e3dac8
[chromium-blink-merge.git] / ui / gl / gl_glx_api_implementation.cc
blobcd38fd88806041066b3cd0c793afe5d72e9b1374
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_glx_api_implementation.h"
6 #include "ui/gl/gl_implementation.h"
8 namespace gfx {
10 RealGLXApi* g_real_glx;
12 void InitializeStaticGLBindingsGLX() {
13 g_driver_glx.InitializeStaticBindings();
14 if (!g_real_glx) {
15 g_real_glx = new RealGLXApi();
17 g_real_glx->Initialize(&g_driver_glx);
18 g_current_glx_context = g_real_glx;
21 void InitializeDebugGLBindingsGLX() {
22 g_driver_glx.InitializeDebugBindings();
25 void ClearGLBindingsGLX() {
26 if (g_real_glx) {
27 delete g_real_glx;
28 g_real_glx = NULL;
30 g_current_glx_context = NULL;
31 g_driver_glx.ClearBindings();
34 GLXApi::GLXApi() {
37 GLXApi::~GLXApi() {
40 GLXApiBase::GLXApiBase()
41 : driver_(NULL) {
44 GLXApiBase::~GLXApiBase() {
47 void GLXApiBase::InitializeBase(DriverGLX* driver) {
48 driver_ = driver;
51 RealGLXApi::RealGLXApi() {
54 RealGLXApi::~RealGLXApi() {
57 void RealGLXApi::Initialize(DriverGLX* driver) {
58 InitializeBase(driver);
61 TraceGLXApi::~TraceGLXApi() {
64 bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info) {
65 Display* display = glXGetCurrentDisplay();
66 const int kDefaultScreen = 0;
67 const char* vendor =
68 glXQueryServerString(display, kDefaultScreen, GLX_VENDOR);
69 const char* version =
70 glXQueryServerString(display, kDefaultScreen, GLX_VERSION);
71 const char* extensions =
72 glXQueryServerString(display, kDefaultScreen, GLX_EXTENSIONS);
73 *info = GLWindowSystemBindingInfo();
74 if (vendor)
75 info->vendor = vendor;
76 if (version)
77 info->version = version;
78 if (extensions)
79 info->extensions = extensions;
80 info->direct_rendering = !!glXIsDirect(display, glXGetCurrentContext());
81 return true;
84 } // namespace gfx