| 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_implementation.h" | 5 #include "ui/gl/gl_implementation.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
| 14 | 14 |
| 15 #if defined(USE_OZONE) |
| 16 #include "ui/gfx/ozone/surface_factory_ozone.h" |
| 17 #endif |
| 18 |
| 15 namespace gfx { | 19 namespace gfx { |
| 16 | 20 |
| 17 namespace { | 21 namespace { |
| 18 | 22 |
| 19 const struct { | 23 const struct { |
| 20 const char* name; | 24 const char* name; |
| 21 GLImplementation implementation; | 25 GLImplementation implementation; |
| 22 } kGLImplementationNamePairs[] = { | 26 } kGLImplementationNamePairs[] = { |
| 23 { kGLImplementationDesktopName, kGLImplementationDesktopGL }, | 27 { kGLImplementationDesktopName, kGLImplementationDesktopGL }, |
| 24 { kGLImplementationOSMesaName, kGLImplementationOSMesaGL }, | 28 { kGLImplementationOSMesaName, kGLImplementationOSMesaGL }, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) { | 139 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) { |
| 136 DCHECK(proc); | 140 DCHECK(proc); |
| 137 g_get_proc_address = proc; | 141 g_get_proc_address = proc; |
| 138 } | 142 } |
| 139 | 143 |
| 140 void* GetGLCoreProcAddress(const char* name) { | 144 void* GetGLCoreProcAddress(const char* name) { |
| 141 DCHECK(g_gl_implementation != kGLImplementationNone); | 145 DCHECK(g_gl_implementation != kGLImplementationNone); |
| 142 | 146 |
| 143 if (g_libraries) { | 147 if (g_libraries) { |
| 144 for (size_t i = 0; i < g_libraries->size(); ++i) { | 148 for (size_t i = 0; i < g_libraries->size(); ++i) { |
| 149 #if defined(USE_OZONE) |
| 150 void* proc = gfx::SurfaceFactoryOzone::GetInstance()-> |
| 151 GetFunctionPointerFromNativeLibrary((*g_libraries)[i], name); |
| 152 #else |
| 145 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i], | 153 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i], |
| 146 name); | 154 name); |
| 155 #endif |
| 147 if (proc) | 156 if (proc) |
| 148 return proc; | 157 return proc; |
| 149 } | 158 } |
| 150 } | 159 } |
| 151 if (ExportsCoreFunctionsFromGetProcAddress(g_gl_implementation) && | 160 if (ExportsCoreFunctionsFromGetProcAddress(g_gl_implementation) && |
| 152 g_get_proc_address) { | 161 g_get_proc_address) { |
| 153 void* proc = g_get_proc_address(name); | 162 void* proc = g_get_proc_address(name); |
| 154 if (proc) | 163 if (proc) |
| 155 return proc; | 164 return proc; |
| 156 } | 165 } |
| 157 | 166 |
| 158 return NULL; | 167 return NULL; |
| 159 } | 168 } |
| 160 | 169 |
| 161 void* GetGLProcAddress(const char* name) { | 170 void* GetGLProcAddress(const char* name) { |
| 162 DCHECK(g_gl_implementation != kGLImplementationNone); | 171 DCHECK(g_gl_implementation != kGLImplementationNone); |
| 163 | 172 |
| 164 void* proc = GetGLCoreProcAddress(name); | 173 void* proc = GetGLCoreProcAddress(name); |
| 165 if (!proc && g_get_proc_address) { | 174 if (!proc && g_get_proc_address) { |
| 166 proc = g_get_proc_address(name); | 175 proc = g_get_proc_address(name); |
| 167 if (proc) | 176 if (proc) |
| 168 return proc; | 177 return proc; |
| 169 } | 178 } |
| 170 | 179 |
| 171 return proc; | 180 return proc; |
| 172 } | 181 } |
| 173 | 182 |
| 174 } // namespace gfx | 183 } // namespace gfx |
| OLD | NEW |