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/gl_surface_wayland.h" | 5 #include "ui/ozone/platform/wayland/gl_surface_wayland.h" |
6 | 6 |
7 #include <wayland-egl.h> | 7 #include <wayland-egl.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "third_party/khronos/EGL/egl.h" | 11 #include "third_party/khronos/EGL/egl.h" |
12 #include "ui/ozone/common/egl_util.h" | 12 #include "ui/ozone/common/egl_util.h" |
13 #include "ui/ozone/platform/wayland/wayland_window.h" | 13 #include "ui/ozone/platform/wayland/wayland_window.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 void EGLWindowDeleter::operator()(wl_egl_window* egl_window) { | 17 void EGLWindowDeleter::operator()(wl_egl_window* egl_window) { |
18 wl_egl_window_destroy(egl_window); | 18 wl_egl_window_destroy(egl_window); |
19 } | 19 } |
20 | 20 |
21 std::unique_ptr<wl_egl_window, EGLWindowDeleter> CreateWaylandEglWindow( | 21 std::unique_ptr<wl_egl_window, EGLWindowDeleter> CreateWaylandEglWindow( |
22 WaylandWindow* window) { | 22 WaylandWindow* window) { |
23 gfx::Size size = window->GetBounds().size(); | 23 gfx::Size size = window->GetBounds().size(); |
24 return std::unique_ptr<wl_egl_window, EGLWindowDeleter>( | 24 return std::unique_ptr<wl_egl_window, EGLWindowDeleter>( |
25 wl_egl_window_create(window->surface(), size.width(), size.height())); | 25 wl_egl_window_create(window->surface(), size.width(), size.height())); |
26 } | 26 } |
27 | 27 |
28 GLSurfaceWayland::GLSurfaceWayland(WaylandEglWindowPtr egl_window) | 28 GLSurfaceWayland::GLSurfaceWayland(WaylandEglWindowPtr egl_window) |
29 : NativeViewGLSurfaceEGL( | 29 : NativeViewGLSurfaceEGL( |
30 reinterpret_cast<EGLNativeWindowType>(egl_window.get())), | 30 reinterpret_cast<EGLNativeWindowType>(egl_window.get()), |
| 31 nullptr), |
31 egl_window_(std::move(egl_window)) { | 32 egl_window_(std::move(egl_window)) { |
32 DCHECK(egl_window_); | 33 DCHECK(egl_window_); |
33 } | 34 } |
34 | 35 |
35 bool GLSurfaceWayland::Resize(const gfx::Size& size, | 36 bool GLSurfaceWayland::Resize(const gfx::Size& size, |
36 float scale_factor, | 37 float scale_factor, |
37 bool has_alpha) { | 38 bool has_alpha) { |
38 if (size_ == size) | 39 if (size_ == size) |
39 return true; | 40 return true; |
40 wl_egl_window_resize(egl_window_.get(), size.width(), size.height(), 0, 0); | 41 wl_egl_window_resize(egl_window_.get(), size.width(), size.height(), 0, 0); |
(...skipping 21 matching lines...) Expand all Loading... |
62 config_ = ChooseEGLConfig(GetDisplay(), config_attribs); | 63 config_ = ChooseEGLConfig(GetDisplay(), config_attribs); |
63 } | 64 } |
64 return config_; | 65 return config_; |
65 } | 66 } |
66 | 67 |
67 GLSurfaceWayland::~GLSurfaceWayland() { | 68 GLSurfaceWayland::~GLSurfaceWayland() { |
68 Destroy(); | 69 Destroy(); |
69 } | 70 } |
70 | 71 |
71 } // namespace ui | 72 } // namespace ui |
OLD | NEW |