Chromium Code Reviews| 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" | |
|
sky
2011/07/27 15:51:05
sort
| |
| 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) { | |
|
sky
2011/07/27 15:51:05
member initialize all non-object fields (meaning i
| |
| 17 ui::WaylandDisplay* dpy = ui::WaylandDisplay::GetDisplay( | |
| 18 gfx::GLSurfaceEGL::GetNativeDisplay()); | |
| 19 EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); | |
| 20 | |
| 21 pixmap_ = wl_egl_pixmap_create(size_.width(), | |
| 22 size_.height(), | |
| 23 dpy->visual(), | |
| 24 0); | |
| 25 | |
| 26 image_ = eglCreateImageKHR( | |
| 27 edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (void*) pixmap_, NULL); | |
| 28 | |
| 29 glGenTextures(1, &texture_); | |
| 30 | |
| 31 GLint current_texture = 0; | |
| 32 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); | |
| 33 | |
| 34 glBindTexture(GL_TEXTURE_2D, texture_); | |
| 35 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
| 36 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
| 37 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 38 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 39 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_); | |
| 40 | |
| 41 glBindTexture(GL_TEXTURE_2D, current_texture); | |
| 42 } | |
| 43 | |
| 44 AcceleratedSurface::~AcceleratedSurface() { | |
| 45 glDeleteTextures(1, &texture_); | |
| 46 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); | |
| 47 wl_egl_pixmap_destroy(pixmap_); | |
| 48 } | |
| OLD | NEW |