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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 LOG(ERROR) << "IOSurfaces only supported on 10.6."; | 46 LOG(ERROR) << "IOSurfaces only supported on 10.6."; |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 io_surface_.reset(io_surface_support->IOSurfaceLookup(handle.io_surface_id)); | 50 io_surface_.reset(io_surface_support->IOSurfaceLookup(handle.io_surface_id)); |
51 if (!io_surface_) { | 51 if (!io_surface_) { |
52 LOG(ERROR) << "IOSurface lookup failed"; | 52 LOG(ERROR) << "IOSurface lookup failed"; |
53 return false; | 53 return false; |
54 } | 54 } |
55 | 55 |
| 56 // Increment the use count to let the browser process know that we're now |
| 57 // holding a reference to the surface. |
| 58 io_surface_support->IOSurfaceIncrementUseCount(io_surface_); |
56 return true; | 59 return true; |
57 } | 60 } |
58 | 61 |
59 void GpuMemoryBufferImplIOSurface::Map(AccessMode mode, void** vaddr) { | 62 void GpuMemoryBufferImplIOSurface::Map(AccessMode mode, void** vaddr) { |
60 DCHECK(!mapped_); | 63 DCHECK(!mapped_); |
61 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 64 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
62 io_surface_support->IOSurfaceLock(io_surface_, 0, NULL); | 65 io_surface_support->IOSurfaceLock(io_surface_, 0, NULL); |
63 *vaddr = io_surface_support->IOSurfaceGetBaseAddress(io_surface_); | 66 *vaddr = io_surface_support->IOSurfaceGetBaseAddress(io_surface_); |
64 mapped_ = true; | 67 mapped_ = true; |
65 } | 68 } |
(...skipping 12 matching lines...) Expand all Loading... |
78 | 81 |
79 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 82 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
80 gfx::GpuMemoryBufferHandle handle; | 83 gfx::GpuMemoryBufferHandle handle; |
81 handle.type = gfx::IO_SURFACE_BUFFER; | 84 handle.type = gfx::IO_SURFACE_BUFFER; |
82 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 85 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
83 handle.io_surface_id = io_surface_support->IOSurfaceGetID(io_surface_); | 86 handle.io_surface_id = io_surface_support->IOSurfaceGetID(io_surface_); |
84 return handle; | 87 return handle; |
85 } | 88 } |
86 | 89 |
87 } // namespace content | 90 } // namespace content |
OLD | NEW |