Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 const DestructionCallback& callback) { | 28 const DestructionCallback& callback) { |
| 29 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( | 29 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( |
| 30 IOSurfaceLookup(handle.io_surface_id)); | 30 IOSurfaceLookup(handle.io_surface_id)); |
| 31 if (!io_surface) | 31 if (!io_surface) |
| 32 return scoped_ptr<GpuMemoryBufferImpl>(); | 32 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 33 | 33 |
| 34 return make_scoped_ptr<GpuMemoryBufferImpl>(new GpuMemoryBufferImplIOSurface( | 34 return make_scoped_ptr<GpuMemoryBufferImpl>(new GpuMemoryBufferImplIOSurface( |
| 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 bool GpuMemoryBufferImplIOSurface::Map(void** data) { |
| 39 DCHECK(!mapped_); | 39 DCHECK(!mapped_); |
| 40 DCHECK_EQ(num_planes_, 1u); | |
|
reveman
2015/03/24 20:13:59
Not needed as it would require us to create a buff
emircan
2015/03/24 21:43:44
Done.
| |
| 40 IOSurfaceLock(io_surface_, 0, NULL); | 41 IOSurfaceLock(io_surface_, 0, NULL); |
| 41 mapped_ = true; | 42 mapped_ = true; |
| 42 return IOSurfaceGetBaseAddress(io_surface_); | 43 data[0] = IOSurfaceGetBaseAddress(io_surface_); |
| 44 return true; | |
| 43 } | 45 } |
| 44 | 46 |
| 47 | |
| 45 void GpuMemoryBufferImplIOSurface::Unmap() { | 48 void GpuMemoryBufferImplIOSurface::Unmap() { |
| 46 DCHECK(mapped_); | 49 DCHECK(mapped_); |
| 47 IOSurfaceUnlock(io_surface_, 0, NULL); | 50 IOSurfaceUnlock(io_surface_, 0, NULL); |
| 48 mapped_ = false; | 51 mapped_ = false; |
| 49 } | 52 } |
| 50 | 53 |
| 51 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { | 54 bool GpuMemoryBufferImplIOSurface::GetStride(uint32* stride) const { |
| 52 return IOSurfaceGetBytesPerRow(io_surface_); | 55 DCHECK_EQ(num_planes_, 1u); |
|
reveman
2015/03/24 20:13:59
Not needed as it would require us to create a buff
emircan
2015/03/24 21:43:44
Done.
| |
| 56 stride[0] = IOSurfaceGetBytesPerRow(io_surface_); | |
| 57 return true; | |
| 53 } | 58 } |
| 54 | 59 |
| 55 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 60 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
| 56 gfx::GpuMemoryBufferHandle handle; | 61 gfx::GpuMemoryBufferHandle handle; |
| 57 handle.type = gfx::IO_SURFACE_BUFFER; | 62 handle.type = gfx::IO_SURFACE_BUFFER; |
| 58 handle.id = id_; | 63 handle.id = id_; |
| 59 handle.io_surface_id = IOSurfaceGetID(io_surface_); | 64 handle.io_surface_id = IOSurfaceGetID(io_surface_); |
| 60 return handle; | 65 return handle; |
| 61 } | 66 } |
| 62 | 67 |
| 63 } // namespace content | 68 } // namespace content |
| OLD | NEW |