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