Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: ui/gl/gl_implementation.cc

Issue 98643013: Take GL version and extensions correctly into account when binding functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Clarify code in generate_bindings.py according to feedback Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 void CleanupNativeLibraries(void* unused) { 39 void CleanupNativeLibraries(void* unused) {
40 if (g_libraries) { 40 if (g_libraries) {
41 // We do not call base::UnloadNativeLibrary() for these libraries as 41 // We do not call base::UnloadNativeLibrary() for these libraries as
42 // unloading libGL without closing X display is not allowed. See 42 // unloading libGL without closing X display is not allowed. See
43 // crbug.com/250813 for details. 43 // crbug.com/250813 for details.
44 delete g_libraries; 44 delete g_libraries;
45 g_libraries = NULL; 45 g_libraries = NULL;
46 } 46 }
47 } 47 }
48 48
49 bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) {
50 switch (GetGLImplementation()) {
51 case kGLImplementationDesktopGL:
52 case kGLImplementationOSMesaGL:
53 case kGLImplementationAppleGL:
54 case kGLImplementationMockGL:
55 return true;
56 case kGLImplementationEGLGLES2:
57 return false;
58 default:
59 NOTREACHED();
60 return true;
61 }
62 }
63
64 } 49 }
65 50
66 base::ThreadLocalPointer<GLApi>* g_current_gl_context_tls = NULL; 51 base::ThreadLocalPointer<GLApi>* g_current_gl_context_tls = NULL;
67 OSMESAApi* g_current_osmesa_context; 52 OSMESAApi* g_current_osmesa_context;
68 53
69 #if defined(OS_WIN) 54 #if defined(OS_WIN)
70 55
71 EGLApi* g_current_egl_context; 56 EGLApi* g_current_egl_context;
72 WGLApi* g_current_wgl_context; 57 WGLApi* g_current_wgl_context;
73 58
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 116
132 void UnloadGLNativeLibraries() { 117 void UnloadGLNativeLibraries() {
133 CleanupNativeLibraries(NULL); 118 CleanupNativeLibraries(NULL);
134 } 119 }
135 120
136 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) { 121 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) {
137 DCHECK(proc); 122 DCHECK(proc);
138 g_get_proc_address = proc; 123 g_get_proc_address = proc;
139 } 124 }
140 125
141 void* GetGLCoreProcAddress(const char* name) { 126 void* GetGLProcAddress(const char* name) {
142 DCHECK(g_gl_implementation != kGLImplementationNone); 127 DCHECK(g_gl_implementation != kGLImplementationNone);
143 128
144 if (g_libraries) { 129 if (g_libraries) {
145 for (size_t i = 0; i < g_libraries->size(); ++i) { 130 for (size_t i = 0; i < g_libraries->size(); ++i) {
146 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i], 131 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i],
147 name); 132 name);
148 if (proc) 133 if (proc)
149 return proc; 134 return proc;
150 } 135 }
151 } 136 }
152 if (ExportsCoreFunctionsFromGetProcAddress(g_gl_implementation) && 137 if (g_get_proc_address) {
153 g_get_proc_address) {
154 void* proc = g_get_proc_address(name); 138 void* proc = g_get_proc_address(name);
155 if (proc) 139 if (proc)
156 return proc; 140 return proc;
157 } 141 }
158 142
159 return NULL; 143 return NULL;
160 } 144 }
161 145
162 void* GetGLProcAddress(const char* name) {
163 DCHECK(g_gl_implementation != kGLImplementationNone);
164
165 void* proc = GetGLCoreProcAddress(name);
166 if (!proc && g_get_proc_address) {
167 proc = g_get_proc_address(name);
168 if (proc)
169 return proc;
170 }
171
172 return proc;
173 }
174
175 void InitializeNullDrawGLBindings() { 146 void InitializeNullDrawGLBindings() {
176 // This is platform independent, so it does not need to live in a platform 147 // This is platform independent, so it does not need to live in a platform
177 // specific implementation file. 148 // specific implementation file.
178 InitializeNullDrawGLBindingsGL(); 149 InitializeNullDrawGLBindingsGL();
179 } 150 }
180 151
181 } // namespace gfx 152 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698