Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: ui/gl/init/gl_factory_x11.cc

Issue 2680423002: Introducing 2 usages for SwiftShader (Closed)
Patch Set: Added missing change to GpuDataManagerImplPrivate Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "ui/gl/gl_context.h" 8 #include "ui/gl/gl_context.h"
9 #include "ui/gl/gl_context_egl.h" 9 #include "ui/gl/gl_context_egl.h"
10 #include "ui/gl/gl_context_glx.h" 10 #include "ui/gl/gl_context_glx.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/gl/gl_surface_stub.h" 24 #include "ui/gl/gl_surface_stub.h"
25 25
26 namespace gl { 26 namespace gl {
27 namespace init { 27 namespace init {
28 28
29 std::vector<GLImplementation> GetAllowedGLImplementations() { 29 std::vector<GLImplementation> GetAllowedGLImplementations() {
30 std::vector<GLImplementation> impls; 30 std::vector<GLImplementation> impls;
31 impls.push_back(kGLImplementationDesktopGL); 31 impls.push_back(kGLImplementationDesktopGL);
32 impls.push_back(kGLImplementationEGLGLES2); 32 impls.push_back(kGLImplementationEGLGLES2);
33 impls.push_back(kGLImplementationOSMesaGL); 33 impls.push_back(kGLImplementationOSMesaGL);
34 impls.push_back(kGLImplementationSwiftShaderGL);
34 return impls; 35 return impls;
35 } 36 }
36 37
37 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { 38 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
38 switch (GetGLImplementation()) { 39 switch (GetGLImplementation()) {
39 case kGLImplementationDesktopGL: 40 case kGLImplementationDesktopGL:
40 return GetGLWindowSystemBindingInfoGLX(info); 41 return GetGLWindowSystemBindingInfoGLX(info);
41 case kGLImplementationEGLGLES2: 42 case kGLImplementationEGLGLES2:
42 return GetGLWindowSystemBindingInfoEGL(info); 43 return GetGLWindowSystemBindingInfoEGL(info);
43 default: 44 default:
44 return false; 45 return false;
45 } 46 }
46 } 47 }
47 48
48 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, 49 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
49 GLSurface* compatible_surface, 50 GLSurface* compatible_surface,
50 const GLContextAttribs& attribs) { 51 const GLContextAttribs& attribs) {
51 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 52 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
52 switch (GetGLImplementation()) { 53 switch (GetGLImplementation()) {
53 case kGLImplementationOSMesaGL: 54 case kGLImplementationOSMesaGL:
54 return InitializeGLContext(new GLContextOSMesa(share_group), 55 return InitializeGLContext(new GLContextOSMesa(share_group),
55 compatible_surface, attribs); 56 compatible_surface, attribs);
56 case kGLImplementationDesktopGL: 57 case kGLImplementationDesktopGL:
57 return InitializeGLContext(new GLContextGLX(share_group), 58 return InitializeGLContext(new GLContextGLX(share_group),
58 compatible_surface, attribs); 59 compatible_surface, attribs);
60 case kGLImplementationSwiftShaderGL:
59 case kGLImplementationEGLGLES2: 61 case kGLImplementationEGLGLES2:
60 return InitializeGLContext(new GLContextEGL(share_group), 62 return InitializeGLContext(new GLContextEGL(share_group),
61 compatible_surface, attribs); 63 compatible_surface, attribs);
62 case kGLImplementationMockGL: 64 case kGLImplementationMockGL:
63 return new GLContextStub(share_group); 65 return new GLContextStub(share_group);
64 case kGLImplementationStubGL: { 66 case kGLImplementationStubGL: {
65 scoped_refptr<GLContextStub> stub_context = 67 scoped_refptr<GLContextStub> stub_context =
66 new GLContextStub(share_group); 68 new GLContextStub(share_group);
67 stub_context->SetUseStubApi(true); 69 stub_context->SetUseStubApi(true);
68 return stub_context; 70 return stub_context;
69 } 71 }
70 default: 72 default:
71 NOTREACHED(); 73 NOTREACHED();
72 return nullptr; 74 return nullptr;
73 } 75 }
74 } 76 }
75 77
76 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { 78 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
77 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); 79 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
78 switch (GetGLImplementation()) { 80 switch (GetGLImplementation()) {
79 case kGLImplementationOSMesaGL: 81 case kGLImplementationOSMesaGL:
80 return InitializeGLSurface(new GLSurfaceOSMesaX11(window)); 82 return InitializeGLSurface(new GLSurfaceOSMesaX11(window));
81 case kGLImplementationDesktopGL: 83 case kGLImplementationDesktopGL:
82 return InitializeGLSurface(new GLSurfaceGLXX11(window)); 84 return InitializeGLSurface(new GLSurfaceGLXX11(window));
85 case kGLImplementationSwiftShaderGL:
83 case kGLImplementationEGLGLES2: 86 case kGLImplementationEGLGLES2:
84 DCHECK(window != gfx::kNullAcceleratedWidget); 87 DCHECK(window != gfx::kNullAcceleratedWidget);
85 return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window)); 88 return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window));
86 case kGLImplementationMockGL: 89 case kGLImplementationMockGL:
87 case kGLImplementationStubGL: 90 case kGLImplementationStubGL:
88 return new GLSurfaceStub; 91 return new GLSurfaceStub;
89 default: 92 default:
90 NOTREACHED(); 93 NOTREACHED();
91 return nullptr; 94 return nullptr;
92 } 95 }
93 } 96 }
94 97
95 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( 98 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat(
96 const gfx::Size& size, GLSurfaceFormat format) { 99 const gfx::Size& size, GLSurfaceFormat format) {
97 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); 100 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
98 switch (GetGLImplementation()) { 101 switch (GetGLImplementation()) {
99 case kGLImplementationOSMesaGL: 102 case kGLImplementationOSMesaGL:
100 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA); 103 format.SetDefaultPixelLayout(GLSurfaceFormat::PIXEL_LAYOUT_RGBA);
101 return InitializeGLSurfaceWithFormat( 104 return InitializeGLSurfaceWithFormat(
102 new GLSurfaceOSMesa(format, size), format); 105 new GLSurfaceOSMesa(format, size), format);
103 case kGLImplementationDesktopGL: 106 case kGLImplementationDesktopGL:
104 return InitializeGLSurfaceWithFormat( 107 return InitializeGLSurfaceWithFormat(
105 new UnmappedNativeViewGLSurfaceGLX(size), format); 108 new UnmappedNativeViewGLSurfaceGLX(size), format);
109 case kGLImplementationSwiftShaderGL:
106 case kGLImplementationEGLGLES2: 110 case kGLImplementationEGLGLES2:
107 return InitializeGLSurfaceWithFormat( 111 return InitializeGLSurfaceWithFormat(
108 new PbufferGLSurfaceEGL(size), format); 112 new PbufferGLSurfaceEGL(size), format);
109 case kGLImplementationMockGL: 113 case kGLImplementationMockGL:
110 case kGLImplementationStubGL: 114 case kGLImplementationStubGL:
111 return new GLSurfaceStub; 115 return new GLSurfaceStub;
112 default: 116 default:
113 NOTREACHED(); 117 NOTREACHED();
114 return nullptr; 118 return nullptr;
115 } 119 }
116 } 120 }
117 121
118 } // namespace init 122 } // namespace init
119 } // namespace gl 123 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698