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 "gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h" | 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_io_surface.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 9 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
10 #include "ui/gfx/buffer_format_util.h" | 10 #include "ui/gfx/buffer_format_util.h" |
| 11 #include "ui/gfx/color_space.h" |
11 #include "ui/gfx/mac/io_surface.h" | 12 #include "ui/gfx/mac/io_surface.h" |
12 | 13 |
13 namespace gpu { | 14 namespace gpu { |
14 namespace { | 15 namespace { |
15 | 16 |
16 uint32_t LockFlags(gfx::BufferUsage usage) { | 17 uint32_t LockFlags(gfx::BufferUsage usage) { |
17 switch (usage) { | 18 switch (usage) { |
18 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 19 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
19 return kIOSurfaceLockAvoidSync; | 20 return kIOSurfaceLockAvoidSync; |
20 case gfx::BufferUsage::GPU_READ: | 21 case gfx::BufferUsage::GPU_READ: |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 DCHECK(mapped_); | 103 DCHECK(mapped_); |
103 IOSurfaceUnlock(io_surface_, lock_flags_, NULL); | 104 IOSurfaceUnlock(io_surface_, lock_flags_, NULL); |
104 mapped_ = false; | 105 mapped_ = false; |
105 } | 106 } |
106 | 107 |
107 int GpuMemoryBufferImplIOSurface::stride(size_t plane) const { | 108 int GpuMemoryBufferImplIOSurface::stride(size_t plane) const { |
108 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); | 109 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); |
109 return IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane); | 110 return IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane); |
110 } | 111 } |
111 | 112 |
| 113 void GpuMemoryBufferImplIOSurface::SetColorSpaceForScanout( |
| 114 const gfx::ColorSpace& color_space) { |
| 115 const std::vector<char>& icc_profile = color_space.GetICCProfile(); |
| 116 if (icc_profile.size()) { |
| 117 base::ScopedCFTypeRef<CFDataRef> cf_data_icc_profile(CFDataCreate( |
| 118 nullptr, reinterpret_cast<const UInt8*>(icc_profile.data()), |
| 119 icc_profile.size())); |
| 120 IOSurfaceSetValue(io_surface_, CFSTR("IOSurfaceColorSpace"), |
| 121 cf_data_icc_profile); |
| 122 } |
| 123 } |
| 124 |
112 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 125 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
113 gfx::GpuMemoryBufferHandle handle; | 126 gfx::GpuMemoryBufferHandle handle; |
114 handle.type = gfx::IO_SURFACE_BUFFER; | 127 handle.type = gfx::IO_SURFACE_BUFFER; |
115 handle.id = id_; | 128 handle.id = id_; |
116 return handle; | 129 return handle; |
117 } | 130 } |
118 | 131 |
119 } // namespace gpu | 132 } // namespace gpu |
OLD | NEW |