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 "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
9 #include "ui/gl/io_surface_support_mac.h" | 9 #include "ui/gl/io_surface_support_mac.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 gfx::GpuMemoryBufferHandle handle) { | 45 gfx::GpuMemoryBufferHandle handle) { |
46 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id)); | 46 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id)); |
47 if (!io_surface_) { | 47 if (!io_surface_) { |
48 VLOG(1) << "IOSurface lookup failed"; | 48 VLOG(1) << "IOSurface lookup failed"; |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 void* GpuMemoryBufferImplIOSurface::Map(AccessMode mode) { | 55 void* GpuMemoryBufferImplIOSurface::Map() { |
56 DCHECK(!mapped_); | 56 DCHECK(!mapped_); |
57 io_surface_support_->IOSurfaceLock(io_surface_, 0, NULL); | 57 io_surface_support_->IOSurfaceLock(io_surface_, 0, NULL); |
58 mapped_ = true; | 58 mapped_ = true; |
59 return io_surface_support_->IOSurfaceGetBaseAddress(io_surface_); | 59 return io_surface_support_->IOSurfaceGetBaseAddress(io_surface_); |
60 } | 60 } |
61 | 61 |
62 void GpuMemoryBufferImplIOSurface::Unmap() { | 62 void GpuMemoryBufferImplIOSurface::Unmap() { |
63 DCHECK(mapped_); | 63 DCHECK(mapped_); |
64 io_surface_support_->IOSurfaceUnlock(io_surface_, 0, NULL); | 64 io_surface_support_->IOSurfaceUnlock(io_surface_, 0, NULL); |
65 mapped_ = false; | 65 mapped_ = false; |
66 } | 66 } |
67 | 67 |
68 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { | 68 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { |
69 return io_surface_support_->IOSurfaceGetBytesPerRow(io_surface_); | 69 return io_surface_support_->IOSurfaceGetBytesPerRow(io_surface_); |
70 } | 70 } |
71 | 71 |
72 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 72 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
73 gfx::GpuMemoryBufferHandle handle; | 73 gfx::GpuMemoryBufferHandle handle; |
74 handle.type = gfx::IO_SURFACE_BUFFER; | 74 handle.type = gfx::IO_SURFACE_BUFFER; |
75 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_); | 75 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_); |
76 return handle; | 76 return handle; |
77 } | 77 } |
78 | 78 |
79 } // namespace content | 79 } // namespace content |
OLD | NEW |