OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/init/gl_factory.h" | 5 #include "ui/gl/init/gl_factory.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/macros.h" | 9 #include "base/macros.h" |
9 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
10 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
11 #include "ui/gl/gl_context_cgl.h" | 12 #include "ui/gl/gl_context_cgl.h" |
12 #include "ui/gl/gl_context_osmesa.h" | 13 #include "ui/gl/gl_context_osmesa.h" |
13 #include "ui/gl/gl_context_stub.h" | 14 #include "ui/gl/gl_context_stub.h" |
14 #include "ui/gl/gl_implementation.h" | 15 #include "ui/gl/gl_implementation.h" |
15 #include "ui/gl/gl_share_group.h" | 16 #include "ui/gl/gl_share_group.h" |
16 #include "ui/gl/gl_surface.h" | 17 #include "ui/gl/gl_surface.h" |
17 #include "ui/gl/gl_surface_osmesa.h" | 18 #include "ui/gl/gl_surface_osmesa.h" |
18 #include "ui/gl/gl_surface_stub.h" | 19 #include "ui/gl/gl_surface_stub.h" |
| 20 #include "ui/gl/gl_switches.h" |
19 | 21 |
20 namespace gl { | 22 namespace gl { |
21 namespace init { | 23 namespace init { |
22 | 24 |
23 namespace { | 25 namespace { |
24 | 26 |
25 // A "no-op" surface. It is not required that a CGLContextObj have an | 27 // A "no-op" surface. It is not required that a CGLContextObj have an |
26 // associated drawable (pbuffer or fullscreen context) in order to be | 28 // associated drawable (pbuffer or fullscreen context) in order to be |
27 // made current. Everywhere this surface type is used, we allocate an | 29 // made current. Everywhere this surface type is used, we allocate an |
28 // FBO at the user level as the drawable of the associated context. | 30 // FBO at the user level as the drawable of the associated context. |
(...skipping 18 matching lines...) Expand all Loading... |
47 ~NoOpGLSurface() override {} | 49 ~NoOpGLSurface() override {} |
48 | 50 |
49 private: | 51 private: |
50 gfx::Size size_; | 52 gfx::Size size_; |
51 | 53 |
52 DISALLOW_COPY_AND_ASSIGN(NoOpGLSurface); | 54 DISALLOW_COPY_AND_ASSIGN(NoOpGLSurface); |
53 }; | 55 }; |
54 | 56 |
55 } // namespace | 57 } // namespace |
56 | 58 |
| 59 std::vector<GLImplementation> GetAllowedGLImplementations() { |
| 60 std::vector<GLImplementation> impls; |
| 61 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 62 switches::kEnableUnsafeES3APIs)) { |
| 63 impls.push_back(kGLImplementationDesktopGLCoreProfile); |
| 64 } |
| 65 impls.push_back(kGLImplementationDesktopGL); |
| 66 impls.push_back(kGLImplementationAppleGL); |
| 67 impls.push_back(kGLImplementationOSMesaGL); |
| 68 return impls; |
| 69 } |
| 70 |
| 71 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { |
| 72 return false; |
| 73 } |
| 74 |
57 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, | 75 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, |
58 GLSurface* compatible_surface, | 76 GLSurface* compatible_surface, |
59 GpuPreference gpu_preference) { | 77 GpuPreference gpu_preference) { |
60 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); | 78 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); |
61 switch (GetGLImplementation()) { | 79 switch (GetGLImplementation()) { |
62 case kGLImplementationDesktopGL: | 80 case kGLImplementationDesktopGL: |
63 case kGLImplementationDesktopGLCoreProfile: | 81 case kGLImplementationDesktopGLCoreProfile: |
64 case kGLImplementationAppleGL: | 82 case kGLImplementationAppleGL: |
65 // Note that with virtualization we might still be able to make current | 83 // Note that with virtualization we might still be able to make current |
66 // a different onscreen surface with this context later. But we should | 84 // a different onscreen surface with this context later. But we should |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 case kGLImplementationMockGL: | 130 case kGLImplementationMockGL: |
113 return new GLSurfaceStub; | 131 return new GLSurfaceStub; |
114 default: | 132 default: |
115 NOTREACHED(); | 133 NOTREACHED(); |
116 return nullptr; | 134 return nullptr; |
117 } | 135 } |
118 } | 136 } |
119 | 137 |
120 } // namespace init | 138 } // namespace init |
121 } // namespace gl | 139 } // namespace gl |
OLD | NEW |