| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void CleanupNativeLibraries(void* unused) { | 38 void CleanupNativeLibraries(void* unused) { |
| 39 if (g_libraries) { | 39 if (g_libraries) { |
| 40 // We do not call base::UnloadNativeLibrary() for these libraries as | 40 // We do not call base::UnloadNativeLibrary() for these libraries as |
| 41 // unloading libGL without closing X display is not allowed. See | 41 // unloading libGL without closing X display is not allowed. See |
| 42 // crbug.com/250813 for details. | 42 // crbug.com/250813 for details. |
| 43 delete g_libraries; | 43 delete g_libraries; |
| 44 g_libraries = NULL; | 44 g_libraries = NULL; |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) { | |
| 49 switch (GetGLImplementation()) { | |
| 50 case kGLImplementationDesktopGL: | |
| 51 case kGLImplementationOSMesaGL: | |
| 52 case kGLImplementationAppleGL: | |
| 53 case kGLImplementationMockGL: | |
| 54 return true; | |
| 55 case kGLImplementationEGLGLES2: | |
| 56 return false; | |
| 57 default: | |
| 58 NOTREACHED(); | |
| 59 return true; | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 } | 48 } |
| 64 | 49 |
| 65 base::ThreadLocalPointer<GLApi>* g_current_gl_context_tls = NULL; | 50 base::ThreadLocalPointer<GLApi>* g_current_gl_context_tls = NULL; |
| 66 OSMESAApi* g_current_osmesa_context; | 51 OSMESAApi* g_current_osmesa_context; |
| 67 | 52 |
| 68 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
| 69 | 54 |
| 70 EGLApi* g_current_egl_context; | 55 EGLApi* g_current_egl_context; |
| 71 WGLApi* g_current_wgl_context; | 56 WGLApi* g_current_wgl_context; |
| 72 | 57 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 115 |
| 131 void UnloadGLNativeLibraries() { | 116 void UnloadGLNativeLibraries() { |
| 132 CleanupNativeLibraries(NULL); | 117 CleanupNativeLibraries(NULL); |
| 133 } | 118 } |
| 134 | 119 |
| 135 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) { | 120 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) { |
| 136 DCHECK(proc); | 121 DCHECK(proc); |
| 137 g_get_proc_address = proc; | 122 g_get_proc_address = proc; |
| 138 } | 123 } |
| 139 | 124 |
| 140 void* GetGLCoreProcAddress(const char* name) { | 125 void* GetGLProcAddress(const char* name) { |
| 141 DCHECK(g_gl_implementation != kGLImplementationNone); | 126 DCHECK(g_gl_implementation != kGLImplementationNone); |
| 142 | 127 |
| 143 if (g_libraries) { | 128 if (g_libraries) { |
| 144 for (size_t i = 0; i < g_libraries->size(); ++i) { | 129 for (size_t i = 0; i < g_libraries->size(); ++i) { |
| 145 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i], | 130 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i], |
| 146 name); | 131 name); |
| 147 if (proc) | 132 if (proc) |
| 148 return proc; | 133 return proc; |
| 149 } | 134 } |
| 150 } | 135 } |
| 151 if (ExportsCoreFunctionsFromGetProcAddress(g_gl_implementation) && | 136 if (g_get_proc_address) { |
| 152 g_get_proc_address) { | |
| 153 void* proc = g_get_proc_address(name); | 137 void* proc = g_get_proc_address(name); |
| 154 if (proc) | 138 if (proc) |
| 155 return proc; | 139 return proc; |
| 156 } | 140 } |
| 157 | 141 |
| 158 return NULL; | 142 return NULL; |
| 159 } | 143 } |
| 160 | 144 |
| 161 void* GetGLProcAddress(const char* name) { | |
| 162 DCHECK(g_gl_implementation != kGLImplementationNone); | |
| 163 | |
| 164 void* proc = GetGLCoreProcAddress(name); | |
| 165 if (!proc && g_get_proc_address) { | |
| 166 proc = g_get_proc_address(name); | |
| 167 if (proc) | |
| 168 return proc; | |
| 169 } | |
| 170 | |
| 171 return proc; | |
| 172 } | |
| 173 | |
| 174 } // namespace gfx | 145 } // namespace gfx |
| OLD | NEW |