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 "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/common/android/surface_texture_lookup.h" | 9 #include "content/common/android/surface_texture_lookup.h" |
10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( | 14 GpuMemoryBufferImplSurfaceTexture::GpuMemoryBufferImplSurfaceTexture( |
15 const gfx::Size& size, | 15 const gfx::Size& size, |
16 unsigned internalformat) | 16 unsigned internalformat, |
17 : GpuMemoryBufferImpl(size, internalformat), | 17 const DestructionCallback& callback) |
| 18 : GpuMemoryBufferImpl(size, internalformat), callback_(callback) { |
18 native_window_(NULL), | 19 native_window_(NULL), |
19 stride_(0u) {} | 20 stride_(0u) {} |
20 | 21 |
21 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() { | 22 GpuMemoryBufferImplSurfaceTexture::~GpuMemoryBufferImplSurfaceTexture() { |
22 if (native_window_) | 23 if (!native_window_) |
23 ANativeWindow_release(native_window_); | 24 return; |
| 25 |
| 26 ANativeWindow_release(native_window_); |
| 27 callback_.Run(); |
24 } | 28 } |
25 | 29 |
26 // static | 30 // static |
27 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported( | 31 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported( |
28 unsigned internalformat) { | 32 unsigned internalformat) { |
29 switch (internalformat) { | 33 switch (internalformat) { |
30 case GL_RGBA8_OES: | 34 case GL_RGBA8_OES: |
31 return true; | 35 return true; |
32 default: | 36 default: |
33 return false; | 37 return false; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 118 |
115 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 119 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
116 const { | 120 const { |
117 gfx::GpuMemoryBufferHandle handle; | 121 gfx::GpuMemoryBufferHandle handle; |
118 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 122 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
119 handle.surface_texture_id = surface_texture_id_; | 123 handle.surface_texture_id = surface_texture_id_; |
120 return handle; | 124 return handle; |
121 } | 125 } |
122 | 126 |
123 } // namespace content | 127 } // namespace content |
OLD | NEW |