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(const gfx::Size& size) | 13 GLImageSurfaceTexture::GLImageSurfaceTexture(const gfx::Size& size) |
14 : size_(size), texture_id_(0) { | 14 : size_(size), texture_id_(0) { |
15 } | 15 } |
16 | 16 |
17 GLImageSurfaceTexture::~GLImageSurfaceTexture() { Destroy(); } | 17 GLImageSurfaceTexture::~GLImageSurfaceTexture() { |
| 18 DCHECK(!surface_texture_); |
| 19 DCHECK_EQ(0, texture_id_); |
| 20 } |
18 | 21 |
19 bool GLImageSurfaceTexture::Initialize( | 22 bool GLImageSurfaceTexture::Initialize( |
20 const gfx::GpuMemoryBufferHandle& handle) { | 23 const gfx::GpuMemoryBufferHandle& handle) { |
21 DCHECK(!surface_texture_); | 24 DCHECK(!surface_texture_); |
22 surface_texture_ = | 25 surface_texture_ = |
23 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( | 26 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( |
24 handle.surface_texture_id.primary_id, | 27 handle.surface_texture_id.primary_id, |
25 handle.surface_texture_id.secondary_id); | 28 handle.surface_texture_id.secondary_id); |
26 return !!surface_texture_; | 29 return !!surface_texture_; |
27 } | 30 } |
28 | 31 |
29 void GLImageSurfaceTexture::Destroy() { | 32 void GLImageSurfaceTexture::Destroy(bool have_context) { |
30 surface_texture_ = NULL; | 33 surface_texture_ = NULL; |
31 texture_id_ = 0; | 34 texture_id_ = 0; |
32 } | 35 } |
33 | 36 |
34 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } | 37 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } |
35 | 38 |
36 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { | 39 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { |
37 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); | 40 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); |
38 | 41 |
39 if (target != GL_TEXTURE_EXTERNAL_OES) { | 42 if (target != GL_TEXTURE_EXTERNAL_OES) { |
(...skipping 28 matching lines...) Expand all Loading... |
68 // GL_TEXTURE_EXTERNAL_OES target. | 71 // GL_TEXTURE_EXTERNAL_OES target. |
69 surface_texture_->AttachToGLContext(); | 72 surface_texture_->AttachToGLContext(); |
70 texture_id_ = texture_id; | 73 texture_id_ = texture_id; |
71 } | 74 } |
72 | 75 |
73 surface_texture_->UpdateTexImage(); | 76 surface_texture_->UpdateTexImage(); |
74 return true; | 77 return true; |
75 } | 78 } |
76 | 79 |
77 } // namespace gfx | 80 } // namespace gfx |
OLD | NEW |