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

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

Issue 94963003: Take GL version and extensions correctly into account when binding functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Improve Windows initialization and renderBufferMultisample explanation Created 7 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
« no previous file with comments | « ui/gl/gl_implementation_linux.cc ('k') | ui/gl/gl_implementation_ozone.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) 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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/native_library.h" 9 #include "base/native_library.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "ui/gl/gl_bindings.h" 12 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_context_stub_with_extensions.h"
13 #include "ui/gl/gl_gl_api_implementation.h" 14 #include "ui/gl/gl_gl_api_implementation.h"
14 #include "ui/gl/gl_implementation.h" 15 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_osmesa_api_implementation.h" 16 #include "ui/gl/gl_osmesa_api_implementation.h"
16 17
17 namespace gfx { 18 namespace gfx {
18 namespace { 19 namespace {
19 const char kOpenGLFrameworkPath[] = 20 const char kOpenGLFrameworkPath[] =
20 "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"; 21 "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL";
21 } // namespace 22 } // namespace
22 23
23 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 24 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
24 impls->push_back(kGLImplementationDesktopGL); 25 impls->push_back(kGLImplementationDesktopGL);
25 impls->push_back(kGLImplementationAppleGL); 26 impls->push_back(kGLImplementationAppleGL);
26 impls->push_back(kGLImplementationOSMesaGL); 27 impls->push_back(kGLImplementationOSMesaGL);
27 } 28 }
28 29
29 bool InitializeGLBindings(GLImplementation implementation) { 30 bool InitializeStaticGLBindings(GLImplementation implementation) {
30 // Prevent reinitialization with a different implementation. Once the gpu 31 // Prevent reinitialization with a different implementation. Once the gpu
31 // unit tests have initialized with kGLImplementationMock, we don't want to 32 // unit tests have initialized with kGLImplementationMock, we don't want to
32 // later switch to another GL implementation. 33 // later switch to another GL implementation.
33 if (GetGLImplementation() != kGLImplementationNone) 34 if (GetGLImplementation() != kGLImplementationNone)
34 return true; 35 return true;
35 36
36 // Allow the main thread or another to initialize these bindings 37 // Allow the main thread or another to initialize these bindings
37 // after instituting restrictions on I/O. Going forward they will 38 // after instituting restrictions on I/O. Going forward they will
38 // likely be used in the browser process on most platforms. The 39 // likely be used in the browser process on most platforms. The
39 // one-time initialization cost is small, between 2 and 5 ms. 40 // one-time initialization cost is small, between 2 and 5 ms.
(...skipping 30 matching lines...) Expand all
70 if (!get_proc_address) { 71 if (!get_proc_address) {
71 LOG(ERROR) << "OSMesaGetProcAddress not found."; 72 LOG(ERROR) << "OSMesaGetProcAddress not found.";
72 base::UnloadNativeLibrary(library); 73 base::UnloadNativeLibrary(library);
73 return false; 74 return false;
74 } 75 }
75 76
76 SetGLGetProcAddressProc(get_proc_address); 77 SetGLGetProcAddressProc(get_proc_address);
77 AddGLNativeLibrary(library); 78 AddGLNativeLibrary(library);
78 SetGLImplementation(kGLImplementationOSMesaGL); 79 SetGLImplementation(kGLImplementationOSMesaGL);
79 80
80 InitializeGLBindingsGL(); 81 InitializeStaticGLBindingsGL();
81 InitializeGLBindingsOSMESA(); 82 InitializeStaticGLBindingsOSMESA();
82 break; 83 break;
83 } 84 }
84 case kGLImplementationDesktopGL: 85 case kGLImplementationDesktopGL:
85 case kGLImplementationAppleGL: { 86 case kGLImplementationAppleGL: {
86 base::NativeLibrary library = base::LoadNativeLibrary( 87 base::NativeLibrary library = base::LoadNativeLibrary(
87 base::FilePath(kOpenGLFrameworkPath), NULL); 88 base::FilePath(kOpenGLFrameworkPath), NULL);
88 if (!library) { 89 if (!library) {
89 LOG(ERROR) << "OpenGL framework not found"; 90 LOG(ERROR) << "OpenGL framework not found";
90 return false; 91 return false;
91 } 92 }
92 93
93 AddGLNativeLibrary(library); 94 AddGLNativeLibrary(library);
94 SetGLImplementation(implementation); 95 SetGLImplementation(implementation);
95 96
96 InitializeGLBindingsGL(); 97 InitializeStaticGLBindingsGL();
97 break; 98 break;
98 } 99 }
99 case kGLImplementationMockGL: { 100 case kGLImplementationMockGL: {
100 SetGLGetProcAddressProc(GetMockGLProcAddress); 101 SetGLGetProcAddressProc(GetMockGLProcAddress);
101 SetGLImplementation(kGLImplementationMockGL); 102 SetGLImplementation(kGLImplementationMockGL);
102 InitializeGLBindingsGL(); 103 InitializeStaticGLBindingsGL();
103 break; 104 break;
104 } 105 }
105 default: 106 default:
106 return false; 107 return false;
107 } 108 }
108 109
109 return true; 110 return true;
110 } 111 }
111 112
112 bool InitializeGLExtensionBindings(GLImplementation implementation, 113 bool InitializeDynamicGLBindings(GLImplementation implementation,
113 GLContext* context) { 114 GLContext* context) {
114 switch (implementation) { 115 switch (implementation) {
115 case kGLImplementationOSMesaGL: 116 case kGLImplementationOSMesaGL:
116 InitializeGLExtensionBindingsGL(context); 117 InitializeDynamicGLBindingsGL(context);
117 InitializeGLExtensionBindingsOSMESA(context); 118 InitializeDynamicGLBindingsOSMESA(context);
118 break; 119 break;
119 case kGLImplementationDesktopGL: 120 case kGLImplementationDesktopGL:
120 case kGLImplementationAppleGL: 121 case kGLImplementationAppleGL:
121 InitializeGLExtensionBindingsGL(context); 122 InitializeDynamicGLBindingsGL(context);
122 break; 123 break;
123 case kGLImplementationMockGL: 124 case kGLImplementationMockGL:
124 InitializeGLExtensionBindingsGL(context); 125 if (!context) {
126 scoped_refptr<GLContextStubWithExtensions> mock_context(
127 new GLContextStubWithExtensions());
128 mock_context->SetGLVersionString("3.0");
129 InitializeDynamicGLBindingsGL(mock_context.get());
130 } else
131 InitializeDynamicGLBindingsGL(context);
125 break; 132 break;
126 default: 133 default:
127 return false; 134 return false;
128 } 135 }
129 136
130 return true; 137 return true;
131 } 138 }
132 139
133 void InitializeDebugGLBindings() { 140 void InitializeDebugGLBindings() {
134 InitializeDebugGLBindingsGL(); 141 InitializeDebugGLBindingsGL();
135 InitializeDebugGLBindingsOSMESA(); 142 InitializeDebugGLBindingsOSMESA();
136 } 143 }
137 144
138 void ClearGLBindings() { 145 void ClearGLBindings() {
139 ClearGLBindingsGL(); 146 ClearGLBindingsGL();
140 ClearGLBindingsOSMESA(); 147 ClearGLBindingsOSMESA();
141 SetGLImplementation(kGLImplementationNone); 148 SetGLImplementation(kGLImplementationNone);
142 149
143 UnloadGLNativeLibraries(); 150 UnloadGLNativeLibraries();
144 } 151 }
145 152
146 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { 153 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
147 return false; 154 return false;
148 } 155 }
149 156
150 } // namespace gfx 157 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_implementation_linux.cc ('k') | ui/gl/gl_implementation_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698