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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { | 78 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { |
79 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); | 79 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); |
80 switch (GetGLImplementation()) { | 80 switch (GetGLImplementation()) { |
81 case kGLImplementationOSMesaGL: | 81 case kGLImplementationOSMesaGL: |
82 return InitializeGLSurface(new GLSurfaceOSMesaWin(window)); | 82 return InitializeGLSurface(new GLSurfaceOSMesaWin(window)); |
83 case kGLImplementationSwiftShaderGL: | 83 case kGLImplementationSwiftShaderGL: |
84 case kGLImplementationEGLGLES2: { | 84 case kGLImplementationEGLGLES2: { |
85 DCHECK(window != gfx::kNullAcceleratedWidget); | 85 std::unique_ptr<gfx::VSyncProvider> sync_provider( |
86 scoped_refptr<NativeViewGLSurfaceEGL> surface( | 86 new VSyncProviderWin(window)); |
87 new NativeViewGLSurfaceEGL(window)); | 87 return CreateNativeViewGLSurfaceEGL(window, std::move(sync_provider)); |
88 std::unique_ptr<gfx::VSyncProvider> sync_provider; | |
89 sync_provider.reset(new VSyncProviderWin(window)); | |
90 if (!surface->Initialize(std::move(sync_provider))) | |
91 return nullptr; | |
92 | |
93 return surface; | |
94 } | 88 } |
95 case kGLImplementationDesktopGL: | 89 case kGLImplementationDesktopGL: |
96 return InitializeGLSurface(new NativeViewGLSurfaceWGL(window)); | 90 return InitializeGLSurface(new NativeViewGLSurfaceWGL(window)); |
97 case kGLImplementationMockGL: | 91 case kGLImplementationMockGL: |
98 case kGLImplementationStubGL: | 92 case kGLImplementationStubGL: |
99 return new GLSurfaceStub; | 93 return new GLSurfaceStub; |
100 default: | 94 default: |
101 NOTREACHED(); | 95 NOTREACHED(); |
102 return nullptr; | 96 return nullptr; |
103 } | 97 } |
104 } | 98 } |
105 | 99 |
| 100 scoped_refptr<GLSurface> CreateNativeViewGLSurfaceEGL( |
| 101 gfx::AcceleratedWidget window, |
| 102 std::unique_ptr<gfx::VSyncProvider> sync_provider) { |
| 103 DCHECK_EQ(kGLImplementationEGLGLES2, GetGLImplementation()); |
| 104 DCHECK(window != gfx::kNullAcceleratedWidget); |
| 105 |
| 106 scoped_refptr<NativeViewGLSurfaceEGL> surface( |
| 107 new NativeViewGLSurfaceEGL(window)); |
| 108 |
| 109 if (!surface->Initialize(std::move(sync_provider))) |
| 110 return nullptr; |
| 111 |
| 112 return surface; |
| 113 } |
| 114 |
106 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( | 115 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( |
107 const gfx::Size& size, GLSurfaceFormat format) { | 116 const gfx::Size& size, GLSurfaceFormat format) { |
108 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); | 117 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); |
109 switch (GetGLImplementation()) { | 118 switch (GetGLImplementation()) { |
110 case kGLImplementationOSMesaGL: | 119 case kGLImplementationOSMesaGL: |
111 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); | 120 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); |
112 return InitializeGLSurfaceWithFormat( | 121 return InitializeGLSurfaceWithFormat( |
113 new GLSurfaceOSMesa(format, size), format); | 122 new GLSurfaceOSMesa(format, size), format); |
114 case kGLImplementationSwiftShaderGL: | 123 case kGLImplementationSwiftShaderGL: |
115 case kGLImplementationEGLGLES2: | 124 case kGLImplementationEGLGLES2: |
116 return InitializeGLSurfaceWithFormat( | 125 return InitializeGLSurfaceWithFormat( |
117 new PbufferGLSurfaceEGL(size), format); | 126 new PbufferGLSurfaceEGL(size), format); |
118 case kGLImplementationDesktopGL: | 127 case kGLImplementationDesktopGL: |
119 return InitializeGLSurfaceWithFormat( | 128 return InitializeGLSurfaceWithFormat( |
120 new PbufferGLSurfaceWGL(size), format); | 129 new PbufferGLSurfaceWGL(size), format); |
121 case kGLImplementationMockGL: | 130 case kGLImplementationMockGL: |
122 case kGLImplementationStubGL: | 131 case kGLImplementationStubGL: |
123 return new GLSurfaceStub; | 132 return new GLSurfaceStub; |
124 default: | 133 default: |
125 NOTREACHED(); | 134 NOTREACHED(); |
126 return nullptr; | 135 return nullptr; |
127 } | 136 } |
128 } | 137 } |
129 | 138 |
130 } // namespace init | 139 } // namespace init |
131 } // namespace gl | 140 } // namespace gl |
OLD | NEW |