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 DCHECK(display_); |
128 return 0; | 133 return reinterpret_cast<intptr_t>(display_->display()); |
129 } | 134 } |
130 | 135 |
131 bool WaylandSurfaceFactory::LoadEGLGLES2Bindings( | 136 bool WaylandSurfaceFactory::LoadEGLGLES2Bindings( |
132 AddGLLibraryCallback add_gl_library, | 137 AddGLLibraryCallback add_gl_library, |
133 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 138 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
134 // This Ozone implementation does not support multi-process rendering so | 139 #if defined(USE_WAYLAND_EGL) |
135 // disable EGL unconditionally for now. | 140 if (!display_) |
141 return false; | |
142 setenv("EGL_PLATFORM", "wayland", 0); | |
143 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); | |
144 #else | |
136 return false; | 145 return false; |
146 #endif | |
137 } | 147 } |
138 | 148 |
139 scoped_ptr<SurfaceOzoneCanvas> WaylandSurfaceFactory::CreateCanvasForWidget( | 149 scoped_ptr<SurfaceOzoneCanvas> WaylandSurfaceFactory::CreateCanvasForWidget( |
140 gfx::AcceleratedWidget widget) { | 150 gfx::AcceleratedWidget widget) { |
141 DCHECK(display_); | 151 DCHECK(display_); |
142 WaylandWindow* window = display_->GetWindow(widget); | 152 WaylandWindow* window = display_->GetWindow(widget); |
143 DCHECK(window); | 153 DCHECK(window); |
144 return make_scoped_ptr(new WaylandCanvasSurface(display_, window)); | 154 return make_scoped_ptr(new WaylandCanvasSurface(display_, window)); |
145 } | 155 } |
146 | 156 |
147 scoped_ptr<SurfaceOzoneEGL> WaylandSurfaceFactory::CreateEGLSurfaceForWidget( | 157 scoped_ptr<SurfaceOzoneEGL> WaylandSurfaceFactory::CreateEGLSurfaceForWidget( |
148 gfx::AcceleratedWidget widget) { | 158 gfx::AcceleratedWidget widget) { |
149 NOTREACHED(); | 159 #if defined(USE_WAYLAND_EGL) |
160 DCHECK(display_); | |
spang
2016/02/24 16:12:11
It's not useful to DCHECK if you immediately deref
Michael Forney
2016/02/24 22:46:41
Done.
| |
161 WaylandWindow* window = display_->GetWindow(widget); | |
162 DCHECK(window); | |
163 auto surface = make_scoped_ptr( | |
164 new WaylandEGLSurface(window, window->GetBounds().size())); | |
165 if (!surface->Initialize()) | |
166 return nullptr; | |
167 return std::move(surface); | |
168 #else | |
150 return nullptr; | 169 return nullptr; |
170 #endif | |
151 } | 171 } |
152 | 172 |
153 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmap( | 173 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmap( |
154 gfx::AcceleratedWidget widget, | 174 gfx::AcceleratedWidget widget, |
155 gfx::Size size, | 175 gfx::Size size, |
156 gfx::BufferFormat format, | 176 gfx::BufferFormat format, |
157 gfx::BufferUsage usage) { | 177 gfx::BufferUsage usage) { |
158 NOTIMPLEMENTED(); | 178 NOTIMPLEMENTED(); |
159 return nullptr; | 179 return nullptr; |
160 } | 180 } |
161 | 181 |
162 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmapFromHandle( | 182 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmapFromHandle( |
163 const gfx::NativePixmapHandle& handle) { | 183 const gfx::NativePixmapHandle& handle) { |
164 NOTIMPLEMENTED(); | 184 NOTIMPLEMENTED(); |
165 return nullptr; | 185 return nullptr; |
166 } | 186 } |
167 | 187 |
168 } // namespace ui | 188 } // namespace ui |
OLD | NEW |