| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_glx_api_implementation.h" | 5 #include "ui/gl/gl_glx_api_implementation.h" |
| 6 #include "ui/gl/gl_implementation.h" | 6 #include "ui/gl/gl_implementation.h" |
| 7 | 7 |
| 8 namespace gfx { | 8 namespace gfx { |
| 9 | 9 |
| 10 RealGLXApi* g_real_glx; | 10 RealGLXApi* g_real_glx; |
| 11 | 11 |
| 12 void InitializeStaticGLBindingsGLX() { | 12 void InitializeStaticGLBindingsGLX() { |
| 13 g_driver_glx.InitializeStaticBindings(); | 13 g_driver_glx.InitializeStaticBindings(); |
| 14 if (!g_real_glx) { | 14 if (!g_real_glx) { |
| 15 g_real_glx = new RealGLXApi(); | 15 g_real_glx = new RealGLXApi(); |
| 16 } | 16 } |
| 17 g_real_glx->Initialize(&g_driver_glx); | 17 g_real_glx->Initialize(&g_driver_glx); |
| 18 g_current_glx_context = g_real_glx; | 18 g_current_glx_context = g_real_glx; |
| 19 g_driver_glx.InitializeExtensionBindings(g_real_glx->GetEnabledExtensions()); |
| 19 } | 20 } |
| 20 | 21 |
| 21 void InitializeDebugGLBindingsGLX() { | 22 void InitializeDebugGLBindingsGLX() { |
| 22 g_driver_glx.InitializeDebugBindings(); | 23 g_driver_glx.InitializeDebugBindings(); |
| 23 } | 24 } |
| 24 | 25 |
| 25 void ClearGLBindingsGLX() { | 26 void ClearGLBindingsGLX() { |
| 26 if (g_real_glx) { | 27 if (g_real_glx) { |
| 27 delete g_real_glx; | 28 delete g_real_glx; |
| 28 g_real_glx = NULL; | 29 g_real_glx = NULL; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 51 RealGLXApi::RealGLXApi() { | 52 RealGLXApi::RealGLXApi() { |
| 52 } | 53 } |
| 53 | 54 |
| 54 RealGLXApi::~RealGLXApi() { | 55 RealGLXApi::~RealGLXApi() { |
| 55 } | 56 } |
| 56 | 57 |
| 57 void RealGLXApi::Initialize(DriverGLX* driver) { | 58 void RealGLXApi::Initialize(DriverGLX* driver) { |
| 58 InitializeBase(driver); | 59 InitializeBase(driver); |
| 59 } | 60 } |
| 60 | 61 |
| 62 std::set<std::string> RealGLXApi::GetEnabledExtensions() const { |
| 63 std::set<std::string> enabled_extensions; |
| 64 |
| 65 std::vector<std::string> platform_extensions_vec; |
| 66 std::string platform_ext = DriverGLX::GetPlatformExtensions(); |
| 67 base::SplitString(platform_ext, ' ', &platform_extensions_vec); |
| 68 |
| 69 enabled_extensions.insert(platform_extensions_vec.begin(), |
| 70 platform_extensions_vec.end()); |
| 71 |
| 72 for (auto ext : disabled_exts_) { |
| 73 enabled_extensions.erase(ext); |
| 74 } |
| 75 |
| 76 return enabled_extensions; |
| 77 } |
| 78 |
| 61 TraceGLXApi::~TraceGLXApi() { | 79 TraceGLXApi::~TraceGLXApi() { |
| 62 } | 80 } |
| 63 | 81 |
| 64 bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info) { | 82 bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info) { |
| 65 Display* display = glXGetCurrentDisplay(); | 83 Display* display = glXGetCurrentDisplay(); |
| 66 const int kDefaultScreen = 0; | 84 const int kDefaultScreen = 0; |
| 67 const char* vendor = | 85 const char* vendor = |
| 68 glXQueryServerString(display, kDefaultScreen, GLX_VENDOR); | 86 glXQueryServerString(display, kDefaultScreen, GLX_VENDOR); |
| 69 const char* version = | 87 const char* version = |
| 70 glXQueryServerString(display, kDefaultScreen, GLX_VERSION); | 88 glXQueryServerString(display, kDefaultScreen, GLX_VERSION); |
| 71 const char* extensions = | 89 const char* extensions = |
| 72 glXQueryServerString(display, kDefaultScreen, GLX_EXTENSIONS); | 90 glXQueryServerString(display, kDefaultScreen, GLX_EXTENSIONS); |
| 73 *info = GLWindowSystemBindingInfo(); | 91 *info = GLWindowSystemBindingInfo(); |
| 74 if (vendor) | 92 if (vendor) |
| 75 info->vendor = vendor; | 93 info->vendor = vendor; |
| 76 if (version) | 94 if (version) |
| 77 info->version = version; | 95 info->version = version; |
| 78 if (extensions) | 96 if (extensions) |
| 79 info->extensions = extensions; | 97 info->extensions = extensions; |
| 80 info->direct_rendering = !!glXIsDirect(display, glXGetCurrentContext()); | 98 info->direct_rendering = !!glXIsDirect(display, glXGetCurrentContext()); |
| 81 return true; | 99 return true; |
| 82 } | 100 } |
| 83 | 101 |
| 84 } // namespace gfx | 102 } // namespace gfx |
| 85 | 103 |
| 86 | 104 |
| OLD | NEW |