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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 case kGLImplementationMockGL: | 88 case kGLImplementationMockGL: |
89 return new GLSurfaceStub; | 89 return new GLSurfaceStub; |
90 default: | 90 default: |
91 NOTREACHED(); | 91 NOTREACHED(); |
92 return nullptr; | 92 return nullptr; |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { | 96 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { |
97 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); | 97 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); |
| 98 scoped_refptr<GLSurface> surface = |
| 99 CreateUninitializedOffscreenGLSurface(size); |
| 100 if (surface && GetGLImplementation() != kGLImplementationMockGL) |
| 101 InitializeGLSurface(surface); |
| 102 return surface; |
| 103 } |
| 104 |
| 105 scoped_refptr<GLSurface> CreateUninitializedOffscreenGLSurface( |
| 106 const gfx::Size& size) { |
| 107 TRACE_EVENT0("gpu", "gl::init::CreateUninitializedOffscreenGLSurface"); |
98 switch (GetGLImplementation()) { | 108 switch (GetGLImplementation()) { |
99 case kGLImplementationOSMesaGL: | 109 case kGLImplementationOSMesaGL: |
100 return InitializeGLSurface( | 110 return new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_RGBA, size); |
101 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_RGBA, size)); | |
102 case kGLImplementationEGLGLES2: | 111 case kGLImplementationEGLGLES2: |
103 return InitializeGLSurface(new PbufferGLSurfaceEGL(size)); | 112 return new PbufferGLSurfaceEGL(size); |
104 case kGLImplementationDesktopGL: | 113 case kGLImplementationDesktopGL: |
105 return InitializeGLSurface(new PbufferGLSurfaceWGL(size)); | 114 return new PbufferGLSurfaceWGL(size); |
106 case kGLImplementationMockGL: | 115 case kGLImplementationMockGL: |
107 return new GLSurfaceStub; | 116 return new GLSurfaceStub; |
108 default: | 117 default: |
109 NOTREACHED(); | 118 NOTREACHED(); |
110 return nullptr; | 119 return nullptr; |
111 } | 120 } |
112 } | 121 } |
113 | 122 |
114 } // namespace init | 123 } // namespace init |
115 } // namespace gl | 124 } // namespace gl |
OLD | NEW |