| 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 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 handle.id, size, format, callback, io_surface.release())); | 35 handle.id, size, format, callback, io_surface.release())); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void* GpuMemoryBufferImplIOSurface::Map() { | 38 void* GpuMemoryBufferImplIOSurface::Map() { |
| 39 DCHECK(!mapped_); | 39 DCHECK(!mapped_); |
| 40 IOSurfaceLock(io_surface_, 0, NULL); | 40 IOSurfaceLock(io_surface_, 0, NULL); |
| 41 mapped_ = true; | 41 mapped_ = true; |
| 42 return IOSurfaceGetBaseAddress(io_surface_); | 42 return IOSurfaceGetBaseAddress(io_surface_); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void* GpuMemoryBufferImplIOSurface::Map(size_t plane_index) { |
| 46 if (plane_index >= num_planes_) |
| 47 return NULL; |
| 48 return Map(); |
| 49 } |
| 50 |
| 45 void GpuMemoryBufferImplIOSurface::Unmap() { | 51 void GpuMemoryBufferImplIOSurface::Unmap() { |
| 46 DCHECK(mapped_); | 52 DCHECK(mapped_); |
| 47 IOSurfaceUnlock(io_surface_, 0, NULL); | 53 IOSurfaceUnlock(io_surface_, 0, NULL); |
| 48 mapped_ = false; | 54 mapped_ = false; |
| 49 } | 55 } |
| 50 | 56 |
| 51 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { | 57 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { |
| 52 return IOSurfaceGetBytesPerRow(io_surface_); | 58 return IOSurfaceGetBytesPerRow(io_surface_); |
| 53 } | 59 } |
| 54 | 60 |
| 61 uint32 GpuMemoryBufferImplIOSurface::GetStride(size_t plane_index) const { |
| 62 if (plane_index >= num_planes_) |
| 63 return 0; |
| 64 return GetStride(); |
| 65 } |
| 66 |
| 55 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 67 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
| 56 gfx::GpuMemoryBufferHandle handle; | 68 gfx::GpuMemoryBufferHandle handle; |
| 57 handle.type = gfx::IO_SURFACE_BUFFER; | 69 handle.type = gfx::IO_SURFACE_BUFFER; |
| 58 handle.id = id_; | 70 handle.id = id_; |
| 59 handle.io_surface_id = IOSurfaceGetID(io_surface_); | 71 handle.io_surface_id = IOSurfaceGetID(io_surface_); |
| 60 return handle; | 72 return handle; |
| 61 } | 73 } |
| 62 | 74 |
| 63 } // namespace content | 75 } // namespace content |
| OLD | NEW |