Chromium Code Reviews| 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/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 Loading... | |
| 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 Loading... | |
| 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 setenv("EGL_PLATFORM", "wayland", 0); | 180 setenv("EGL_PLATFORM", "wayland", 0); |
|
rjkroege
2017/06/12 17:23:40
I suspect that the setenv should be skipped if we'
tonikitoo
2017/06/12 18:32:17
I believe the comment pasted below is relevant (so
sadrul
2017/06/12 19:37:00
Sounds like the safest option is to always set the
| |
| 181 return LoadDefaultEGLGLES2Bindings(); | 181 return LoadDefaultEGLGLES2Bindings(impl); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace | 184 } // namespace |
| 185 | 185 |
| 186 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandConnection* connection) | 186 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandConnection* connection) |
| 187 : connection_(connection), | 187 : connection_(connection), |
| 188 osmesa_implementation_(base::MakeUnique<GLOzoneOSMesa>()) { | 188 osmesa_implementation_(base::MakeUnique<GLOzoneOSMesa>()) { |
| 189 if (connection_) | 189 if (connection_) |
| 190 egl_implementation_ = base::MakeUnique<GLOzoneEGLWayland>(connection_); | 190 egl_implementation_ = base::MakeUnique<GLOzoneEGLWayland>(connection_); |
| 191 } | 191 } |
| 192 | 192 |
| 193 WaylandSurfaceFactory::~WaylandSurfaceFactory() {} | 193 WaylandSurfaceFactory::~WaylandSurfaceFactory() {} |
| 194 | 194 |
| 195 std::unique_ptr<SurfaceOzoneCanvas> | 195 std::unique_ptr<SurfaceOzoneCanvas> |
| 196 WaylandSurfaceFactory::CreateCanvasForWidget(gfx::AcceleratedWidget widget) { | 196 WaylandSurfaceFactory::CreateCanvasForWidget(gfx::AcceleratedWidget widget) { |
| 197 if (!connection_) | 197 if (!connection_) |
| 198 return nullptr; | 198 return nullptr; |
| 199 WaylandWindow* window = connection_->GetWindow(widget); | 199 WaylandWindow* window = connection_->GetWindow(widget); |
| 200 DCHECK(window); | 200 DCHECK(window); |
| 201 return base::MakeUnique<WaylandCanvasSurface>(connection_, window); | 201 return base::MakeUnique<WaylandCanvasSurface>(connection_, window); |
| 202 } | 202 } |
| 203 | 203 |
| 204 std::vector<gl::GLImplementation> | 204 std::vector<gl::GLImplementation> |
| 205 WaylandSurfaceFactory::GetAllowedGLImplementations() { | 205 WaylandSurfaceFactory::GetAllowedGLImplementations() { |
| 206 std::vector<gl::GLImplementation> impls; | 206 std::vector<gl::GLImplementation> impls; |
| 207 if (egl_implementation_) | 207 if (egl_implementation_) { |
| 208 impls.push_back(gl::kGLImplementationEGLGLES2); | 208 impls.push_back(gl::kGLImplementationEGLGLES2); |
| 209 impls.push_back(gl::kGLImplementationSwiftShaderGL); | |
| 210 } | |
| 209 impls.push_back(gl::kGLImplementationOSMesaGL); | 211 impls.push_back(gl::kGLImplementationOSMesaGL); |
| 210 return impls; | 212 return impls; |
| 211 } | 213 } |
| 212 | 214 |
| 213 GLOzone* WaylandSurfaceFactory::GetGLOzone( | 215 GLOzone* WaylandSurfaceFactory::GetGLOzone( |
| 214 gl::GLImplementation implementation) { | 216 gl::GLImplementation implementation) { |
| 215 switch (implementation) { | 217 switch (implementation) { |
| 216 case gl::kGLImplementationEGLGLES2: | 218 case gl::kGLImplementationEGLGLES2: |
| 217 return egl_implementation_.get(); | 219 return egl_implementation_.get(); |
| 218 case gl::kGLImplementationOSMesaGL: | 220 case gl::kGLImplementationOSMesaGL: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 235 WaylandSurfaceFactory::CreateNativePixmapFromHandle( | 237 WaylandSurfaceFactory::CreateNativePixmapFromHandle( |
| 236 gfx::AcceleratedWidget widget, | 238 gfx::AcceleratedWidget widget, |
| 237 gfx::Size size, | 239 gfx::Size size, |
| 238 gfx::BufferFormat format, | 240 gfx::BufferFormat format, |
| 239 const gfx::NativePixmapHandle& handle) { | 241 const gfx::NativePixmapHandle& handle) { |
| 240 NOTIMPLEMENTED(); | 242 NOTIMPLEMENTED(); |
| 241 return nullptr; | 243 return nullptr; |
| 242 } | 244 } |
| 243 | 245 |
| 244 } // namespace ui | 246 } // namespace ui |
| OLD | NEW |