OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/surface/accelerated_surface_linux.h" | 5 #include "ui/gfx/surface/accelerated_surface_linux.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 | 8 |
9 #include "third_party/angle/include/EGL/egl.h" | 9 #include "third_party/angle/include/EGL/egl.h" |
10 #include "third_party/angle/include/EGL/eglext.h" | 10 #include "third_party/angle/include/EGL/eglext.h" |
11 #include "ui/gfx/gl/gl_surface_egl.h" | 11 #include "ui/gfx/gl/gl_surface_egl.h" |
12 #include "ui/gfx/gl/gl_bindings.h" | 12 #include "ui/gfx/gl/gl_bindings.h" |
13 | 13 |
14 AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) | 14 AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) |
15 : size_(size) { | 15 : size_(size) { |
16 Display* dpy = gfx::GLSurfaceEGL::GetNativeDisplay(); | 16 Display* dpy = gfx::GLSurfaceEGL::GetNativeDisplay(); |
17 EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); | 17 EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); |
18 | 18 |
19 XID window = XDefaultRootWindow(dpy); | 19 XID window = XDefaultRootWindow(dpy); |
20 XWindowAttributes gwa; | 20 XWindowAttributes gwa; |
21 XGetWindowAttributes(dpy, window, &gwa); | 21 XGetWindowAttributes(dpy, window, &gwa); |
22 pixmap_ = XCreatePixmap( | 22 pixmap_ = XCreatePixmap( |
23 dpy, window, size_.width(), size_.height(), gwa.depth); | 23 dpy, window, size_.width(), size_.height(), gwa.depth); |
24 | 24 |
25 image_ = eglCreateImageKHR( | 25 image_ = eglCreateImageKHR( |
26 edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (void*) pixmap_, NULL); | 26 edpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, |
| 27 reinterpret_cast<void*>(pixmap_), NULL); |
27 | 28 |
28 glGenTextures(1, &texture_); | 29 glGenTextures(1, &texture_); |
29 | 30 |
30 GLint current_texture = 0; | 31 GLint current_texture = 0; |
31 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); | 32 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); |
32 | 33 |
33 glBindTexture(GL_TEXTURE_2D, texture_); | 34 glBindTexture(GL_TEXTURE_2D, texture_); |
34 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 35 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
35 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 36 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
36 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 37 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
37 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 38 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
38 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_); | 39 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image_); |
39 | 40 |
40 glBindTexture(GL_TEXTURE_2D, current_texture); | 41 glBindTexture(GL_TEXTURE_2D, current_texture); |
41 } | 42 } |
42 | 43 |
43 AcceleratedSurface::~AcceleratedSurface() { | 44 AcceleratedSurface::~AcceleratedSurface() { |
44 glDeleteTextures(1, &texture_); | 45 glDeleteTextures(1, &texture_); |
45 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); | 46 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); |
46 XFreePixmap(gfx::GLSurfaceEGL::GetNativeDisplay(), pixmap_); | 47 XFreePixmap(gfx::GLSurfaceEGL::GetNativeDisplay(), pixmap_); |
47 } | 48 } |
OLD | NEW |