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

Side by Side Diff: ui/gfx/gl/gl_implementation_mac.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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/native_library.h" 10 #include "base/native_library.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "ui/gfx/gl/gl_bindings.h" 12 #include "ui/gfx/gl/gl_bindings.h"
13 #include "ui/gfx/gl/gl_implementation.h" 13 #include "ui/gfx/gl/gl_implementation.h"
14 14
15 namespace gfx { 15 namespace gfx {
16 namespace { 16 namespace {
17 const char kOpenGLFrameworkPath[] = 17 const char kOpenGLFrameworkPath[] =
18 "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"; 18 "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL";
19 } // namespace anonymous 19 } // namespace anonymous
20 20
21 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 21 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
22 impls->push_back(kGLImplementationDesktopGL); 22 impls->push_back(kGLImplementationDesktopGL);
23 impls->push_back(kGLImplementationAppleGL);
23 impls->push_back(kGLImplementationOSMesaGL); 24 impls->push_back(kGLImplementationOSMesaGL);
24 } 25 }
25 26
26 bool InitializeGLBindings(GLImplementation implementation) { 27 bool InitializeGLBindings(GLImplementation implementation) {
27 // Prevent reinitialization with a different implementation. Once the gpu 28 // Prevent reinitialization with a different implementation. Once the gpu
28 // unit tests have initialized with kGLImplementationMock, we don't want to 29 // unit tests have initialized with kGLImplementationMock, we don't want to
29 // later switch to another GL implementation. 30 // later switch to another GL implementation.
30 if (GetGLImplementation() != kGLImplementationNone) 31 if (GetGLImplementation() != kGLImplementationNone)
31 return true; 32 return true;
32 33
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 68 }
68 69
69 SetGLGetProcAddressProc(get_proc_address); 70 SetGLGetProcAddressProc(get_proc_address);
70 AddGLNativeLibrary(library); 71 AddGLNativeLibrary(library);
71 SetGLImplementation(kGLImplementationOSMesaGL); 72 SetGLImplementation(kGLImplementationOSMesaGL);
72 73
73 InitializeGLBindingsGL(); 74 InitializeGLBindingsGL();
74 InitializeGLBindingsOSMESA(); 75 InitializeGLBindingsOSMESA();
75 break; 76 break;
76 } 77 }
77 case kGLImplementationDesktopGL: { 78 case kGLImplementationDesktopGL:
79 case kGLImplementationAppleGL: {
78 base::NativeLibrary library = base::LoadNativeLibrary( 80 base::NativeLibrary library = base::LoadNativeLibrary(
79 FilePath(kOpenGLFrameworkPath), NULL); 81 FilePath(kOpenGLFrameworkPath), NULL);
80 if (!library) { 82 if (!library) {
81 LOG(ERROR) << "OpenGL framework not found"; 83 LOG(ERROR) << "OpenGL framework not found";
82 return false; 84 return false;
83 } 85 }
84 86
85 AddGLNativeLibrary(library); 87 AddGLNativeLibrary(library);
86 SetGLImplementation(kGLImplementationDesktopGL); 88 SetGLImplementation(implementation);
87 89
88 InitializeGLBindingsGL(); 90 InitializeGLBindingsGL();
89 break; 91 break;
90 } 92 }
91 case kGLImplementationMockGL: { 93 case kGLImplementationMockGL: {
92 SetGLGetProcAddressProc(GetMockGLProcAddress); 94 SetGLGetProcAddressProc(GetMockGLProcAddress);
93 SetGLImplementation(kGLImplementationMockGL); 95 SetGLImplementation(kGLImplementationMockGL);
94 InitializeGLBindingsGL(); 96 InitializeGLBindingsGL();
95 break; 97 break;
96 } 98 }
97 default: 99 default:
98 return false; 100 return false;
99 } 101 }
100 102
101 return true; 103 return true;
102 } 104 }
103 105
104 bool InitializeGLExtensionBindings(GLImplementation implementation, 106 bool InitializeGLExtensionBindings(GLImplementation implementation,
105 GLContext* context) { 107 GLContext* context) {
106 switch (implementation) { 108 switch (implementation) {
107 case kGLImplementationOSMesaGL: 109 case kGLImplementationOSMesaGL:
108 InitializeGLExtensionBindingsGL(context); 110 InitializeGLExtensionBindingsGL(context);
109 InitializeGLExtensionBindingsOSMESA(context); 111 InitializeGLExtensionBindingsOSMESA(context);
110 break; 112 break;
111 case kGLImplementationDesktopGL: 113 case kGLImplementationDesktopGL:
114 case kGLImplementationAppleGL:
112 InitializeGLExtensionBindingsGL(context); 115 InitializeGLExtensionBindingsGL(context);
113 break; 116 break;
114 case kGLImplementationMockGL: 117 case kGLImplementationMockGL:
115 InitializeGLExtensionBindingsGL(context); 118 InitializeGLExtensionBindingsGL(context);
116 break; 119 break;
117 default: 120 default:
118 return false; 121 return false;
119 } 122 }
120 123
121 return true; 124 return true;
122 } 125 }
123 126
124 void InitializeDebugGLBindings() { 127 void InitializeDebugGLBindings() {
125 InitializeDebugGLBindingsGL(); 128 InitializeDebugGLBindingsGL();
126 InitializeDebugGLBindingsOSMESA(); 129 InitializeDebugGLBindingsOSMESA();
127 } 130 }
128 131
129 void ClearGLBindings() { 132 void ClearGLBindings() {
130 ClearGLBindingsGL(); 133 ClearGLBindingsGL();
131 ClearGLBindingsOSMESA(); 134 ClearGLBindingsOSMESA();
132 SetGLImplementation(kGLImplementationNone); 135 SetGLImplementation(kGLImplementationNone);
133 136
134 UnloadGLNativeLibraries(); 137 UnloadGLNativeLibraries();
135 } 138 }
136 139
137 } // namespace gfx 140 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698