Chromium Code Reviews| Index: ui/gfx/surface/accelerated_surface_wayland.cc |
| diff --git a/ui/gfx/surface/accelerated_surface_wayland.cc b/ui/gfx/surface/accelerated_surface_wayland.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..45748fc84ec0791640464890777bfd9026c143a1 |
| --- /dev/null |
| +++ b/ui/gfx/surface/accelerated_surface_wayland.cc |
| @@ -0,0 +1,48 @@ |
| +// 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 <EGL/egl.h> |
| +#include <EGL/eglext.h> |
| +#include <wayland-egl.h> |
| + |
| +#include "ui/gfx/gl/gl_surface_egl.h" |
|
sky
2011/07/27 15:51:05
sort
|
| +#include "ui/gfx/gl/gl_bindings.h" |
| +#include "ui/wayland/wayland_display.h" |
| + |
| +AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) |
| + : size_(size) { |
|
sky
2011/07/27 15:51:05
member initialize all non-object fields (meaning i
|
| + 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_); |
| +} |