6 #include <CoreGraphics/CGColorSpace.h>
7 #include <Metal/Metal.h>
9 #include "flutter/common/settings.h"
10 #include "flutter/common/task_runners.h"
11 #include "flutter/flow/layers/layer_tree.h"
12 #include "flutter/fml/platform/darwin/cf_utils.h"
13 #include "flutter/fml/synchronization/waitable_event.h"
14 #include "flutter/fml/trace_event.h"
15 #include "flutter/shell/common/platform_view.h"
16 #include "flutter/shell/common/rasterizer.h"
19 #include "third_party/skia/include/utils/mac/SkCGUtils.h"
24 fml::CFRef<CGColorSpaceRef> _colorSpaceRef;
28 NSAssert(NO,
@"FlutterOverlayView must init or initWithContentsScale");
33 NSAssert(NO,
@"FlutterOverlayView must init or initWithContentsScale");
37 - (instancetype)init {
38 self = [
super initWithFrame:CGRectZero];
41 self.layer.opaque = NO;
42 self.userInteractionEnabled = NO;
43 self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
49 - (instancetype)initWithContentsScale:(CGFloat)contentsScale
50 pixelFormat:(MTLPixelFormat)pixelFormat {
53 if ([
self.layer isKindOfClass:NSClassFromString(
@"CAMetalLayer")]) {
54 self.layer.allowsGroupOpacity = NO;
55 self.layer.contentsScale = contentsScale;
56 self.layer.rasterizationScale = contentsScale;
57 #pragma clang diagnostic push
58 #pragma clang diagnostic ignored "-Wunguarded-availability-new"
59 CAMetalLayer* layer = (CAMetalLayer*)
self.layer;
60 #pragma clang diagnostic pop
61 layer.pixelFormat = pixelFormat;
62 if (pixelFormat == MTLPixelFormatRGBA16Float) {
63 self->_colorSpaceRef = fml::CFRef(CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB));
64 layer.colorspace =
self->_colorSpaceRef;