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

Side by Side Diff: ui/ozone/platform/wayland/wayland_surface_factory.cc

Issue 2926423002: ozone: Allow using swiftshader with --use-gl=swiftshader. (Closed)
Patch Set: . Created 3 years, 6 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/ozone/platform/wayland/wayland_surface_factory.h" 5 #include "ui/ozone/platform/wayland/wayland_surface_factory.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <wayland-client.h> 9 #include <wayland-client.h>
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ~GLOzoneEGLWayland() override {} 134 ~GLOzoneEGLWayland() override {}
135 135
136 scoped_refptr<gl::GLSurface> CreateViewGLSurface( 136 scoped_refptr<gl::GLSurface> CreateViewGLSurface(
137 gfx::AcceleratedWidget widget) override; 137 gfx::AcceleratedWidget widget) override;
138 138
139 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface( 139 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(
140 const gfx::Size& size) override; 140 const gfx::Size& size) override;
141 141
142 protected: 142 protected:
143 intptr_t GetNativeDisplay() override; 143 intptr_t GetNativeDisplay() override;
144 bool LoadGLES2Bindings() override; 144 bool LoadGLES2Bindings(gl::GLImplementation impl) override;
145 145
146 private: 146 private:
147 WaylandConnection* connection_; 147 WaylandConnection* connection_;
148 148
149 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLWayland); 149 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLWayland);
150 }; 150 };
151 151
152 scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateViewGLSurface( 152 scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateViewGLSurface(
153 gfx::AcceleratedWidget widget) { 153 gfx::AcceleratedWidget widget) {
154 DCHECK(connection_); 154 DCHECK(connection_);
(...skipping 14 matching lines...) Expand all
169 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size)); 169 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size));
170 } else { 170 } else {
171 return gl::InitializeGLSurface(new gl::PbufferGLSurfaceEGL(size)); 171 return gl::InitializeGLSurface(new gl::PbufferGLSurfaceEGL(size));
172 } 172 }
173 } 173 }
174 174
175 intptr_t GLOzoneEGLWayland::GetNativeDisplay() { 175 intptr_t GLOzoneEGLWayland::GetNativeDisplay() {
176 return reinterpret_cast<intptr_t>(connection_->display()); 176 return reinterpret_cast<intptr_t>(connection_->display());
177 } 177 }
178 178
179 bool GLOzoneEGLWayland::LoadGLES2Bindings() { 179 bool GLOzoneEGLWayland::LoadGLES2Bindings(gl::GLImplementation impl) {
180 // TODO: It may not be necessary to set this environment variable when using
181 // swiftshader.
180 setenv("EGL_PLATFORM", "wayland", 0); 182 setenv("EGL_PLATFORM", "wayland", 0);
181 return LoadDefaultEGLGLES2Bindings(); 183 return LoadDefaultEGLGLES2Bindings(impl);
182 } 184 }
183 185
184 } // namespace 186 } // namespace
185 187
186 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandConnection* connection) 188 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandConnection* connection)
187 : connection_(connection), 189 : connection_(connection),
188 osmesa_implementation_(base::MakeUnique<GLOzoneOSMesa>()) { 190 osmesa_implementation_(base::MakeUnique<GLOzoneOSMesa>()) {
189 if (connection_) 191 if (connection_)
190 egl_implementation_ = base::MakeUnique<GLOzoneEGLWayland>(connection_); 192 egl_implementation_ = base::MakeUnique<GLOzoneEGLWayland>(connection_);
191 } 193 }
192 194
193 WaylandSurfaceFactory::~WaylandSurfaceFactory() {} 195 WaylandSurfaceFactory::~WaylandSurfaceFactory() {}
194 196
195 std::unique_ptr<SurfaceOzoneCanvas> 197 std::unique_ptr<SurfaceOzoneCanvas>
196 WaylandSurfaceFactory::CreateCanvasForWidget(gfx::AcceleratedWidget widget) { 198 WaylandSurfaceFactory::CreateCanvasForWidget(gfx::AcceleratedWidget widget) {
197 if (!connection_) 199 if (!connection_)
198 return nullptr; 200 return nullptr;
199 WaylandWindow* window = connection_->GetWindow(widget); 201 WaylandWindow* window = connection_->GetWindow(widget);
200 DCHECK(window); 202 DCHECK(window);
201 return base::MakeUnique<WaylandCanvasSurface>(connection_, window); 203 return base::MakeUnique<WaylandCanvasSurface>(connection_, window);
202 } 204 }
203 205
204 std::vector<gl::GLImplementation> 206 std::vector<gl::GLImplementation>
205 WaylandSurfaceFactory::GetAllowedGLImplementations() { 207 WaylandSurfaceFactory::GetAllowedGLImplementations() {
206 std::vector<gl::GLImplementation> impls; 208 std::vector<gl::GLImplementation> impls;
207 if (egl_implementation_) 209 if (egl_implementation_) {
208 impls.push_back(gl::kGLImplementationEGLGLES2); 210 impls.push_back(gl::kGLImplementationEGLGLES2);
211 impls.push_back(gl::kGLImplementationSwiftShaderGL);
212 }
209 impls.push_back(gl::kGLImplementationOSMesaGL); 213 impls.push_back(gl::kGLImplementationOSMesaGL);
210 return impls; 214 return impls;
211 } 215 }
212 216
213 GLOzone* WaylandSurfaceFactory::GetGLOzone( 217 GLOzone* WaylandSurfaceFactory::GetGLOzone(
214 gl::GLImplementation implementation) { 218 gl::GLImplementation implementation) {
215 switch (implementation) { 219 switch (implementation) {
216 case gl::kGLImplementationEGLGLES2: 220 case gl::kGLImplementationEGLGLES2:
217 return egl_implementation_.get(); 221 return egl_implementation_.get();
218 case gl::kGLImplementationOSMesaGL: 222 case gl::kGLImplementationOSMesaGL:
(...skipping 16 matching lines...) Expand all
235 WaylandSurfaceFactory::CreateNativePixmapFromHandle( 239 WaylandSurfaceFactory::CreateNativePixmapFromHandle(
236 gfx::AcceleratedWidget widget, 240 gfx::AcceleratedWidget widget,
237 gfx::Size size, 241 gfx::Size size,
238 gfx::BufferFormat format, 242 gfx::BufferFormat format,
239 const gfx::NativePixmapHandle& handle) { 243 const gfx::NativePixmapHandle& handle) {
240 NOTIMPLEMENTED(); 244 NOTIMPLEMENTED();
241 return nullptr; 245 return nullptr;
242 } 246 }
243 247
244 } // namespace ui 248 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surface_factory.cc ('k') | ui/ozone/platform/x11/x11_surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698