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 |
11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
12 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
13 #include "ui/gfx/vsync_provider.h" | 13 #include "ui/gfx/vsync_provider.h" |
| 14 #include "ui/ozone/common/egl_util.h" |
14 #include "ui/ozone/platform/wayland/wayland_display.h" | 15 #include "ui/ozone/platform/wayland/wayland_display.h" |
15 #include "ui/ozone/platform/wayland/wayland_object.h" | 16 #include "ui/ozone/platform/wayland/wayland_object.h" |
16 #include "ui/ozone/platform/wayland/wayland_window.h" | 17 #include "ui/ozone/platform/wayland/wayland_window.h" |
17 #include "ui/ozone/public/surface_ozone_canvas.h" | 18 #include "ui/ozone/public/surface_ozone_canvas.h" |
18 #include "ui/ozone/public/surface_ozone_egl.h" | 19 #include "ui/ozone/public/surface_ozone_egl.h" |
19 | 20 |
| 21 #if defined(USE_WAYLAND_EGL) |
| 22 #include "ui/ozone/platform/wayland/wayland_egl_surface.h" |
| 23 #endif |
| 24 |
20 namespace ui { | 25 namespace ui { |
21 | 26 |
22 static void DeleteSharedMemory(void* pixels, void* context) { | 27 static void DeleteSharedMemory(void* pixels, void* context) { |
23 delete static_cast<base::SharedMemory*>(context); | 28 delete static_cast<base::SharedMemory*>(context); |
24 } | 29 } |
25 | 30 |
26 class WaylandCanvasSurface : public SurfaceOzoneCanvas { | 31 class WaylandCanvasSurface : public SurfaceOzoneCanvas { |
27 public: | 32 public: |
28 WaylandCanvasSurface(WaylandDisplay* display, WaylandWindow* window_); | 33 WaylandCanvasSurface(WaylandDisplay* display, WaylandWindow* window_); |
29 ~WaylandCanvasSurface() override; | 34 ~WaylandCanvasSurface() override; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 NOTIMPLEMENTED(); | 122 NOTIMPLEMENTED(); |
118 return nullptr; | 123 return nullptr; |
119 } | 124 } |
120 | 125 |
121 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandDisplay* display) | 126 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandDisplay* display) |
122 : display_(display) {} | 127 : display_(display) {} |
123 | 128 |
124 WaylandSurfaceFactory::~WaylandSurfaceFactory() {} | 129 WaylandSurfaceFactory::~WaylandSurfaceFactory() {} |
125 | 130 |
126 intptr_t WaylandSurfaceFactory::GetNativeDisplay() { | 131 intptr_t WaylandSurfaceFactory::GetNativeDisplay() { |
127 NOTIMPLEMENTED(); | 132 return reinterpret_cast<intptr_t>(display_->display()); |
128 return 0; | |
129 } | 133 } |
130 | 134 |
131 bool WaylandSurfaceFactory::LoadEGLGLES2Bindings( | 135 bool WaylandSurfaceFactory::LoadEGLGLES2Bindings( |
132 AddGLLibraryCallback add_gl_library, | 136 AddGLLibraryCallback add_gl_library, |
133 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 137 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
134 // This Ozone implementation does not support multi-process rendering so | 138 #if defined(USE_WAYLAND_EGL) |
135 // disable EGL unconditionally for now. | 139 if (!display_) |
| 140 return false; |
| 141 setenv("EGL_PLATFORM", "wayland", 0); |
| 142 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); |
| 143 #else |
136 return false; | 144 return false; |
| 145 #endif |
137 } | 146 } |
138 | 147 |
139 scoped_ptr<SurfaceOzoneCanvas> WaylandSurfaceFactory::CreateCanvasForWidget( | 148 scoped_ptr<SurfaceOzoneCanvas> WaylandSurfaceFactory::CreateCanvasForWidget( |
140 gfx::AcceleratedWidget widget) { | 149 gfx::AcceleratedWidget widget) { |
141 DCHECK(display_); | |
142 WaylandWindow* window = display_->GetWindow(widget); | 150 WaylandWindow* window = display_->GetWindow(widget); |
143 DCHECK(window); | 151 DCHECK(window); |
144 return make_scoped_ptr(new WaylandCanvasSurface(display_, window)); | 152 return make_scoped_ptr(new WaylandCanvasSurface(display_, window)); |
145 } | 153 } |
146 | 154 |
147 scoped_ptr<SurfaceOzoneEGL> WaylandSurfaceFactory::CreateEGLSurfaceForWidget( | 155 scoped_ptr<SurfaceOzoneEGL> WaylandSurfaceFactory::CreateEGLSurfaceForWidget( |
148 gfx::AcceleratedWidget widget) { | 156 gfx::AcceleratedWidget widget) { |
149 NOTREACHED(); | 157 #if defined(USE_WAYLAND_EGL) |
| 158 WaylandWindow* window = display_->GetWindow(widget); |
| 159 DCHECK(window); |
| 160 auto surface = make_scoped_ptr( |
| 161 new WaylandEGLSurface(window, window->GetBounds().size())); |
| 162 if (!surface->Initialize()) |
| 163 return nullptr; |
| 164 return std::move(surface); |
| 165 #else |
150 return nullptr; | 166 return nullptr; |
| 167 #endif |
151 } | 168 } |
152 | 169 |
153 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmap( | 170 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmap( |
154 gfx::AcceleratedWidget widget, | 171 gfx::AcceleratedWidget widget, |
155 gfx::Size size, | 172 gfx::Size size, |
156 gfx::BufferFormat format, | 173 gfx::BufferFormat format, |
157 gfx::BufferUsage usage) { | 174 gfx::BufferUsage usage) { |
158 NOTIMPLEMENTED(); | 175 NOTIMPLEMENTED(); |
159 return nullptr; | 176 return nullptr; |
160 } | 177 } |
161 | 178 |
162 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmapFromHandle( | 179 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmapFromHandle( |
163 gfx::Size size, | 180 gfx::Size size, |
164 gfx::BufferFormat format, | 181 gfx::BufferFormat format, |
165 const gfx::NativePixmapHandle& handle) { | 182 const gfx::NativePixmapHandle& handle) { |
166 NOTIMPLEMENTED(); | 183 NOTIMPLEMENTED(); |
167 return nullptr; | 184 return nullptr; |
168 } | 185 } |
169 | 186 |
170 } // namespace ui | 187 } // namespace ui |
OLD | NEW |