| 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 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, |
| 130 sync_point); |
| 131 } |
| 132 |
| 133 // static |
| 120 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported(Format format) { | 134 bool GpuMemoryBufferImplSurfaceTexture::IsFormatSupported(Format format) { |
| 121 switch (format) { | 135 switch (format) { |
| 122 case RGBA_8888: | 136 case RGBA_8888: |
| 123 return true; | 137 return true; |
| 124 case RGBX_8888: | 138 case RGBX_8888: |
| 125 case BGRA_8888: | 139 case BGRA_8888: |
| 126 return false; | 140 return false; |
| 127 } | 141 } |
| 128 | 142 |
| 129 NOTREACHED(); | 143 NOTREACHED(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 210 |
| 197 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() | 211 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() |
| 198 const { | 212 const { |
| 199 gfx::GpuMemoryBufferHandle handle; | 213 gfx::GpuMemoryBufferHandle handle; |
| 200 handle.type = gfx::SURFACE_TEXTURE_BUFFER; | 214 handle.type = gfx::SURFACE_TEXTURE_BUFFER; |
| 201 handle.global_id = id_; | 215 handle.global_id = id_; |
| 202 return handle; | 216 return handle; |
| 203 } | 217 } |
| 204 | 218 |
| 205 } // namespace content | 219 } // namespace content |
| OLD | NEW |