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 { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 return make_scoped_ptr<GpuMemoryBufferImpl>( | 54 return make_scoped_ptr<GpuMemoryBufferImpl>( |
55 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback, | 55 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback, |
56 io_surface.release(), LockFlags(usage))); | 56 io_surface.release(), LockFlags(usage))); |
57 } | 57 } |
58 | 58 |
59 bool GpuMemoryBufferImplIOSurface::Map(void** data) { | 59 bool GpuMemoryBufferImplIOSurface::Map(void** data) { |
60 DCHECK(!mapped_); | 60 DCHECK(!mapped_); |
61 IOReturn status = IOSurfaceLock(io_surface_, lock_flags_, NULL); | 61 IOReturn status = IOSurfaceLock(io_surface_, lock_flags_, NULL); |
62 DCHECK_NE(status, kIOReturnCannotLock); | 62 DCHECK_NE(status, kIOReturnCannotLock); |
63 mapped_ = true; | 63 mapped_ = true; |
64 *data = IOSurfaceGetBaseAddress(io_surface_); | 64 |
65 const size_t planes = IOSurfaceGetPlaneCount(io_surface_); | |
reveman
2015/08/10 22:40:54
nit: no need for 'const' and maybe plane_count or
Andre
2015/08/11 03:50:46
Done.
| |
66 if (planes == 0) { | |
reveman
2015/08/10 22:40:54
Does IOSurfaceGetPlaneCount actually return this?
Andre
2015/08/11 03:50:46
Yes, IOSurface actually returns 0 in the non-plana
| |
67 data[0] = IOSurfaceGetBaseAddress(io_surface_); | |
68 } else { | |
69 for (size_t plane = 0; plane < planes; ++plane) | |
70 data[plane] = IOSurfaceGetBaseAddressOfPlane(io_surface_, plane); | |
71 } | |
65 return true; | 72 return true; |
66 } | 73 } |
67 | 74 |
68 void GpuMemoryBufferImplIOSurface::Unmap() { | 75 void GpuMemoryBufferImplIOSurface::Unmap() { |
69 DCHECK(mapped_); | 76 DCHECK(mapped_); |
70 IOSurfaceUnlock(io_surface_, lock_flags_, NULL); | 77 IOSurfaceUnlock(io_surface_, lock_flags_, NULL); |
71 mapped_ = false; | 78 mapped_ = false; |
72 } | 79 } |
73 | 80 |
74 void GpuMemoryBufferImplIOSurface::GetStride(int* stride) const { | 81 void GpuMemoryBufferImplIOSurface::GetStride(int* strides) const { |
reveman
2015/08/10 22:40:55
same comments here as above
Andre
2015/08/11 03:50:45
Done.
| |
75 *stride = IOSurfaceGetBytesPerRow(io_surface_); | 82 const size_t planes = IOSurfaceGetPlaneCount(io_surface_); |
83 if (planes == 0) { | |
84 strides[0] = IOSurfaceGetBytesPerRow(io_surface_); | |
85 } else { | |
86 for (size_t plane = 0; plane < planes; ++plane) | |
87 strides[plane] = IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane); | |
88 } | |
76 } | 89 } |
77 | 90 |
78 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 91 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
79 gfx::GpuMemoryBufferHandle handle; | 92 gfx::GpuMemoryBufferHandle handle; |
80 handle.type = gfx::IO_SURFACE_BUFFER; | 93 handle.type = gfx::IO_SURFACE_BUFFER; |
81 handle.id = id_; | 94 handle.id = id_; |
82 return handle; | 95 return handle; |
83 } | 96 } |
84 | 97 |
85 } // namespace content | 98 } // namespace content |
OLD | NEW |