7 #include <CoreGraphics/CGColorSpace.h>
10 #include "fml/platform/darwin/cf_utils.h"
16 fml::CFRef<CGColorSpaceRef> _colorSpaceRef;
20 NSAssert(NO,
@"FlutterOverlayView must init or initWithContentsScale");
25 NSAssert(NO,
@"FlutterOverlayView must init or initWithContentsScale");
29 - (instancetype)init {
30 self = [
super initWithFrame:CGRectZero];
33 self.layer.opaque = NO;
34 self.userInteractionEnabled = NO;
35 self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
41 - (instancetype)initWithContentsScale:(CGFloat)contentsScale
42 pixelFormat:(MTLPixelFormat)pixelFormat {
45 if ([
self.layer isKindOfClass:NSClassFromString(
@"CAMetalLayer")]) {
46 self.layer.allowsGroupOpacity = NO;
47 self.layer.contentsScale = contentsScale;
48 self.layer.rasterizationScale = contentsScale;
49 #pragma clang diagnostic push
50 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
51 CAMetalLayer* layer = (CAMetalLayer*)
self.layer;
52 #pragma clang diagnostic pop
53 layer.pixelFormat = pixelFormat;
54 if (pixelFormat == MTLPixelFormatRGBA16Float || pixelFormat == MTLPixelFormatBGRA10_XR) {
55 self->_colorSpaceRef = fml::CFRef(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
56 layer.colorspace =
self->_colorSpaceRef;