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/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "ui/gl/gl_context.h" | 8 #include "ui/gl/gl_context.h" |
9 #include "ui/gl/gl_context_egl.h" | 9 #include "ui/gl/gl_context_egl.h" |
10 #include "ui/gl/gl_context_glx.h" | 10 #include "ui/gl/gl_context_glx.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return InitializeGLContext(new GLContextOSMesa(share_group), | 54 return InitializeGLContext(new GLContextOSMesa(share_group), |
55 compatible_surface, attribs); | 55 compatible_surface, attribs); |
56 case kGLImplementationDesktopGL: | 56 case kGLImplementationDesktopGL: |
57 return InitializeGLContext(new GLContextGLX(share_group), | 57 return InitializeGLContext(new GLContextGLX(share_group), |
58 compatible_surface, attribs); | 58 compatible_surface, attribs); |
59 case kGLImplementationEGLGLES2: | 59 case kGLImplementationEGLGLES2: |
60 return InitializeGLContext(new GLContextEGL(share_group), | 60 return InitializeGLContext(new GLContextEGL(share_group), |
61 compatible_surface, attribs); | 61 compatible_surface, attribs); |
62 case kGLImplementationMockGL: | 62 case kGLImplementationMockGL: |
63 return new GLContextStub(share_group); | 63 return new GLContextStub(share_group); |
| 64 case kGLImplementationStubGL: { |
| 65 scoped_refptr<GLContextStub> stub_context = |
| 66 new GLContextStub(share_group); |
| 67 stub_context->SetUseStubApi(true); |
| 68 return stub_context; |
| 69 } |
64 default: | 70 default: |
65 NOTREACHED(); | 71 NOTREACHED(); |
66 return nullptr; | 72 return nullptr; |
67 } | 73 } |
68 } | 74 } |
69 | 75 |
70 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { | 76 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { |
71 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); | 77 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); |
72 switch (GetGLImplementation()) { | 78 switch (GetGLImplementation()) { |
73 case kGLImplementationOSMesaGL: | 79 case kGLImplementationOSMesaGL: |
74 return InitializeGLSurface(new GLSurfaceOSMesaX11(window)); | 80 return InitializeGLSurface(new GLSurfaceOSMesaX11(window)); |
75 case kGLImplementationDesktopGL: | 81 case kGLImplementationDesktopGL: |
76 return InitializeGLSurface(new GLSurfaceGLXX11(window)); | 82 return InitializeGLSurface(new GLSurfaceGLXX11(window)); |
77 case kGLImplementationEGLGLES2: | 83 case kGLImplementationEGLGLES2: |
78 DCHECK(window != gfx::kNullAcceleratedWidget); | 84 DCHECK(window != gfx::kNullAcceleratedWidget); |
79 return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window)); | 85 return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window)); |
80 case kGLImplementationMockGL: | 86 case kGLImplementationMockGL: |
| 87 case kGLImplementationStubGL: |
81 return new GLSurfaceStub; | 88 return new GLSurfaceStub; |
82 default: | 89 default: |
83 NOTREACHED(); | 90 NOTREACHED(); |
84 return nullptr; | 91 return nullptr; |
85 } | 92 } |
86 } | 93 } |
87 | 94 |
88 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( | 95 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( |
89 const gfx::Size& size, GLSurfaceFormat format) { | 96 const gfx::Size& size, GLSurfaceFormat format) { |
90 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); | 97 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); |
91 switch (GetGLImplementation()) { | 98 switch (GetGLImplementation()) { |
92 case kGLImplementationOSMesaGL: | 99 case kGLImplementationOSMesaGL: |
93 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); | 100 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); |
94 return InitializeGLSurfaceWithFormat( | 101 return InitializeGLSurfaceWithFormat( |
95 new GLSurfaceOSMesa(format, size), format); | 102 new GLSurfaceOSMesa(format, size), format); |
96 case kGLImplementationDesktopGL: | 103 case kGLImplementationDesktopGL: |
97 return InitializeGLSurfaceWithFormat( | 104 return InitializeGLSurfaceWithFormat( |
98 new UnmappedNativeViewGLSurfaceGLX(size), format); | 105 new UnmappedNativeViewGLSurfaceGLX(size), format); |
99 case kGLImplementationEGLGLES2: | 106 case kGLImplementationEGLGLES2: |
100 return InitializeGLSurfaceWithFormat( | 107 return InitializeGLSurfaceWithFormat( |
101 new PbufferGLSurfaceEGL(size), format); | 108 new PbufferGLSurfaceEGL(size), format); |
102 case kGLImplementationMockGL: | 109 case kGLImplementationMockGL: |
| 110 case kGLImplementationStubGL: |
103 return new GLSurfaceStub; | 111 return new GLSurfaceStub; |
104 default: | 112 default: |
105 NOTREACHED(); | 113 NOTREACHED(); |
106 return nullptr; | 114 return nullptr; |
107 } | 115 } |
108 } | 116 } |
109 | 117 |
110 } // namespace init | 118 } // namespace init |
111 } // namespace gl | 119 } // namespace gl |
OLD | NEW |