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 IOSurfaceLock(io_surface_, 0, NULL); | 40 IOSurfaceLock(io_surface_, 0, NULL); |
41 mapped_ = true; | 41 mapped_ = true; |
42 return IOSurfaceGetBaseAddress(io_surface_); | 42 *data = IOSurfaceGetBaseAddress(io_surface_); |
| 43 return true; |
43 } | 44 } |
44 | 45 |
45 void GpuMemoryBufferImplIOSurface::Unmap() { | 46 void GpuMemoryBufferImplIOSurface::Unmap() { |
46 DCHECK(mapped_); | 47 DCHECK(mapped_); |
47 IOSurfaceUnlock(io_surface_, 0, NULL); | 48 IOSurfaceUnlock(io_surface_, 0, NULL); |
48 mapped_ = false; | 49 mapped_ = false; |
49 } | 50 } |
50 | 51 |
51 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { | 52 void GpuMemoryBufferImplIOSurface::GetStride(uint32* stride) const { |
52 return IOSurfaceGetBytesPerRow(io_surface_); | 53 *stride = IOSurfaceGetBytesPerRow(io_surface_); |
53 } | 54 } |
54 | 55 |
55 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 56 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
56 gfx::GpuMemoryBufferHandle handle; | 57 gfx::GpuMemoryBufferHandle handle; |
57 handle.type = gfx::IO_SURFACE_BUFFER; | 58 handle.type = gfx::IO_SURFACE_BUFFER; |
58 handle.id = id_; | 59 handle.id = id_; |
59 handle.io_surface_id = IOSurfaceGetID(io_surface_); | 60 handle.io_surface_id = IOSurfaceGetID(io_surface_); |
60 return handle; | 61 return handle; |
61 } | 62 } |
62 | 63 |
63 } // namespace content | 64 } // namespace content |
OLD | NEW |