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

Unified Diff: ui/ozone/platform/wayland/gl_surface_wayland.cc

Issue 2187443003: Convert Ozone wayland to directly create GLSurfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/wayland/gl_surface_wayland.h ('k') | ui/ozone/platform/wayland/wayland.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/wayland/gl_surface_wayland.cc
diff --git a/ui/ozone/platform/wayland/gl_surface_wayland.cc b/ui/ozone/platform/wayland/gl_surface_wayland.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a828ac509c488833f90a5c813887d01c67236627
--- /dev/null
+++ b/ui/ozone/platform/wayland/gl_surface_wayland.cc
@@ -0,0 +1,71 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/wayland/gl_surface_wayland.h"
+
+#include <wayland-egl.h>
+
+#include <utility>
+
+#include "third_party/khronos/EGL/egl.h"
+#include "ui/ozone/common/egl_util.h"
+#include "ui/ozone/platform/wayland/wayland_window.h"
+
+namespace ui {
+
+void EGLWindowDeleter::operator()(wl_egl_window* egl_window) {
+ wl_egl_window_destroy(egl_window);
+}
+
+std::unique_ptr<wl_egl_window, EGLWindowDeleter> CreateWaylandEglWindow(
+ WaylandWindow* window) {
+ gfx::Size size = window->GetBounds().size();
+ return std::unique_ptr<wl_egl_window, EGLWindowDeleter>(
+ wl_egl_window_create(window->surface(), size.width(), size.height()));
+}
+
+GLSurfaceWayland::GLSurfaceWayland(WaylandEglWindowPtr egl_window)
+ : NativeViewGLSurfaceEGL(
+ reinterpret_cast<EGLNativeWindowType>(egl_window.get())),
+ egl_window_(std::move(egl_window)) {
+ DCHECK(egl_window_);
+}
+
+bool GLSurfaceWayland::Resize(const gfx::Size& size,
+ float scale_factor,
+ bool has_alpha) {
+ if (size_ == size)
+ return true;
+ wl_egl_window_resize(egl_window_.get(), size.width(), size.height(), 0, 0);
+ size_ = size;
+ return true;
+}
+
+EGLConfig GLSurfaceWayland::GetConfig() {
+ if (!config_) {
+ GLint config_attribs[] = {EGL_BUFFER_SIZE,
+ 32,
+ EGL_ALPHA_SIZE,
+ 8,
+ EGL_BLUE_SIZE,
+ 8,
+ EGL_GREEN_SIZE,
+ 8,
+ EGL_RED_SIZE,
+ 8,
+ EGL_RENDERABLE_TYPE,
+ EGL_OPENGL_ES2_BIT,
+ EGL_SURFACE_TYPE,
+ EGL_WINDOW_BIT,
+ EGL_NONE};
+ config_ = ChooseEGLConfig(GetDisplay(), config_attribs);
+ }
+ return config_;
+}
+
+GLSurfaceWayland::~GLSurfaceWayland() {
+ Destroy();
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/wayland/gl_surface_wayland.h ('k') | ui/ozone/platform/wayland/wayland.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698