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_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 return InitializeGLSurface(new GLSurfaceStub()); | 126 return InitializeGLSurface(new GLSurfaceStub()); |
127 } | 127 } |
128 default: | 128 default: |
129 NOTREACHED(); | 129 NOTREACHED(); |
130 return nullptr; | 130 return nullptr; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { | 134 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { |
135 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); | 135 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); |
136 scoped_refptr<GLSurface> surface = | |
137 CreateUninitializedOffscreenGLSurface(size); | |
138 if (surface && GetGLImplementation() != kGLImplementationMockGL) | |
piman
2016/11/16 00:44:03
Here and other places: no need to check against kG
klausw
2017/01/05 02:17:43
Moot, no longer applicable in the new refactor.
| |
139 InitializeGLSurface(surface); | |
140 return surface; | |
141 } | |
142 | |
143 scoped_refptr<GLSurface> CreateUninitializedOffscreenGLSurface( | |
144 const gfx::Size& size) { | |
145 TRACE_EVENT0("gpu", "gl::init::CreateUninitializedOffscreenGLSurface"); | |
136 CHECK_NE(kGLImplementationNone, GetGLImplementation()); | 146 CHECK_NE(kGLImplementationNone, GetGLImplementation()); |
137 switch (GetGLImplementation()) { | 147 switch (GetGLImplementation()) { |
138 case kGLImplementationOSMesaGL: { | 148 case kGLImplementationOSMesaGL: { |
139 return InitializeGLSurface( | 149 return new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size); |
140 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size)); | |
141 } | 150 } |
142 case kGLImplementationEGLGLES2: { | 151 case kGLImplementationEGLGLES2: { |
143 scoped_refptr<GLSurface> surface; | 152 scoped_refptr<GLSurface> surface; |
144 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && | 153 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && |
145 (size.width() == 0 && size.height() == 0)) { | 154 (size.width() == 0 && size.height() == 0)) { |
146 return InitializeGLSurface(new SurfacelessEGL(size)); | 155 return new SurfacelessEGL(size); |
147 } else { | 156 } else { |
148 return InitializeGLSurface(new PbufferGLSurfaceEGL(size)); | 157 return new PbufferGLSurfaceEGL(size); |
149 } | 158 } |
150 } | 159 } |
151 case kGLImplementationMockGL: | 160 case kGLImplementationMockGL: |
152 return new GLSurfaceStub; | 161 return new GLSurfaceStub; |
153 default: | 162 default: |
154 NOTREACHED(); | 163 NOTREACHED(); |
155 return nullptr; | 164 return nullptr; |
156 } | 165 } |
157 } | 166 } |
158 | 167 |
159 } // namespace init | 168 } // namespace init |
160 } // namespace gl | 169 } // namespace gl |
OLD | NEW |