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

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

Issue 2431383002: Ozone: Remove the use_wayland_egl build flag (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « ui/ozone/platform/wayland/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "third_party/skia/include/core/SkSurface.h" 13 #include "third_party/skia/include/core/SkSurface.h"
14 #include "ui/gfx/vsync_provider.h" 14 #include "ui/gfx/vsync_provider.h"
15 #include "ui/ozone/common/egl_util.h" 15 #include "ui/ozone/common/egl_util.h"
16 #include "ui/ozone/common/gl_ozone_egl.h" 16 #include "ui/ozone/common/gl_ozone_egl.h"
17 #include "ui/ozone/platform/wayland/gl_surface_wayland.h"
17 #include "ui/ozone/platform/wayland/wayland_connection.h" 18 #include "ui/ozone/platform/wayland/wayland_connection.h"
18 #include "ui/ozone/platform/wayland/wayland_object.h" 19 #include "ui/ozone/platform/wayland/wayland_object.h"
19 #include "ui/ozone/platform/wayland/wayland_window.h" 20 #include "ui/ozone/platform/wayland/wayland_window.h"
20 #include "ui/ozone/public/surface_ozone_canvas.h" 21 #include "ui/ozone/public/surface_ozone_canvas.h"
21 22
22 #if defined(USE_WAYLAND_EGL)
23 #include "ui/ozone/platform/wayland/gl_surface_wayland.h"
24 #endif
25
26 namespace ui { 23 namespace ui {
27 24
28 static void DeleteSharedMemory(void* pixels, void* context) { 25 static void DeleteSharedMemory(void* pixels, void* context) {
29 delete static_cast<base::SharedMemory*>(context); 26 delete static_cast<base::SharedMemory*>(context);
30 } 27 }
31 28
32 class WaylandCanvasSurface : public SurfaceOzoneCanvas { 29 class WaylandCanvasSurface : public SurfaceOzoneCanvas {
33 public: 30 public:
34 WaylandCanvasSurface(WaylandConnection* connection, WaylandWindow* window_); 31 WaylandCanvasSurface(WaylandConnection* connection, WaylandWindow* window_);
35 ~WaylandCanvasSurface() override; 32 ~WaylandCanvasSurface() override;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 bool LoadGLES2Bindings() override; 142 bool LoadGLES2Bindings() override;
146 143
147 private: 144 private:
148 WaylandConnection* connection_; 145 WaylandConnection* connection_;
149 146
150 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLWayland); 147 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLWayland);
151 }; 148 };
152 149
153 scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateViewGLSurface( 150 scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateViewGLSurface(
154 gfx::AcceleratedWidget widget) { 151 gfx::AcceleratedWidget widget) {
155 #if defined(USE_WAYLAND_EGL)
156 DCHECK(connection_); 152 DCHECK(connection_);
157 WaylandWindow* window = connection_->GetWindow(widget); 153 WaylandWindow* window = connection_->GetWindow(widget);
158 DCHECK(window); 154 DCHECK(window);
159 // The wl_egl_window needs to be created before the GLSurface so it can be 155 // The wl_egl_window needs to be created before the GLSurface so it can be
160 // used in the GLSurface constructor. 156 // used in the GLSurface constructor.
161 auto egl_window = CreateWaylandEglWindow(window); 157 auto egl_window = CreateWaylandEglWindow(window);
162 if (!egl_window) 158 if (!egl_window)
163 return nullptr; 159 return nullptr;
164 return gl::InitializeGLSurface(new GLSurfaceWayland(std::move(egl_window))); 160 return gl::InitializeGLSurface(new GLSurfaceWayland(std::move(egl_window)));
165 #else
166 return nullptr;
167 #endif
168 } 161 }
169 162
170 scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateOffscreenGLSurface( 163 scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateOffscreenGLSurface(
171 const gfx::Size& size) { 164 const gfx::Size& size) {
172 #if defined(USE_WAYLAND_EGL)
173 if (gl::GLSurfaceEGL::IsEGLSurfacelessContextSupported() && 165 if (gl::GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
174 size.width() == 0 && size.height() == 0) { 166 size.width() == 0 && size.height() == 0) {
175 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size)); 167 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size));
176 } else { 168 } else {
177 return gl::InitializeGLSurface(new gl::PbufferGLSurfaceEGL(size)); 169 return gl::InitializeGLSurface(new gl::PbufferGLSurfaceEGL(size));
178 } 170 }
179 #else
180 return nullptr;
181 #endif
182 } 171 }
183 172
184 intptr_t GLOzoneEGLWayland::GetNativeDisplay() { 173 intptr_t GLOzoneEGLWayland::GetNativeDisplay() {
185 return reinterpret_cast<intptr_t>(connection_->display()); 174 return reinterpret_cast<intptr_t>(connection_->display());
186 } 175 }
187 176
188 bool GLOzoneEGLWayland::LoadGLES2Bindings() { 177 bool GLOzoneEGLWayland::LoadGLES2Bindings() {
189 #if defined(USE_WAYLAND_EGL)
190 setenv("EGL_PLATFORM", "wayland", 0); 178 setenv("EGL_PLATFORM", "wayland", 0);
191 return LoadDefaultEGLGLES2Bindings(); 179 return LoadDefaultEGLGLES2Bindings();
192 #else
193 return false;
194 #endif
195 } 180 }
196 181
197 } // namespace 182 } // namespace
198 183
199 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandConnection* connection) 184 WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandConnection* connection)
200 : connection_(connection) { 185 : connection_(connection) {
201 if (connection_) 186 if (connection_)
202 egl_implementation_.reset(new GLOzoneEGLWayland(connection_)); 187 egl_implementation_.reset(new GLOzoneEGLWayland(connection_));
203 } 188 }
204 189
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmapFromHandle( 227 scoped_refptr<NativePixmap> WaylandSurfaceFactory::CreateNativePixmapFromHandle(
243 gfx::AcceleratedWidget widget, 228 gfx::AcceleratedWidget widget,
244 gfx::Size size, 229 gfx::Size size,
245 gfx::BufferFormat format, 230 gfx::BufferFormat format,
246 const gfx::NativePixmapHandle& handle) { 231 const gfx::NativePixmapHandle& handle) {
247 NOTIMPLEMENTED(); 232 NOTIMPLEMENTED();
248 return nullptr; 233 return nullptr;
249 } 234 }
250 235
251 } // namespace ui 236 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/wayland/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698