| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/mac/io_surface_manager.h" | 8 #include "content/common/mac/io_surface_manager.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 uint32_t LockFlags(gfx::GpuMemoryBuffer::Usage usage) { | 13 uint32_t LockFlags(gfx::BufferUsage usage) { |
| 14 switch (usage) { | 14 switch (usage) { |
| 15 case gfx::GpuMemoryBuffer::MAP: | 15 case gfx::BufferUsage::MAP: |
| 16 return kIOSurfaceLockAvoidSync; | 16 return kIOSurfaceLockAvoidSync; |
| 17 case gfx::GpuMemoryBuffer::PERSISTENT_MAP: | 17 case gfx::BufferUsage::PERSISTENT_MAP: |
| 18 return 0; | 18 return 0; |
| 19 case gfx::GpuMemoryBuffer::SCANOUT: | 19 case gfx::BufferUsage::SCANOUT: |
| 20 return 0; | 20 return 0; |
| 21 } | 21 } |
| 22 NOTREACHED(); | 22 NOTREACHED(); |
| 23 return 0; | 23 return 0; |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( | 28 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( |
| 29 gfx::GpuMemoryBufferId id, | 29 gfx::GpuMemoryBufferId id, |
| 30 const gfx::Size& size, | 30 const gfx::Size& size, |
| 31 Format format, | 31 gfx::BufferFormat format, |
| 32 const DestructionCallback& callback, | 32 const DestructionCallback& callback, |
| 33 IOSurfaceRef io_surface, | 33 IOSurfaceRef io_surface, |
| 34 uint32_t lock_flags) | 34 uint32_t lock_flags) |
| 35 : GpuMemoryBufferImpl(id, size, format, callback), | 35 : GpuMemoryBufferImpl(id, size, format, callback), |
| 36 io_surface_(io_surface), | 36 io_surface_(io_surface), |
| 37 lock_flags_(lock_flags) { | 37 lock_flags_(lock_flags) {} |
| 38 } | |
| 39 | 38 |
| 40 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() { | 39 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() { |
| 41 } | 40 } |
| 42 | 41 |
| 43 // static | 42 // static |
| 44 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImplIOSurface::CreateFromHandle( | 43 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImplIOSurface::CreateFromHandle( |
| 45 const gfx::GpuMemoryBufferHandle& handle, | 44 const gfx::GpuMemoryBufferHandle& handle, |
| 46 const gfx::Size& size, | 45 const gfx::Size& size, |
| 47 Format format, | 46 gfx::BufferFormat format, |
| 48 Usage usage, | 47 gfx::BufferUsage usage, |
| 49 const DestructionCallback& callback) { | 48 const DestructionCallback& callback) { |
| 50 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( | 49 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( |
| 51 IOSurfaceManager::GetInstance()->AcquireIOSurface(handle.id)); | 50 IOSurfaceManager::GetInstance()->AcquireIOSurface(handle.id)); |
| 52 if (!io_surface) | 51 if (!io_surface) |
| 53 return nullptr; | 52 return nullptr; |
| 54 | 53 |
| 55 return make_scoped_ptr<GpuMemoryBufferImpl>( | 54 return make_scoped_ptr<GpuMemoryBufferImpl>( |
| 56 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback, | 55 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback, |
| 57 io_surface.release(), LockFlags(usage))); | 56 io_surface.release(), LockFlags(usage))); |
| 58 } | 57 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 } | 76 } |
| 78 | 77 |
| 79 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 78 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
| 80 gfx::GpuMemoryBufferHandle handle; | 79 gfx::GpuMemoryBufferHandle handle; |
| 81 handle.type = gfx::IO_SURFACE_BUFFER; | 80 handle.type = gfx::IO_SURFACE_BUFFER; |
| 82 handle.id = id_; | 81 handle.id = id_; |
| 83 return handle; | 82 return handle; |
| 84 } | 83 } |
| 85 | 84 |
| 86 } // namespace content | 85 } // namespace content |
| OLD | NEW |