[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #include "ui/gl/gl_glx_api_implementation.h" | ||||
[email protected] | 4589503 | 2013-05-30 17:06:43 | [diff] [blame] | 6 | #include "ui/gl/gl_implementation.h" |
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 7 | |
8 | namespace gfx { | ||||
9 | |||||
10 | RealGLXApi* g_real_glx; | ||||
11 | |||||
12 | void InitializeGLBindingsGLX() { | ||||
13 | g_driver_glx.InitializeBindings(); | ||||
14 | if (!g_real_glx) { | ||||
15 | g_real_glx = new RealGLXApi(); | ||||
16 | } | ||||
17 | g_real_glx->Initialize(&g_driver_glx); | ||||
18 | g_current_glx_context = g_real_glx; | ||||
19 | } | ||||
20 | |||||
21 | void InitializeGLExtensionBindingsGLX(GLContext* context) { | ||||
22 | g_driver_glx.InitializeExtensionBindings(context); | ||||
23 | } | ||||
24 | |||||
25 | void InitializeDebugGLBindingsGLX() { | ||||
26 | g_driver_glx.InitializeDebugBindings(); | ||||
27 | } | ||||
28 | |||||
29 | void ClearGLBindingsGLX() { | ||||
30 | if (g_real_glx) { | ||||
31 | delete g_real_glx; | ||||
32 | g_real_glx = NULL; | ||||
33 | } | ||||
34 | g_current_glx_context = NULL; | ||||
35 | g_driver_glx.ClearBindings(); | ||||
36 | } | ||||
37 | |||||
38 | GLXApi::GLXApi() { | ||||
39 | } | ||||
40 | |||||
41 | GLXApi::~GLXApi() { | ||||
42 | } | ||||
43 | |||||
[email protected] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 44 | GLXApiBase::GLXApiBase() |
45 | : driver_(NULL) { | ||||
46 | } | ||||
47 | |||||
48 | GLXApiBase::~GLXApiBase() { | ||||
49 | } | ||||
50 | |||||
51 | void GLXApiBase::InitializeBase(DriverGLX* driver) { | ||||
52 | driver_ = driver; | ||||
53 | } | ||||
54 | |||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 55 | RealGLXApi::RealGLXApi() { |
56 | } | ||||
57 | |||||
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 58 | RealGLXApi::~RealGLXApi() { |
59 | } | ||||
60 | |||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 61 | void RealGLXApi::Initialize(DriverGLX* driver) { |
[email protected] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 62 | InitializeBase(driver); |
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 63 | } |
64 | |||||
[email protected] | b8f1d48c | 2013-02-07 05:21:12 | [diff] [blame] | 65 | TraceGLXApi::~TraceGLXApi() { |
66 | } | ||||
67 | |||||
[email protected] | 4589503 | 2013-05-30 17:06:43 | [diff] [blame] | 68 | bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info) { |
69 | Display* display = glXGetCurrentDisplay(); | ||||
70 | const int kDefaultScreen = 0; | ||||
71 | const char* vendor = | ||||
72 | glXQueryServerString(display, kDefaultScreen, GLX_VENDOR); | ||||
73 | const char* version = | ||||
74 | glXQueryServerString(display, kDefaultScreen, GLX_VERSION); | ||||
75 | const char* extensions = | ||||
76 | glXQueryServerString(display, kDefaultScreen, GLX_EXTENSIONS); | ||||
77 | *info = GLWindowSystemBindingInfo(); | ||||
78 | if (vendor) | ||||
79 | info->vendor = vendor; | ||||
80 | if (version) | ||||
81 | info->version = version; | ||||
82 | if (extensions) | ||||
83 | info->extensions = extensions; | ||||
84 | return true; | ||||
85 | } | ||||
86 | |||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 87 | } // namespace gfx |
88 | |||||
89 |