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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 10 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 int GpuMemoryBufferImplIOSurface::stride(size_t plane) const { | 109 int GpuMemoryBufferImplIOSurface::stride(size_t plane) const { |
110 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); | 110 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_)); |
111 return IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane); | 111 return IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane); |
112 } | 112 } |
113 | 113 |
114 void GpuMemoryBufferImplIOSurface::SetColorSpaceForScanout( | 114 void GpuMemoryBufferImplIOSurface::SetColorSpaceForScanout( |
115 const gfx::ColorSpace& color_space) { | 115 const gfx::ColorSpace& color_space) { |
116 if (color_space == color_space_) | 116 if (color_space == color_space_) |
117 return; | 117 return; |
118 color_space_ = color_space; | 118 color_space_ = color_space; |
119 std::vector<char> icc_profile = | 119 |
120 gfx::ICCProfile::FromColorSpace(color_space).GetData(); | 120 // Retrieve the ICC profile data. |
121 if (icc_profile.size()) { | 121 gfx::ICCProfile icc_profile; |
122 base::ScopedCFTypeRef<CFDataRef> cf_data_icc_profile(CFDataCreate( | 122 if (!color_space_.GetICCProfile(&icc_profile)) { |
123 nullptr, reinterpret_cast<const UInt8*>(icc_profile.data()), | 123 DLOG(ERROR) << "Failed to set color space for scanout: no ICC profile."; |
124 icc_profile.size())); | 124 return; |
125 IOSurfaceSetValue(io_surface_, CFSTR("IOSurfaceColorSpace"), | |
126 cf_data_icc_profile); | |
127 } | 125 } |
| 126 |
| 127 // Package it as a CFDataRef and send it to the IOSurface. |
| 128 base::ScopedCFTypeRef<CFDataRef> cf_data_icc_profile(CFDataCreate( |
| 129 nullptr, reinterpret_cast<const UInt8*>(icc_profile.GetData().data()), |
| 130 icc_profile.GetData().size())); |
| 131 IOSurfaceSetValue(io_surface_, CFSTR("IOSurfaceColorSpace"), |
| 132 cf_data_icc_profile); |
128 } | 133 } |
129 | 134 |
130 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 135 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
131 gfx::GpuMemoryBufferHandle handle; | 136 gfx::GpuMemoryBufferHandle handle; |
132 handle.type = gfx::IO_SURFACE_BUFFER; | 137 handle.type = gfx::IO_SURFACE_BUFFER; |
133 handle.id = id_; | 138 handle.id = id_; |
134 return handle; | 139 return handle; |
135 } | 140 } |
136 | 141 |
137 } // namespace gpu | 142 } // namespace gpu |
OLD | NEW |