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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
10 #include "ui/gl/gl_context_egl.h" | 10 #include "ui/gl/gl_context_egl.h" |
11 #include "ui/gl/gl_context_osmesa.h" | 11 #include "ui/gl/gl_context_osmesa.h" |
12 #include "ui/gl/gl_context_stub.h" | 12 #include "ui/gl/gl_context_stub.h" |
13 #include "ui/gl/gl_egl_api_implementation.h" | 13 #include "ui/gl/gl_egl_api_implementation.h" |
14 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
15 #include "ui/gl/gl_share_group.h" | 15 #include "ui/gl/gl_share_group.h" |
16 #include "ui/gl/gl_surface.h" | 16 #include "ui/gl/gl_surface.h" |
17 #include "ui/gl/gl_surface_egl.h" | 17 #include "ui/gl/gl_surface_egl.h" |
18 #include "ui/gl/gl_surface_osmesa.h" | 18 #include "ui/gl/gl_surface_osmesa.h" |
19 #include "ui/gl/gl_surface_stub.h" | 19 #include "ui/gl/gl_surface_stub.h" |
20 #include "ui/gl/init/ozone_util.h" | 20 #include "ui/gl/init/ozone_util.h" |
21 #include "ui/ozone/public/ozone_platform.h" | 21 #include "ui/ozone/public/ozone_platform.h" |
22 #include "ui/ozone/public/surface_factory_ozone.h" | 22 #include "ui/ozone/public/surface_factory_ozone.h" |
23 | 23 |
24 namespace gl { | 24 namespace gl { |
25 namespace init { | 25 namespace init { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 bool HasDefaultImplementation(GLImplementation impl) { | 29 bool HasDefaultImplementation(GLImplementation impl) { |
30 return impl == kGLImplementationOSMesaGL || impl == kGLImplementationMockGL; | 30 return impl == kGLImplementationOSMesaGL || impl == kGLImplementationMockGL || |
| 31 impl == kGLImplementationStubGL; |
31 } | 32 } |
32 | 33 |
33 scoped_refptr<GLSurface> CreateDefaultViewGLSurface( | 34 scoped_refptr<GLSurface> CreateDefaultViewGLSurface( |
34 gfx::AcceleratedWidget window) { | 35 gfx::AcceleratedWidget window) { |
35 switch (GetGLImplementation()) { | 36 switch (GetGLImplementation()) { |
36 case kGLImplementationOSMesaGL: | 37 case kGLImplementationOSMesaGL: |
37 return InitializeGLSurface(new GLSurfaceOSMesaHeadless()); | 38 return InitializeGLSurface(new GLSurfaceOSMesaHeadless()); |
38 case kGLImplementationMockGL: | 39 case kGLImplementationMockGL: |
| 40 case kGLImplementationStubGL: |
39 return InitializeGLSurface(new GLSurfaceStub()); | 41 return InitializeGLSurface(new GLSurfaceStub()); |
40 default: | 42 default: |
41 NOTREACHED(); | 43 NOTREACHED(); |
42 } | 44 } |
43 return nullptr; | 45 return nullptr; |
44 } | 46 } |
45 | 47 |
46 scoped_refptr<GLSurface> CreateDefaultOffscreenGLSurface( | 48 scoped_refptr<GLSurface> CreateDefaultOffscreenGLSurface( |
47 const gfx::Size& size) { | 49 const gfx::Size& size) { |
48 switch (GetGLImplementation()) { | 50 switch (GetGLImplementation()) { |
49 case kGLImplementationOSMesaGL: | 51 case kGLImplementationOSMesaGL: |
50 return InitializeGLSurface( | 52 return InitializeGLSurface( |
51 new GLSurfaceOSMesa( | 53 new GLSurfaceOSMesa( |
52 GLSurfaceFormat(GLSurfaceFormat::PIXEL_LAYOUT_BGRA), size)); | 54 GLSurfaceFormat(GLSurfaceFormat::PIXEL_LAYOUT_BGRA), size)); |
53 case kGLImplementationMockGL: | 55 case kGLImplementationMockGL: |
| 56 case kGLImplementationStubGL: |
54 return InitializeGLSurface(new GLSurfaceStub); | 57 return InitializeGLSurface(new GLSurfaceStub); |
55 default: | 58 default: |
56 NOTREACHED(); | 59 NOTREACHED(); |
57 } | 60 } |
58 return nullptr; | 61 return nullptr; |
59 } | 62 } |
60 | 63 |
61 } // namespace | 64 } // namespace |
62 | 65 |
63 std::vector<GLImplementation> GetAllowedGLImplementations() { | 66 std::vector<GLImplementation> GetAllowedGLImplementations() { |
(...skipping 21 matching lines...) Expand all Loading... |
85 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); | 88 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); |
86 | 89 |
87 if (HasGLOzone()) { | 90 if (HasGLOzone()) { |
88 return GetGLOzone()->CreateGLContext(share_group, compatible_surface, | 91 return GetGLOzone()->CreateGLContext(share_group, compatible_surface, |
89 attribs); | 92 attribs); |
90 } | 93 } |
91 | 94 |
92 switch (GetGLImplementation()) { | 95 switch (GetGLImplementation()) { |
93 case kGLImplementationMockGL: | 96 case kGLImplementationMockGL: |
94 return scoped_refptr<GLContext>(new GLContextStub(share_group)); | 97 return scoped_refptr<GLContext>(new GLContextStub(share_group)); |
| 98 case kGLImplementationStubGL: { |
| 99 scoped_refptr<GLContextStub> stub_context = |
| 100 new GLContextStub(share_group); |
| 101 stub_context->SetUseStubApi(true); |
| 102 return stub_context; |
| 103 } |
95 case kGLImplementationOSMesaGL: | 104 case kGLImplementationOSMesaGL: |
96 return InitializeGLContext(new GLContextOSMesa(share_group), | 105 return InitializeGLContext(new GLContextOSMesa(share_group), |
97 compatible_surface, attribs); | 106 compatible_surface, attribs); |
98 case kGLImplementationEGLGLES2: | 107 case kGLImplementationEGLGLES2: |
99 return InitializeGLContext(new GLContextEGL(share_group), | 108 return InitializeGLContext(new GLContextEGL(share_group), |
100 compatible_surface, attribs); | 109 compatible_surface, attribs); |
101 default: | 110 default: |
102 NOTREACHED(); | 111 NOTREACHED(); |
103 } | 112 } |
104 return nullptr; | 113 return nullptr; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return CreateDefaultOffscreenGLSurface(size); | 157 return CreateDefaultOffscreenGLSurface(size); |
149 | 158 |
150 // TODO(kylechar): This is deprecated and can be removed once all Ozone | 159 // TODO(kylechar): This is deprecated and can be removed once all Ozone |
151 // platforms use GLOzone instead. | 160 // platforms use GLOzone instead. |
152 return GetSurfaceFactoryOzone()->CreateOffscreenGLSurface( | 161 return GetSurfaceFactoryOzone()->CreateOffscreenGLSurface( |
153 GetGLImplementation(), size); | 162 GetGLImplementation(), size); |
154 } | 163 } |
155 | 164 |
156 } // namespace init | 165 } // namespace init |
157 } // namespace gl | 166 } // namespace gl |
OLD | NEW |