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