| 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 "chrome/browser/renderer_host/accelerated_surface_container_touch.h" | 5 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/extensions/Xcomposite.h> | 8 #include <X11/extensions/Xcomposite.h> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "third_party/angle/include/EGL/egl.h" | 11 #include "third_party/angle/include/EGL/egl.h" |
| 12 #include "third_party/angle/include/EGL/eglext.h" | 12 #include "third_party/angle/include/EGL/eglext.h" |
| 13 #include "ui/gfx/gl/gl_bindings.h" | 13 #include "ui/gfx/gl/gl_bindings.h" |
| 14 #include "ui/gfx/gl/gl_implementation.h" | 14 #include "ui/gfx/gl/gl_implementation.h" |
| 15 #include "ui/gfx/gl/gl_surface_egl.h" | 15 #include "ui/gfx/gl/gl_surface_egl.h" |
| 16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 17 #include "ui/gfx/gl/gl_surface_glx.h" | 17 #include "ui/gfx/gl/gl_surface_glx.h" |
| 18 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class AcceleratedSurfaceContainerTouchEGL | 22 class AcceleratedSurfaceContainerTouchEGL |
| 23 : public AcceleratedSurfaceContainerTouch { | 23 : public AcceleratedSurfaceContainerTouch { |
| 24 public: | 24 public: |
| 25 AcceleratedSurfaceContainerTouchEGL(ui::CompositorGL* compositor, | 25 AcceleratedSurfaceContainerTouchEGL(ui::CompositorGL* compositor, |
| 26 const gfx::Size& size, | 26 const gfx::Size& size, |
| 27 uint64 surface_handle); | 27 uint64 surface_handle); |
| 28 // TextureGL implementation | 28 // TextureGL implementation |
| 29 virtual void Draw(const ui::TextureDrawParams& params, | 29 virtual void Draw(const ui::TextureDrawParams& params, |
| 30 const gfx::Rect& clip_bounds) OVERRIDE; | 30 const gfx::Rect& clip_bounds_in_texture) OVERRIDE; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 ~AcceleratedSurfaceContainerTouchEGL(); | 33 ~AcceleratedSurfaceContainerTouchEGL(); |
| 34 | 34 |
| 35 void* image_; | 35 void* image_; |
| 36 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerTouchEGL); | 36 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerTouchEGL); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class AcceleratedSurfaceContainerTouchGLX | 39 class AcceleratedSurfaceContainerTouchGLX |
| 40 : public AcceleratedSurfaceContainerTouch { | 40 : public AcceleratedSurfaceContainerTouch { |
| 41 public: | 41 public: |
| 42 AcceleratedSurfaceContainerTouchGLX(ui::CompositorGL* compositor, | 42 AcceleratedSurfaceContainerTouchGLX(ui::CompositorGL* compositor, |
| 43 const gfx::Size& size, | 43 const gfx::Size& size, |
| 44 uint64 surface_handle); | 44 uint64 surface_handle); |
| 45 // TextureGL implementation | 45 // TextureGL implementation |
| 46 virtual void Draw(const ui::TextureDrawParams& params, | 46 virtual void Draw(const ui::TextureDrawParams& params, |
| 47 const gfx::Rect& clip_bounds) OVERRIDE; | 47 const gfx::Rect& clip_bounds_in_texture) OVERRIDE; |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 ~AcceleratedSurfaceContainerTouchGLX(); | 50 ~AcceleratedSurfaceContainerTouchGLX(); |
| 51 | 51 |
| 52 XID pixmap_; | 52 XID pixmap_; |
| 53 XID glx_pixmap_; | 53 XID glx_pixmap_; |
| 54 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerTouchGLX); | 54 DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerTouchGLX); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class ScopedPtrXFree { | 57 class ScopedPtrXFree { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 83 glFlush(); | 83 glFlush(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 AcceleratedSurfaceContainerTouchEGL::~AcceleratedSurfaceContainerTouchEGL() { | 86 AcceleratedSurfaceContainerTouchEGL::~AcceleratedSurfaceContainerTouchEGL() { |
| 87 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); | 87 eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); |
| 88 glFlush(); | 88 glFlush(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void AcceleratedSurfaceContainerTouchEGL::Draw( | 91 void AcceleratedSurfaceContainerTouchEGL::Draw( |
| 92 const ui::TextureDrawParams& params, | 92 const ui::TextureDrawParams& params, |
| 93 const gfx::Rect& clip_bounds) { | 93 const gfx::Rect& clip_bounds_in_texture) { |
| 94 DCHECK(compositor_->program_no_swizzle()); | 94 DCHECK(compositor_->program_no_swizzle()); |
| 95 | 95 |
| 96 ui::TextureDrawParams modified_params = params; | 96 ui::TextureDrawParams modified_params = params; |
| 97 | 97 |
| 98 // Texture from GPU is flipped vertically. | 98 // Texture from GPU is flipped vertically. |
| 99 ui::Transform flipped; | 99 ui::Transform flipped; |
| 100 flipped.SetScaleY(-1.0); | 100 flipped.SetScaleY(-1.0); |
| 101 flipped.SetTranslateY(size_.height()); | 101 flipped.SetTranslateY(size_.height()); |
| 102 flipped.ConcatTransform(params.transform); | 102 flipped.ConcatTransform(params.transform); |
| 103 | 103 |
| 104 modified_params.transform = flipped; | 104 modified_params.transform = flipped; |
| 105 | 105 |
| 106 DrawInternal(*compositor_->program_no_swizzle(), | 106 DrawInternal(*compositor_->program_no_swizzle(), |
| 107 modified_params, | 107 modified_params, |
| 108 clip_bounds); | 108 clip_bounds_in_texture); |
| 109 } | 109 } |
| 110 | 110 |
| 111 AcceleratedSurfaceContainerTouchGLX::AcceleratedSurfaceContainerTouchGLX( | 111 AcceleratedSurfaceContainerTouchGLX::AcceleratedSurfaceContainerTouchGLX( |
| 112 ui::CompositorGL* compositor, | 112 ui::CompositorGL* compositor, |
| 113 const gfx::Size& size, | 113 const gfx::Size& size, |
| 114 uint64 surface_handle) | 114 uint64 surface_handle) |
| 115 : AcceleratedSurfaceContainerTouch(compositor, size), | 115 : AcceleratedSurfaceContainerTouch(compositor, size), |
| 116 pixmap_(0), | 116 pixmap_(0), |
| 117 glx_pixmap_(0) { | 117 glx_pixmap_(0) { |
| 118 // Create pixmap from window. | 118 // Create pixmap from window. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 AcceleratedSurfaceContainerTouchGLX::~AcceleratedSurfaceContainerTouchGLX() { | 198 AcceleratedSurfaceContainerTouchGLX::~AcceleratedSurfaceContainerTouchGLX() { |
| 199 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); | 199 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); |
| 200 if (glx_pixmap_) | 200 if (glx_pixmap_) |
| 201 glXDestroyGLXPixmap(dpy, glx_pixmap_); | 201 glXDestroyGLXPixmap(dpy, glx_pixmap_); |
| 202 if (pixmap_) | 202 if (pixmap_) |
| 203 XFreePixmap(dpy, pixmap_); | 203 XFreePixmap(dpy, pixmap_); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void AcceleratedSurfaceContainerTouchGLX::Draw( | 206 void AcceleratedSurfaceContainerTouchGLX::Draw( |
| 207 const ui::TextureDrawParams& params, | 207 const ui::TextureDrawParams& params, |
| 208 const gfx::Rect& clip_bounds) { | 208 const gfx::Rect& clip_bounds_in_texture) { |
| 209 DCHECK(compositor_->program_no_swizzle()); | 209 DCHECK(compositor_->program_no_swizzle()); |
| 210 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); | 210 Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); |
| 211 | 211 |
| 212 glBindTexture(GL_TEXTURE_2D, texture_id_); | 212 glBindTexture(GL_TEXTURE_2D, texture_id_); |
| 213 glXBindTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL); | 213 glXBindTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL); |
| 214 DrawInternal(*compositor_->program_no_swizzle(), | 214 DrawInternal(*compositor_->program_no_swizzle(), |
| 215 params, | 215 params, |
| 216 clip_bounds); | 216 clip_bounds_in_texture); |
| 217 glXReleaseTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT); | 217 glXReleaseTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace | 220 } // namespace |
| 221 | 221 |
| 222 AcceleratedSurfaceContainerTouch::AcceleratedSurfaceContainerTouch( | 222 AcceleratedSurfaceContainerTouch::AcceleratedSurfaceContainerTouch( |
| 223 ui::CompositorGL* compositor, | 223 ui::CompositorGL* compositor, |
| 224 const gfx::Size& size) : | 224 const gfx::Size& size) : |
| 225 TextureGL(compositor, size) { | 225 TextureGL(compositor, size) { |
| 226 } | 226 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 245 return NULL; | 245 return NULL; |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 void AcceleratedSurfaceContainerTouch::SetCanvas( | 249 void AcceleratedSurfaceContainerTouch::SetCanvas( |
| 250 const SkCanvas& canvas, | 250 const SkCanvas& canvas, |
| 251 const gfx::Point& origin, | 251 const gfx::Point& origin, |
| 252 const gfx::Size& overall_size) { | 252 const gfx::Size& overall_size) { |
| 253 NOTREACHED(); | 253 NOTREACHED(); |
| 254 } | 254 } |
| OLD | NEW |