| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_io_surface.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" | 10 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" |
| 11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 base::StaticAtomicSequenceNumber g_next_buffer_id; | 16 base::StaticAtomicSequenceNumber g_next_buffer_id; |
| 17 | 17 |
| 18 void GpuMemoryBufferDeleted(const gfx::GpuMemoryBufferHandle& handle, | 18 void GpuMemoryBufferDeleted(const gfx::GpuMemoryBufferHandle& handle, |
| 19 uint32 sync_point) { | 19 uint32 sync_point) { |
| 20 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, | 20 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, |
| 21 sync_point); | 21 sync_point); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void GpuMemoryBufferCreated( | 24 void GpuMemoryBufferCreated( |
| 25 const gfx::Size& size, | 25 const gfx::Size& size, |
| 26 gfx::GpuMemoryBuffer::Format format, | 26 gfx::GpuMemoryBuffer::Format format, |
| 27 const GpuMemoryBufferImpl::CreationCallback& callback, | 27 const GpuMemoryBufferImpl::CreationCallback& callback, |
| 28 const gfx::GpuMemoryBufferHandle& handle) { | 28 const gfx::GpuMemoryBufferHandle& handle) { |
| 29 if (handle.is_null()) { |
| 30 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
| 31 return; |
| 32 } |
| 33 |
| 29 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); | 34 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); |
| 30 | |
| 31 callback.Run(GpuMemoryBufferImplIOSurface::CreateFromHandle( | 35 callback.Run(GpuMemoryBufferImplIOSurface::CreateFromHandle( |
| 32 handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); | 36 handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); |
| 33 } | 37 } |
| 34 | 38 |
| 35 void GpuMemoryBufferCreatedForChildProcess( | 39 void GpuMemoryBufferCreatedForChildProcess( |
| 36 const GpuMemoryBufferImpl::AllocationCallback& callback, | 40 const GpuMemoryBufferImpl::AllocationCallback& callback, |
| 37 const gfx::GpuMemoryBufferHandle& handle) { | 41 const gfx::GpuMemoryBufferHandle& handle) { |
| 38 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); | 42 DCHECK_IMPLIES(!handle.is_null(), gfx::IO_SURFACE_BUFFER == handle.type); |
| 39 | 43 |
| 40 callback.Run(handle); | 44 callback.Run(handle); |
| 41 } | 45 } |
| 42 | 46 |
| 43 } // namespace | 47 } // namespace |
| 44 | 48 |
| 45 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( | 49 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( |
| 46 const gfx::Size& size, | 50 const gfx::Size& size, |
| 47 Format format, | 51 Format format, |
| 48 const DestructionCallback& callback, | 52 const DestructionCallback& callback, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 185 } |
| 182 | 186 |
| 183 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 187 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
| 184 gfx::GpuMemoryBufferHandle handle; | 188 gfx::GpuMemoryBufferHandle handle; |
| 185 handle.type = gfx::IO_SURFACE_BUFFER; | 189 handle.type = gfx::IO_SURFACE_BUFFER; |
| 186 handle.io_surface_id = IOSurfaceGetID(io_surface_); | 190 handle.io_surface_id = IOSurfaceGetID(io_surface_); |
| 187 return handle; | 191 return handle; |
| 188 } | 192 } |
| 189 | 193 |
| 190 } // namespace content | 194 } // namespace content |
| OLD | NEW |