OLD | NEW |
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 "ui/gl/gl_context_stub_with_extensions.h" | 7 #include "ui/gl/gl_context_stub_with_extensions.h" |
8 #include "ui/gl/gl_egl_api_implementation.h" | 8 #include "ui/gl/gl_egl_api_implementation.h" |
9 #include "ui/gl/gl_gl_api_implementation.h" | 9 #include "ui/gl/gl_gl_api_implementation.h" |
10 #include "ui/gl/gl_osmesa_api_implementation.h" | 10 #include "ui/gl/gl_osmesa_api_implementation.h" |
11 #include "ui/gl/gl_wgl_api_implementation.h" | 11 #include "ui/gl/gl_wgl_api_implementation.h" |
12 | 12 |
13 namespace gl { | 13 namespace gl { |
14 | 14 |
15 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { | 15 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
16 impls->push_back(kGLImplementationEGLGLES2); | 16 impls->push_back(kGLImplementationEGLGLES2); |
17 impls->push_back(kGLImplementationDesktopGL); | 17 impls->push_back(kGLImplementationDesktopGL); |
18 impls->push_back(kGLImplementationOSMesaGL); | 18 impls->push_back(kGLImplementationOSMesaGL); |
19 } | 19 } |
20 | 20 |
21 bool InitializeDynamicGLBindings(GLImplementation implementation, | |
22 GLContext* context) { | |
23 switch (implementation) { | |
24 case kGLImplementationOSMesaGL: | |
25 case kGLImplementationEGLGLES2: | |
26 case kGLImplementationDesktopGL: | |
27 InitializeDynamicGLBindingsGL(context); | |
28 break; | |
29 case kGLImplementationMockGL: | |
30 if (!context) { | |
31 scoped_refptr<GLContextStubWithExtensions> mock_context( | |
32 new GLContextStubWithExtensions()); | |
33 mock_context->SetGLVersionString("3.0"); | |
34 InitializeDynamicGLBindingsGL(mock_context.get()); | |
35 } else { | |
36 InitializeDynamicGLBindingsGL(context); | |
37 } | |
38 break; | |
39 default: | |
40 return false; | |
41 } | |
42 | |
43 return true; | |
44 } | |
45 | |
46 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { | 21 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { |
47 switch (GetGLImplementation()) { | 22 switch (GetGLImplementation()) { |
48 case kGLImplementationDesktopGL: | 23 case kGLImplementationDesktopGL: |
49 return GetGLWindowSystemBindingInfoWGL(info); | 24 return GetGLWindowSystemBindingInfoWGL(info); |
50 case kGLImplementationEGLGLES2: | 25 case kGLImplementationEGLGLES2: |
51 return GetGLWindowSystemBindingInfoEGL(info); | 26 return GetGLWindowSystemBindingInfoEGL(info); |
52 default: | 27 default: |
53 return false; | 28 return false; |
54 } | 29 } |
55 } | 30 } |
56 | 31 |
57 } // namespace gl | 32 } // namespace gl |
OLD | NEW |