Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: ui/gfx/mac/io_surface.cc

Issue 2480583002: Mac: Workaround IOSurface color behavior change in 10.12 (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/mac/screen_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mac/io_surface.cc
diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc
index 867643a4fcf53250cb2edb6f0d1355104f3ad1cd..c4a30c13c56c17fc0374e38c71a96f292f6783ab 100644
--- a/ui/gfx/mac/io_surface.cc
+++ b/ui/gfx/mac/io_surface.cc
@@ -177,15 +177,28 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, gfx::BufferFormat format) {
DCHECK_EQ(kIOReturnSuccess, r);
}
+ bool force_system_color_space = false;
+
// Displaying an IOSurface that does not have a color space using an
// AVSampleBufferDisplayLayer can result in a black screen. Specify the
// main display's color profile by default, which will result in no color
// correction being done for the main monitor (which is the behavior of not
// specifying a color space).
// https://crbug.com/608879
- if (format == gfx::BufferFormat::YUV_420_BIPLANAR) {
- base::ScopedCFTypeRef<CGColorSpaceRef> color_space(
- CGDisplayCopyColorSpace(CGMainDisplayID()));
+ if (format == gfx::BufferFormat::YUV_420_BIPLANAR)
+ force_system_color_space = true;
+
+ // On Sierra, all IOSurfaces are color corrected as though they are in sRGB
+ // color space by default. Prior to Sierra, IOSurfaces were not color
+ // corrected (they were treated as though they were in the display color
+ // space). Override this by defaulting IOSurfaces to be in the main display
+ // color space.
+ // https://crbug.com/654488
+ if (base::mac::IsAtLeastOS10_12())
+ force_system_color_space = true;
+
+ if (force_system_color_space) {
+ CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
base::ScopedCFTypeRef<CFDataRef> color_space_icc(
CGColorSpaceCopyICCProfile(color_space));
// Note that nullptr is an acceptable input to IOSurfaceSetValue.
« no previous file with comments | « ui/display/mac/screen_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698