| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/gfx/mac/io_surface.h" | 5 #include "ui/gfx/mac/io_surface.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // https://crbug.com/594343. | 157 // https://crbug.com/594343. |
| 158 if (!base::mac::IsOSMavericks()) { | 158 if (!base::mac::IsOSMavericks()) { |
| 159 // Zero-initialize the IOSurface. Calling IOSurfaceLock/IOSurfaceUnlock | 159 // Zero-initialize the IOSurface. Calling IOSurfaceLock/IOSurfaceUnlock |
| 160 // appears to be sufficient. https://crbug.com/584760#c17 | 160 // appears to be sufficient. https://crbug.com/584760#c17 |
| 161 IOReturn r = IOSurfaceLock(surface, 0, nullptr); | 161 IOReturn r = IOSurfaceLock(surface, 0, nullptr); |
| 162 DCHECK_EQ(kIOReturnSuccess, r); | 162 DCHECK_EQ(kIOReturnSuccess, r); |
| 163 r = IOSurfaceUnlock(surface, 0, nullptr); | 163 r = IOSurfaceUnlock(surface, 0, nullptr); |
| 164 DCHECK_EQ(kIOReturnSuccess, r); | 164 DCHECK_EQ(kIOReturnSuccess, r); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Displaying an IOSurface that does not have a color space using an |
| 168 // AVSampleBufferDisplayLayer can result in a black screen. Specify the |
| 169 // main display's color profile by default, which will result in no color |
| 170 // correction being done for the main monitor (which is the behavior of not |
| 171 // specifying a color space). |
| 172 // https://crbug.com/608879 |
| 173 if (format == gfx::BufferFormat::YUV_420_BIPLANAR) { |
| 174 base::ScopedCFTypeRef<CGColorSpaceRef> color_space( |
| 175 CGDisplayCopyColorSpace(CGMainDisplayID())); |
| 176 base::ScopedCFTypeRef<CFDataRef> color_space_icc( |
| 177 CGColorSpaceCopyICCProfile(color_space)); |
| 178 // Note that nullptr is an acceptable input to IOSurfaceSetValue. |
| 179 IOSurfaceSetValue(surface, CFSTR("IOSurfaceColorSpace"), color_space_icc); |
| 180 } |
| 181 |
| 167 return surface; | 182 return surface; |
| 168 } | 183 } |
| 169 | 184 |
| 170 } // namespace gfx | 185 } // namespace gfx |
| OLD | NEW |