OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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/gfx/surface/accelerated_surface_wayland.h" |
| 6 |
| 7 #include <EGL/egl.h> |
| 8 #include <EGL/eglext.h> |
| 9 #include <wayland-egl.h> |
| 10 |
| 11 #include "ui/gfx/gl/gl_surface_egl.h" |
| 12 #include "ui/gfx/gl/gl_bindings.h" |
| 13 #include "ui/wayland/wayland_display.h" |
| 14 |
| 15 AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) |
| 16 : size_(size) { |
| 17 WaylandDisplay* dpy = WaylandDisplay::GetDisplay( |
| 18 gfx::GLSurfaceEGL::GetNativeDisplay()); |
| 19 EGLDisplay edpy = gfx::GLSurfaceEGL::GetDisplay(); |
| 20 |
| 21 pixmap_ = wl_egl_pixmap_create(size_.width(), size_.height(), |
| 22 dpy->GetVisual(), 0); |
| 23 |
| 24 image_ = eglCreateImageKHR( |
| 25 edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (void*) pixmap_, NULL); |
| 26 |
| 27 glGenTextures(1, &texture_); |
| 28 |
| 29 GLint current_texture = 0; |
| 30 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); |
| 31 |
| 32 glBindTexture(GL_TEXTURE_2D, texture_); |
| 33 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 34 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 35 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 36 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 37 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_); |
| 38 |
| 39 glBindTexture(GL_TEXTURE_2D, current_texture); |
| 40 } |
| 41 |
| 42 AcceleratedSurface::~AcceleratedSurface() { |
| 43 glDeleteTextures(1, &texture_); |
| 44 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetDisplay(), image_); |
| 45 wl_egl_pixmap_destroy(pixmap_); |
| 46 } |
OLD | NEW |