diff options
author | dnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-10 16:50:44 +0000 |
---|---|---|
committer | dnicoara@chromium.org <dnicoara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-10 16:50:44 +0000 |
commit | f1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b (patch) | |
tree | 0e711e1f5d167a35844627206d709485a730b804 /ui/gfx/surface | |
parent | 11edb87b32bc384c4df1ff342a38647c076a722f (diff) | |
download | chromium_src-f1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b.zip chromium_src-f1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b.tar.gz chromium_src-f1b2cd0ebbdbcd4765f3d8a83ddeaccaa74c715b.tar.bz2 |
Adding Wayland support for ui/gfx
* Added GL surface and context support for Wayland.
* Updated ui/gfx files to allow Wayland support
* All Wayland code is behind the use_wayland gyp flag
This CL depends on http://codereview.chromium.org/7457023
BUG=
TEST=Compiled Chrome with use_wayland disabled to verify that
the changes didn't break anything
Review URL: http://codereview.chromium.org/7467007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/surface')
-rw-r--r-- | ui/gfx/surface/accelerated_surface_wayland.cc | 51 | ||||
-rw-r--r-- | ui/gfx/surface/accelerated_surface_wayland.h | 37 | ||||
-rw-r--r-- | ui/gfx/surface/surface.gyp | 12 |
3 files changed, 99 insertions, 1 deletions
diff --git a/ui/gfx/surface/accelerated_surface_wayland.cc b/ui/gfx/surface/accelerated_surface_wayland.cc new file mode 100644 index 0000000..29d0e7d --- /dev/null +++ b/ui/gfx/surface/accelerated_surface_wayland.cc @@ -0,0 +1,51 @@ +// Copyright (c) 2011 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/gfx/surface/accelerated_surface_wayland.h" + +#include <wayland-egl.h> + +#include "third_party/angle/include/EGL/egl.h" +#include "third_party/angle/include/EGL/eglext.h" +#include "ui/gfx/gl/gl_bindings.h" +#include "ui/gfx/gl/gl_surface_egl.h" +#include "ui/wayland/wayland_display.h" + +AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) + : size_(size), + image_(NULL), + pixmap_(NULL), + texture_(0) { + ui::WaylandDisplay* dpy = ui::WaylandDisplay::GetDisplay( + gfx::GLSurfaceEGL::GetNativeDisplay()); + EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); + + pixmap_ = wl_egl_pixmap_create(size_.width(), + size_.height(), + dpy->visual(), + 0); + + image_ = eglCreateImageKHR( + edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (void*) pixmap_, NULL); + + glGenTextures(1, &texture_); + + GLint current_texture = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); + + glBindTexture(GL_TEXTURE_2D, texture_); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_); + + glBindTexture(GL_TEXTURE_2D, current_texture); +} + +AcceleratedSurface::~AcceleratedSurface() { + glDeleteTextures(1, &texture_); + eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); + wl_egl_pixmap_destroy(pixmap_); +} diff --git a/ui/gfx/surface/accelerated_surface_wayland.h b/ui/gfx/surface/accelerated_surface_wayland.h new file mode 100644 index 0000000..c4418e4 --- /dev/null +++ b/ui/gfx/surface/accelerated_surface_wayland.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 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. + +#ifndef UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_ +#define UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_ +#pragma once + +#include "base/memory/ref_counted.h" +#include "ui/gfx/size.h" + +struct wl_egl_pixmap; + +// The GL context associated with the surface must be current when +// an instance is created or destroyed. +class AcceleratedSurface : public base::RefCounted<AcceleratedSurface> { + public: + AcceleratedSurface(const gfx::Size& size); + const gfx::Size& size() const { return size_; } + // The pointer returned is owned by this object + wl_egl_pixmap* pixmap() const { return pixmap_; } + uint32 texture() const { return texture_; } + + private: + friend class base::RefCounted<AcceleratedSurface>; + + ~AcceleratedSurface(); + + gfx::Size size_; + void* image_; + wl_egl_pixmap* pixmap_; + uint32 texture_; + + DISALLOW_COPY_AND_ASSIGN(AcceleratedSurface); +}; + +#endif // UI_GFX_SURFACE_ACCELERATED_SURFACE_LINUX_H_ diff --git a/ui/gfx/surface/surface.gyp b/ui/gfx/surface/surface.gyp index 17f372c..9e7081d 100644 --- a/ui/gfx/surface/surface.gyp +++ b/ui/gfx/surface/surface.gyp @@ -9,7 +9,7 @@ 'target_defaults': { 'conditions': [ - ['toolkit_uses_gtk == 1', { + ['toolkit_uses_gtk == 1 or use_wayland == 1', { 'include_dirs': [ '<(DEPTH)/third_party/angle/include', ], @@ -31,6 +31,8 @@ 'accelerated_surface_linux.h', 'accelerated_surface_mac.cc', 'accelerated_surface_mac.h', + 'accelerated_surface_wayland.cc', + 'accelerated_surface_wayland.h', 'io_surface_support_mac.cc', 'io_surface_support_mac.h', 'transport_dib.h', @@ -38,6 +40,14 @@ 'transport_dib_mac.cc', 'transport_dib_win.cc', ], + 'conditions': [ + ['use_wayland == 1', { + 'sources/': [ + ['exclude', 'accelerated_surface_linux.cc'], + ['exclude', 'accelerated_surface_linux.h'], + ], + }], + ], }, ], } |