| 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 Noop() { | 18 void GpuMemoryBufferDeleted(const gfx::GpuMemoryBufferHandle& handle, |
| 19 uint32 sync_point) { |
| 20 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, |
| 21 sync_point); |
| 19 } | 22 } |
| 20 | 23 |
| 21 void GpuMemoryBufferCreated( | 24 void GpuMemoryBufferCreated( |
| 22 const gfx::Size& size, | 25 const gfx::Size& size, |
| 23 gfx::GpuMemoryBuffer::Format format, | 26 gfx::GpuMemoryBuffer::Format format, |
| 24 const GpuMemoryBufferImpl::CreationCallback& callback, | 27 const GpuMemoryBufferImpl::CreationCallback& callback, |
| 25 const gfx::GpuMemoryBufferHandle& handle) { | 28 const gfx::GpuMemoryBufferHandle& handle) { |
| 26 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); | 29 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); |
| 27 | 30 |
| 28 callback.Run(GpuMemoryBufferImplIOSurface::CreateFromHandle( | 31 callback.Run(GpuMemoryBufferImplIOSurface::CreateFromHandle( |
| 29 handle, size, format, base::Bind(&Noop))); | 32 handle, size, format, base::Bind(&GpuMemoryBufferDeleted, handle))); |
| 30 } | 33 } |
| 31 | 34 |
| 32 void GpuMemoryBufferCreatedForChildProcess( | 35 void GpuMemoryBufferCreatedForChildProcess( |
| 33 const GpuMemoryBufferImpl::AllocationCallback& callback, | 36 const GpuMemoryBufferImpl::AllocationCallback& callback, |
| 34 const gfx::GpuMemoryBufferHandle& handle) { | 37 const gfx::GpuMemoryBufferHandle& handle) { |
| 35 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); | 38 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type); |
| 36 | 39 |
| 37 callback.Run(handle); | 40 callback.Run(handle); |
| 38 } | 41 } |
| 39 | 42 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 98 |
| 96 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( | 99 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( |
| 97 IOSurfaceLookup(handle.io_surface_id)); | 100 IOSurfaceLookup(handle.io_surface_id)); |
| 98 if (!io_surface) | 101 if (!io_surface) |
| 99 return scoped_ptr<GpuMemoryBufferImpl>(); | 102 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 100 | 103 |
| 101 return make_scoped_ptr<GpuMemoryBufferImpl>(new GpuMemoryBufferImplIOSurface( | 104 return make_scoped_ptr<GpuMemoryBufferImpl>(new GpuMemoryBufferImplIOSurface( |
| 102 size, format, callback, io_surface.get())); | 105 size, format, callback, io_surface.get())); |
| 103 } | 106 } |
| 104 | 107 |
| 108 void GpuMemoryBufferImplIOSurface::DeletedByChildProcess( |
| 109 const gfx::GpuMemoryBufferId& id, |
| 110 uint32_t sync_point) { |
| 111 gfx::GpuMemoryBufferHandle handle; |
| 112 handle.type = gfx::IO_SURFACE_BUFFER; |
| 113 handle.global_id = id; |
| 114 |
| 115 GpuMemoryBufferFactoryHost::GetInstance()->DestroyGpuMemoryBuffer(handle, |
| 116 sync_point); |
| 117 } |
| 118 |
| 105 // static | 119 // static |
| 106 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(Format format) { | 120 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(Format format) { |
| 107 switch (format) { | 121 switch (format) { |
| 108 case BGRA_8888: | 122 case BGRA_8888: |
| 109 return true; | 123 return true; |
| 110 case RGBA_8888: | 124 case RGBA_8888: |
| 111 case RGBX_8888: | 125 case RGBX_8888: |
| 112 return false; | 126 return false; |
| 113 } | 127 } |
| 114 | 128 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 182 } |
| 169 | 183 |
| 170 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 184 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
| 171 gfx::GpuMemoryBufferHandle handle; | 185 gfx::GpuMemoryBufferHandle handle; |
| 172 handle.type = gfx::IO_SURFACE_BUFFER; | 186 handle.type = gfx::IO_SURFACE_BUFFER; |
| 173 handle.io_surface_id = IOSurfaceGetID(io_surface_); | 187 handle.io_surface_id = IOSurfaceGetID(io_surface_); |
| 174 return handle; | 188 return handle; |
| 175 } | 189 } |
| 176 | 190 |
| 177 } // namespace content | 191 } // namespace content |
| OLD | NEW |