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 "gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h" | 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 9 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
9 #include "ui/gfx/buffer_format_util.h" | 10 #include "ui/gfx/buffer_format_util.h" |
10 #include "ui/gfx/mac/io_surface.h" | 11 #include "ui/gfx/mac/io_surface.h" |
11 | 12 |
12 namespace gpu { | 13 namespace gpu { |
13 namespace { | 14 namespace { |
14 | 15 |
15 uint32_t LockFlags(gfx::BufferUsage usage) { | 16 uint32_t LockFlags(gfx::BufferUsage usage) { |
16 switch (usage) { | 17 switch (usage) { |
17 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 18 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
(...skipping 18 matching lines...) Expand all Loading... |
36 const DestructionCallback& callback, | 37 const DestructionCallback& callback, |
37 IOSurfaceRef io_surface, | 38 IOSurfaceRef io_surface, |
38 uint32_t lock_flags) | 39 uint32_t lock_flags) |
39 : GpuMemoryBufferImpl(id, size, format, callback), | 40 : GpuMemoryBufferImpl(id, size, format, callback), |
40 io_surface_(io_surface), | 41 io_surface_(io_surface), |
41 lock_flags_(lock_flags) {} | 42 lock_flags_(lock_flags) {} |
42 | 43 |
43 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {} | 44 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {} |
44 | 45 |
45 // static | 46 // static |
46 scoped_ptr<GpuMemoryBufferImplIOSurface> | 47 std::unique_ptr<GpuMemoryBufferImplIOSurface> |
47 GpuMemoryBufferImplIOSurface::CreateFromHandle( | 48 GpuMemoryBufferImplIOSurface::CreateFromHandle( |
48 const gfx::GpuMemoryBufferHandle& handle, | 49 const gfx::GpuMemoryBufferHandle& handle, |
49 const gfx::Size& size, | 50 const gfx::Size& size, |
50 gfx::BufferFormat format, | 51 gfx::BufferFormat format, |
51 gfx::BufferUsage usage, | 52 gfx::BufferUsage usage, |
52 const DestructionCallback& callback) { | 53 const DestructionCallback& callback) { |
53 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( | 54 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( |
54 IOSurfaceLookupFromMachPort(handle.mach_port.get())); | 55 IOSurfaceLookupFromMachPort(handle.mach_port.get())); |
55 if (!io_surface) | 56 if (!io_surface) |
56 return nullptr; | 57 return nullptr; |
57 | 58 |
58 return make_scoped_ptr( | 59 return base::WrapUnique( |
59 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback, | 60 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback, |
60 io_surface.release(), LockFlags(usage))); | 61 io_surface.release(), LockFlags(usage))); |
61 } | 62 } |
62 | 63 |
63 // static | 64 // static |
64 bool GpuMemoryBufferImplIOSurface::IsConfigurationSupported( | 65 bool GpuMemoryBufferImplIOSurface::IsConfigurationSupported( |
65 gfx::BufferFormat format, | 66 gfx::BufferFormat format, |
66 gfx::BufferUsage usage) { | 67 gfx::BufferUsage usage) { |
67 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage); | 68 return gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage); |
68 } | 69 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 114 } |
114 | 115 |
115 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 116 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
116 gfx::GpuMemoryBufferHandle handle; | 117 gfx::GpuMemoryBufferHandle handle; |
117 handle.type = gfx::IO_SURFACE_BUFFER; | 118 handle.type = gfx::IO_SURFACE_BUFFER; |
118 handle.id = id_; | 119 handle.id = id_; |
119 return handle; | 120 return handle; |
120 } | 121 } |
121 | 122 |
122 } // namespace gpu | 123 } // namespace gpu |
OLD | NEW |