| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gl/gl_image_surface_texture.h" | 5 #include "ui/gl/gl_image_surface_texture.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "ui/gl/android/surface_texture.h" | 8 #include "ui/gl/android/surface_texture.h" |
| 9 #include "ui/gl/android/surface_texture_tracker.h" | 9 #include "ui/gl/android/surface_texture_tracker.h" |
| 10 | 10 |
| 11 namespace gfx { | 11 namespace gfx { |
| 12 | 12 |
| 13 GLImageSurfaceTexture::GLImageSurfaceTexture(gfx::Size size) | 13 GLImageSurfaceTexture::GLImageSurfaceTexture(gfx::Size size) |
| 14 : size_(size), texture_id_(0) {} | 14 : size_(size), texture_id_(0) {} |
| 15 | 15 |
| 16 GLImageSurfaceTexture::~GLImageSurfaceTexture() { Destroy(); } | 16 GLImageSurfaceTexture::~GLImageSurfaceTexture() { Destroy(); } |
| 17 | 17 |
| 18 bool GLImageSurfaceTexture::Initialize(gfx::GpuMemoryBufferHandle buffer) { | 18 bool GLImageSurfaceTexture::Initialize(gfx::GpuMemoryBufferHandle buffer) { |
| 19 DCHECK(!surface_texture_); | 19 DCHECK(!surface_texture_); |
| 20 surface_texture_ = | 20 surface_texture_ = |
| 21 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( | 21 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( |
| 22 buffer.surface_texture_id.primary_id, | 22 buffer.gpu_memory_id.primary_id, buffer.gpu_memory_id.secondary_id); |
| 23 buffer.surface_texture_id.secondary_id); | |
| 24 return !!surface_texture_; | 23 return !!surface_texture_; |
| 25 } | 24 } |
| 26 | 25 |
| 27 void GLImageSurfaceTexture::Destroy() { | 26 void GLImageSurfaceTexture::Destroy() { |
| 28 surface_texture_ = NULL; | 27 surface_texture_ = NULL; |
| 29 texture_id_ = 0; | 28 texture_id_ = 0; |
| 30 } | 29 } |
| 31 | 30 |
| 32 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } | 31 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } |
| 33 | 32 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // GL_TEXTURE_EXTERNAL_OES target. | 65 // GL_TEXTURE_EXTERNAL_OES target. |
| 67 surface_texture_->AttachToGLContext(); | 66 surface_texture_->AttachToGLContext(); |
| 68 texture_id_ = texture_id; | 67 texture_id_ = texture_id; |
| 69 } | 68 } |
| 70 | 69 |
| 71 surface_texture_->UpdateTexImage(); | 70 surface_texture_->UpdateTexImage(); |
| 72 return true; | 71 return true; |
| 73 } | 72 } |
| 74 | 73 |
| 75 } // namespace gfx | 74 } // namespace gfx |
| OLD | NEW |