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" |
(...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 kGLImplementationEGLGLES2: | 56 case kGLImplementationEGLGLES2: |
57 return InitializeGLContext(new GLContextEGL(share_group), | 57 return InitializeGLContext(new GLContextEGL(share_group), |
58 compatible_surface, attribs); | 58 compatible_surface, attribs); |
59 case kGLImplementationDesktopGL: | 59 case kGLImplementationDesktopGL: |
60 return InitializeGLContext(new GLContextWGL(share_group), | 60 return InitializeGLContext(new GLContextWGL(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 GLSurfaceOSMesaWin(window)); | 80 return InitializeGLSurface(new GLSurfaceOSMesaWin(window)); |
75 case kGLImplementationEGLGLES2: { | 81 case kGLImplementationEGLGLES2: { |
76 DCHECK(window != gfx::kNullAcceleratedWidget); | 82 DCHECK(window != gfx::kNullAcceleratedWidget); |
77 scoped_refptr<NativeViewGLSurfaceEGL> surface( | 83 scoped_refptr<NativeViewGLSurfaceEGL> surface( |
78 new NativeViewGLSurfaceEGL(window)); | 84 new NativeViewGLSurfaceEGL(window)); |
79 std::unique_ptr<gfx::VSyncProvider> sync_provider; | 85 std::unique_ptr<gfx::VSyncProvider> sync_provider; |
80 sync_provider.reset(new VSyncProviderWin(window)); | 86 sync_provider.reset(new VSyncProviderWin(window)); |
81 if (!surface->Initialize(std::move(sync_provider))) | 87 if (!surface->Initialize(std::move(sync_provider))) |
82 return nullptr; | 88 return nullptr; |
83 | 89 |
84 return surface; | 90 return surface; |
85 } | 91 } |
86 case kGLImplementationDesktopGL: | 92 case kGLImplementationDesktopGL: |
87 return InitializeGLSurface(new NativeViewGLSurfaceWGL(window)); | 93 return InitializeGLSurface(new NativeViewGLSurfaceWGL(window)); |
88 case kGLImplementationMockGL: | 94 case kGLImplementationMockGL: |
| 95 case kGLImplementationStubGL: |
89 return new GLSurfaceStub; | 96 return new GLSurfaceStub; |
90 default: | 97 default: |
91 NOTREACHED(); | 98 NOTREACHED(); |
92 return nullptr; | 99 return nullptr; |
93 } | 100 } |
94 } | 101 } |
95 | 102 |
96 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( | 103 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( |
97 const gfx::Size& size, GLSurfaceFormat format) { | 104 const gfx::Size& size, GLSurfaceFormat format) { |
98 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); | 105 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); |
99 switch (GetGLImplementation()) { | 106 switch (GetGLImplementation()) { |
100 case kGLImplementationOSMesaGL: | 107 case kGLImplementationOSMesaGL: |
101 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); | 108 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); |
102 return InitializeGLSurfaceWithFormat( | 109 return InitializeGLSurfaceWithFormat( |
103 new GLSurfaceOSMesa(format, size), format); | 110 new GLSurfaceOSMesa(format, size), format); |
104 case kGLImplementationEGLGLES2: | 111 case kGLImplementationEGLGLES2: |
105 return InitializeGLSurfaceWithFormat( | 112 return InitializeGLSurfaceWithFormat( |
106 new PbufferGLSurfaceEGL(size), format); | 113 new PbufferGLSurfaceEGL(size), format); |
107 case kGLImplementationDesktopGL: | 114 case kGLImplementationDesktopGL: |
108 return InitializeGLSurfaceWithFormat( | 115 return InitializeGLSurfaceWithFormat( |
109 new PbufferGLSurfaceWGL(size), format); | 116 new PbufferGLSurfaceWGL(size), format); |
110 case kGLImplementationMockGL: | 117 case kGLImplementationMockGL: |
| 118 case kGLImplementationStubGL: |
111 return new GLSurfaceStub; | 119 return new GLSurfaceStub; |
112 default: | 120 default: |
113 NOTREACHED(); | 121 NOTREACHED(); |
114 return nullptr; | 122 return nullptr; |
115 } | 123 } |
116 } | 124 } |
117 | 125 |
118 } // namespace init | 126 } // namespace init |
119 } // namespace gl | 127 } // namespace gl |
OLD | NEW |