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/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "content/common/android/surface_texture_manager.h" | 11 #include "content/common/android/surface_texture_manager.h" |
12 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" | 12 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" |
13 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 namespace { | 16 namespace { |
17 | 17 |
18 base::StaticAtomicSequenceNumber g_next_buffer_id; | 18 base::StaticAtomicSequenceNumber g_next_buffer_id; |
19 | 19 |
20 void Noop() { | 20 void GpuMemoryBufferDeleted(const gfx::GpuMemoryBufferHandle& handle, |
21 uint32 sync_point) { | |
22 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, | |
23 sync_point); | |
21 } | 24 } |
22 | 25 |
23 void GpuMemoryBufferCreated( | 26 void GpuMemoryBufferCreated( |
24 const gfx::Size& size, | 27 const gfx::Size& size, |
25 gfx::GpuMemoryBuffer::Format format, | 28 gfx::GpuMemoryBuffer::Format format, |
26 const GpuMemoryBufferImpl::CreationCallback& callback, | 29 const GpuMemoryBufferImpl::CreationCallback& callback, |
27 const gfx::GpuMemoryBufferHandle& handle) { | 30 const gfx::GpuMemoryBufferHandle& handle) { |
28 DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); | 31 DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); |
29 | 32 |
30 callback.Run(GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( | 33 callback.Run(GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
31 handle, size, format, base::Bind(&Noop))); | 34 handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); |
32 } | 35 } |
33 | 36 |
34 void GpuMemoryBufferCreatedForChildProcess( | 37 void GpuMemoryBufferCreatedForChildProcess( |
35 const GpuMemoryBufferImpl::AllocationCallback& callback, | 38 const GpuMemoryBufferImpl::AllocationCallback& callback, |
36 const gfx::GpuMemoryBufferHandle& handle) { | 39 const gfx::GpuMemoryBufferHandle& handle) { |
37 DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); | 40 DCHECK_EQ(gfx::SURFACE_TEXTURE_BUFFER, handle.type); |
38 | 41 |
39 callback.Run(handle); | 42 callback.Run(handle); |
40 } | 43 } |
41 | 44 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 | 113 |
111 ANativeWindow_setBuffersGeometry( | 114 ANativeWindow_setBuffersGeometry( |
112 native_window, size.width(), size.height(), WindowFormat(format)); | 115 native_window, size.width(), size.height(), WindowFormat(format)); |
113 | 116 |
114 return make_scoped_ptr<GpuMemoryBufferImpl>( | 117 return make_scoped_ptr<GpuMemoryBufferImpl>( |
115 new GpuMemoryBufferImplSurfaceTexture( | 118 new GpuMemoryBufferImplSurfaceTexture( |
116 size, format, callback, handle.global_id, native_window)); | 119 size, format, callback, handle.global_id, native_window)); |
117 } | 120 } |
118 | 121 |
119 // static | 122 // static |
123 void GpuMemoryBufferImplSurfaceTexture::DeletedByChildProcess( | |
124 const gfx::GpuMemoryBufferId& id, | |
125 uint32_t sync_point) { | |
126 gfx::GpuMemoryBufferHandle handle; | |
127 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | |
128 handle.global_id = id; | |
129 | |
reveman
2014/11/04 00:16:13
nit: make blank line usage consistent with Create/
| |
130 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, | |
131 sync_point); | |
132 } | |
133 | |
134 // static | |
120 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported(Format format) { | 135 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported(Format format) { |
121 switch (format) { | 136 switch (format) { |
122 case RGBA_8888: | 137 case RGBA_8888: |
123 return true; | 138 return true; |
124 case RGBX_8888: | 139 case RGBX_8888: |
125 case BGRA_8888: | 140 case BGRA_8888: |
126 return false; | 141 return false; |
127 } | 142 } |
128 | 143 |
129 NOTREACHED(); | 144 NOTREACHED(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 211 |
197 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 212 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
198 const { | 213 const { |
199 gfx::GpuMemoryBufferHandle handle; | 214 gfx::GpuMemoryBufferHandle handle; |
200 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 215 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
201 handle.global_id = id_; | 216 handle.global_id = id_; |
202 return handle; | 217 return handle; |
203 } | 218 } |
204 | 219 |
205 } // namespace content | 220 } // namespace content |
OLD | NEW |