Skip to content

Commit 92c62fd

Browse files
authored
fix(🌈): enable wide gamut colors by default on iOS (#3153)
1 parent bbe1f68 commit 92c62fd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎packages/skia/apple/MetalWindowContext.mm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
_layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
2424
_layer.contentsGravity = kCAGravityBottomLeft;
2525
_layer.drawableSize = CGSizeMake(width, height);
26+
BOOL supportsWideColor = NO;
27+
if (@available(iOS 10.0, *)) {
28+
supportsWideColor = [UIScreen mainScreen].traitCollection.displayGamut == UIDisplayGamutP3;
29+
}
30+
if (supportsWideColor) {
31+
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
32+
_layer.colorspace = colorSpace;
33+
CGColorSpaceRelease(colorSpace);
34+
}
2635
}
2736

2837
sk_sp<SkSurface> MetalWindowContext::getSurface() {
@@ -61,4 +70,4 @@
6170
[commandBuffer presentDrawable:_currentDrawable];
6271
[commandBuffer commit];
6372
_skSurface = nullptr;
64-
}
73+
}

0 commit comments

Comments
 (0)