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

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

Issue 8381001: Split GL binding init into core and extension part (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added dependencies to gl.gyp. Used NOT_REACHED() instead of DCHECK(0). Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/gl/gl_implementation.h ('k') | ui/gfx/gl/gl_implementation_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gfx/gl/gl_implementation.h" 5 #include "ui/gfx/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 23 matching lines...) Expand all
34 void CleanupNativeLibraries(void* unused) { 34 void CleanupNativeLibraries(void* unused) {
35 if (g_libraries) { 35 if (g_libraries) {
36 for (LibraryArray::iterator it = g_libraries->begin(); 36 for (LibraryArray::iterator it = g_libraries->begin();
37 it != g_libraries->end(); ++it) { 37 it != g_libraries->end(); ++it) {
38 base::UnloadNativeLibrary(*it); 38 base::UnloadNativeLibrary(*it);
39 } 39 }
40 delete g_libraries; 40 delete g_libraries;
41 g_libraries = NULL; 41 g_libraries = NULL;
42 } 42 }
43 } 43 }
44
45 bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) {
46 switch (GetGLImplementation()) {
47 case kGLImplementationDesktopGL:
48 case kGLImplementationOSMesaGL:
49 case kGLImplementationMockGL:
50 return true;
51 case kGLImplementationEGLGLES2:
52 return false;
53 default:
54 NOTREACHED();
55 return true;
56 }
57 }
58
44 } 59 }
45 60
46 GLImplementation GetNamedGLImplementation(const std::string& name) { 61 GLImplementation GetNamedGLImplementation(const std::string& name) {
47 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kGLImplementationNamePairs); ++i) { 62 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kGLImplementationNamePairs); ++i) {
48 if (name == kGLImplementationNamePairs[i].name) 63 if (name == kGLImplementationNamePairs[i].name)
49 return kGLImplementationNamePairs[i].implementation; 64 return kGLImplementationNamePairs[i].implementation;
50 } 65 }
51 66
52 return kGLImplementationNone; 67 return kGLImplementationNone;
53 } 68 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 145 }
131 146
132 g_libraries->push_back(library); 147 g_libraries->push_back(library);
133 } 148 }
134 149
135 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) { 150 void SetGLGetProcAddressProc(GLGetProcAddressProc proc) {
136 DCHECK(proc); 151 DCHECK(proc);
137 g_get_proc_address = proc; 152 g_get_proc_address = proc;
138 } 153 }
139 154
140 void* GetGLProcAddress(const char* name) { 155 void* GetGLCoreProcAddress(const char* name) {
141 DCHECK(g_gl_implementation != kGLImplementationNone); 156 DCHECK(g_gl_implementation != kGLImplementationNone);
142 157
143 if (g_libraries) { 158 if (g_libraries) {
144 for (size_t i = 0; i < g_libraries->size(); ++i) { 159 for (size_t i = 0; i < g_libraries->size(); ++i) {
145 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i], 160 void* proc = base::GetFunctionPointerFromNativeLibrary((*g_libraries)[i],
146 name); 161 name);
147 if (proc) 162 if (proc)
148 return proc; 163 return proc;
149 } 164 }
150 } 165 }
151 166 if (ExportsCoreFunctionsFromGetProcAddress(g_gl_implementation) &&
152 if (g_get_proc_address) { 167 g_get_proc_address) {
153 void* proc = g_get_proc_address(name); 168 void* proc = g_get_proc_address(name);
154 if (proc) 169 if (proc)
155 return proc; 170 return proc;
156 } 171 }
157 172
158 return NULL; 173 return NULL;
159 } 174 }
160 175
176 void* GetGLProcAddress(const char* name) {
177 DCHECK(g_gl_implementation != kGLImplementationNone);
178
179 void* proc = GetGLCoreProcAddress(name);
180 if (!proc && g_get_proc_address) {
181 proc = g_get_proc_address(name);
182 if (proc)
183 return proc;
184 }
185
186 return proc;
187 }
188
161 } // namespace gfx 189 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_implementation.h ('k') | ui/gfx/gl/gl_implementation_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698