OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/ozone/platform/wayland/gl_surface_wayland.h" |
| 6 |
| 7 #include <wayland-egl.h> |
| 8 |
| 9 #include <utility> |
| 10 |
| 11 #include "third_party/khronos/EGL/egl.h" |
| 12 #include "ui/ozone/common/egl_util.h" |
| 13 #include "ui/ozone/platform/wayland/wayland_window.h" |
| 14 |
| 15 namespace ui { |
| 16 |
| 17 void EGLWindowDeleter::operator()(wl_egl_window* egl_window) { |
| 18 wl_egl_window_destroy(egl_window); |
| 19 } |
| 20 |
| 21 std::unique_ptr<wl_egl_window, EGLWindowDeleter> CreateWaylandEglWindow( |
| 22 WaylandWindow* window) { |
| 23 gfx::Size size = window->GetBounds().size(); |
| 24 return std::unique_ptr<wl_egl_window, EGLWindowDeleter>( |
| 25 wl_egl_window_create(window->surface(), size.width(), size.height())); |
| 26 } |
| 27 |
| 28 GLSurfaceWayland::GLSurfaceWayland(WaylandEglWindowPtr egl_window) |
| 29 : NativeViewGLSurfaceEGL( |
| 30 reinterpret_cast<EGLNativeWindowType>(egl_window.get())), |
| 31 egl_window_(std::move(egl_window)) { |
| 32 DCHECK(egl_window_); |
| 33 } |
| 34 |
| 35 bool GLSurfaceWayland::Resize(const gfx::Size& size, |
| 36 float scale_factor, |
| 37 bool has_alpha) { |
| 38 if (size_ == size) |
| 39 return true; |
| 40 wl_egl_window_resize(egl_window_.get(), size.width(), size.height(), 0, 0); |
| 41 size_ = size; |
| 42 return true; |
| 43 } |
| 44 |
| 45 EGLConfig GLSurfaceWayland::GetConfig() { |
| 46 if (!config_) { |
| 47 GLint config_attribs[] = {EGL_BUFFER_SIZE, |
| 48 32, |
| 49 EGL_ALPHA_SIZE, |
| 50 8, |
| 51 EGL_BLUE_SIZE, |
| 52 8, |
| 53 EGL_GREEN_SIZE, |
| 54 8, |
| 55 EGL_RED_SIZE, |
| 56 8, |
| 57 EGL_RENDERABLE_TYPE, |
| 58 EGL_OPENGL_ES2_BIT, |
| 59 EGL_SURFACE_TYPE, |
| 60 EGL_WINDOW_BIT, |
| 61 EGL_NONE}; |
| 62 config_ = ChooseEGLConfig(GetDisplay(), config_attribs); |
| 63 } |
| 64 return config_; |
| 65 } |
| 66 |
| 67 GLSurfaceWayland::~GLSurfaceWayland() { |
| 68 Destroy(); |
| 69 } |
| 70 |
| 71 } // namespace ui |
OLD | NEW |