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

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

Issue 8698008: This change adds the apple software renderer as an option on Chrome/Mac. It's enabled by passing... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 namespace { 16 namespace {
17 17
18 const struct { 18 const struct {
19 const char* name; 19 const char* name;
20 GLImplementation implementation; 20 GLImplementation implementation;
21 } kGLImplementationNamePairs[] = { 21 } kGLImplementationNamePairs[] = {
22 { kGLImplementationDesktopName, kGLImplementationDesktopGL }, 22 { kGLImplementationDesktopName, kGLImplementationDesktopGL },
23 { kGLImplementationOSMesaName, kGLImplementationOSMesaGL }, 23 { kGLImplementationOSMesaName, kGLImplementationOSMesaGL },
24 #if defined(OS_MACOSX)
25 { kGLImplementationAppleName, kGLImplementationAppleGL },
26 #endif
24 { kGLImplementationEGLName, kGLImplementationEGLGLES2 }, 27 { kGLImplementationEGLName, kGLImplementationEGLGLES2 },
25 { kGLImplementationMockName, kGLImplementationMockGL } 28 { kGLImplementationMockName, kGLImplementationMockGL }
26 }; 29 };
27 30
28 typedef std::vector<base::NativeLibrary> LibraryArray; 31 typedef std::vector<base::NativeLibrary> LibraryArray;
29 32
30 GLImplementation g_gl_implementation = kGLImplementationNone; 33 GLImplementation g_gl_implementation = kGLImplementationNone;
31 LibraryArray* g_libraries; 34 LibraryArray* g_libraries;
32 GLGetProcAddressProc g_get_proc_address; 35 GLGetProcAddressProc g_get_proc_address;
33 36
34 void CleanupNativeLibraries(void* unused) { 37 void CleanupNativeLibraries(void* unused) {
35 if (g_libraries) { 38 if (g_libraries) {
36 for (LibraryArray::iterator it = g_libraries->begin(); 39 for (LibraryArray::iterator it = g_libraries->begin();
37 it != g_libraries->end(); ++it) { 40 it != g_libraries->end(); ++it) {
38 base::UnloadNativeLibrary(*it); 41 base::UnloadNativeLibrary(*it);
39 } 42 }
40 delete g_libraries; 43 delete g_libraries;
41 g_libraries = NULL; 44 g_libraries = NULL;
42 } 45 }
43 } 46 }
44 47
45 bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) { 48 bool ExportsCoreFunctionsFromGetProcAddress(GLImplementation implementation) {
46 switch (GetGLImplementation()) { 49 switch (GetGLImplementation()) {
47 case kGLImplementationDesktopGL: 50 case kGLImplementationDesktopGL:
48 case kGLImplementationOSMesaGL: 51 case kGLImplementationOSMesaGL:
52 case kGLImplementationAppleGL:
49 case kGLImplementationMockGL: 53 case kGLImplementationMockGL:
50 return true; 54 return true;
51 case kGLImplementationEGLGLES2: 55 case kGLImplementationEGLGLES2:
52 return false; 56 return false;
53 default: 57 default:
54 NOTREACHED(); 58 NOTREACHED();
55 return true; 59 return true;
56 } 60 }
57 } 61 }
58 62
(...skipping 20 matching lines...) Expand all
79 void SetGLImplementation(GLImplementation implementation) { 83 void SetGLImplementation(GLImplementation implementation) {
80 g_gl_implementation = implementation; 84 g_gl_implementation = implementation;
81 } 85 }
82 86
83 GLImplementation GetGLImplementation() { 87 GLImplementation GetGLImplementation() {
84 return g_gl_implementation; 88 return g_gl_implementation;
85 } 89 }
86 90
87 bool HasDesktopGLFeatures() { 91 bool HasDesktopGLFeatures() {
88 return kGLImplementationDesktopGL == g_gl_implementation || 92 return kGLImplementationDesktopGL == g_gl_implementation ||
89 kGLImplementationOSMesaGL == g_gl_implementation; 93 kGLImplementationOSMesaGL == g_gl_implementation ||
94 kGLImplementationAppleGL == g_gl_implementation;
90 } 95 }
91 96
92 void AddGLNativeLibrary(base::NativeLibrary library) { 97 void AddGLNativeLibrary(base::NativeLibrary library) {
93 DCHECK(library); 98 DCHECK(library);
94 99
95 if (!g_libraries) { 100 if (!g_libraries) {
96 g_libraries = new LibraryArray; 101 g_libraries = new LibraryArray;
97 base::AtExitManager::RegisterCallback(CleanupNativeLibraries, NULL); 102 base::AtExitManager::RegisterCallback(CleanupNativeLibraries, NULL);
98 } 103 }
99 104
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (!proc && g_get_proc_address) { 142 if (!proc && g_get_proc_address) {
138 proc = g_get_proc_address(name); 143 proc = g_get_proc_address(name);
139 if (proc) 144 if (proc)
140 return proc; 145 return proc;
141 } 146 }
142 147
143 return proc; 148 return proc;
144 } 149 }
145 150
146 } // namespace gfx 151 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698