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