Chromium Code Reviews| 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() { |
| 17 Destroy(false); | |
|
reveman
2014/05/29 16:30:34
No call to Destroy in dtor please. Instead verify
| |
| 18 } | |
| 17 | 19 |
| 18 bool GLImageSurfaceTexture::Initialize(gfx::GpuMemoryBufferHandle buffer) { | 20 bool GLImageSurfaceTexture::Initialize(gfx::GpuMemoryBufferHandle buffer) { |
| 19 DCHECK(!surface_texture_); | 21 DCHECK(!surface_texture_); |
| 20 surface_texture_ = | 22 surface_texture_ = |
| 21 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( | 23 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( |
| 22 buffer.surface_texture_id.primary_id, | 24 buffer.surface_texture_id.primary_id, |
| 23 buffer.surface_texture_id.secondary_id); | 25 buffer.surface_texture_id.secondary_id); |
| 24 return !!surface_texture_; | 26 return !!surface_texture_; |
| 25 } | 27 } |
| 26 | 28 |
| 27 void GLImageSurfaceTexture::Destroy() { | 29 void GLImageSurfaceTexture::Destroy(bool have_context) { |
| 28 surface_texture_ = NULL; | 30 surface_texture_ = NULL; |
| 29 texture_id_ = 0; | 31 texture_id_ = 0; |
| 30 } | 32 } |
| 31 | 33 |
| 32 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } | 34 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } |
| 33 | 35 |
| 34 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { | 36 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { |
| 35 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); | 37 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); |
| 36 | 38 |
| 37 if (target != GL_TEXTURE_EXTERNAL_OES) { | 39 if (target != GL_TEXTURE_EXTERNAL_OES) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 66 // GL_TEXTURE_EXTERNAL_OES target. | 68 // GL_TEXTURE_EXTERNAL_OES target. |
| 67 surface_texture_->AttachToGLContext(); | 69 surface_texture_->AttachToGLContext(); |
| 68 texture_id_ = texture_id; | 70 texture_id_ = texture_id; |
| 69 } | 71 } |
| 70 | 72 |
| 71 surface_texture_->UpdateTexImage(); | 73 surface_texture_->UpdateTexImage(); |
| 72 return true; | 74 return true; |
| 73 } | 75 } |
| 74 | 76 |
| 75 } // namespace gfx | 77 } // namespace gfx |
| OLD | NEW |