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/wayland_egl_surface.h" |
| 6 |
| 7 #include <wayland-egl.h> |
| 8 |
| 9 #include "third_party/khronos/EGL/egl.h" |
| 10 #include "ui/ozone/common/egl_util.h" |
| 11 #include "ui/ozone/platform/wayland/wayland_window.h" |
| 12 |
| 13 namespace ui { |
| 14 |
| 15 void EGLWindowDeleter::operator()(wl_egl_window* egl_window) { |
| 16 wl_egl_window_destroy(egl_window); |
| 17 } |
| 18 |
| 19 WaylandEGLSurface::WaylandEGLSurface(WaylandWindow* window, |
| 20 const gfx::Size& size) |
| 21 : window_(window), size_(size) {} |
| 22 |
| 23 WaylandEGLSurface::~WaylandEGLSurface() {} |
| 24 |
| 25 bool WaylandEGLSurface::Initialize() { |
| 26 egl_window_.reset(wl_egl_window_create(window_->GetSurface(), size_.width(), |
| 27 size_.height())); |
| 28 return egl_window_; |
| 29 } |
| 30 |
| 31 intptr_t WaylandEGLSurface::GetNativeWindow() { |
| 32 DCHECK(egl_window_); |
| 33 return reinterpret_cast<intptr_t>(egl_window_.get()); |
| 34 } |
| 35 |
| 36 bool WaylandEGLSurface::ResizeNativeWindow(const gfx::Size& viewport_size) { |
| 37 if (size_ == viewport_size) |
| 38 return true; |
| 39 DCHECK(egl_window_); |
| 40 wl_egl_window_resize(egl_window_.get(), size_.width(), size_.height(), 0, 0); |
| 41 size_ = viewport_size; |
| 42 return true; |
| 43 } |
| 44 |
| 45 bool WaylandEGLSurface::OnSwapBuffers() { |
| 46 return true; |
| 47 } |
| 48 |
| 49 void WaylandEGLSurface::OnSwapBuffersAsync( |
| 50 const SwapCompletionCallback& callback) { |
| 51 NOTREACHED(); |
| 52 } |
| 53 |
| 54 scoped_ptr<gfx::VSyncProvider> WaylandEGLSurface::CreateVSyncProvider() { |
| 55 NOTIMPLEMENTED(); |
| 56 return nullptr; |
| 57 } |
| 58 |
| 59 void* /* EGLConfig */ WaylandEGLSurface::GetEGLSurfaceConfig( |
| 60 const EglConfigCallbacks& egl) { |
| 61 EGLint config_attribs[] = {EGL_BUFFER_SIZE, |
| 62 32, |
| 63 EGL_ALPHA_SIZE, |
| 64 8, |
| 65 EGL_BLUE_SIZE, |
| 66 8, |
| 67 EGL_GREEN_SIZE, |
| 68 8, |
| 69 EGL_RED_SIZE, |
| 70 8, |
| 71 EGL_RENDERABLE_TYPE, |
| 72 EGL_OPENGL_ES2_BIT, |
| 73 EGL_SURFACE_TYPE, |
| 74 EGL_WINDOW_BIT, |
| 75 EGL_NONE}; |
| 76 return ChooseEGLConfig(egl, config_attribs); |
| 77 } |
| 78 |
| 79 } // namespace ui |
OLD | NEW |