| Flutter iOS Embedder |

FlutterOverlayView.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h"
6
7 #include <CoreGraphics/CGColorSpace.h>
8
9 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
10 #include "fml/platform/darwin/cf_utils.h"
11
12 FLUTTER_ASSERT_ARC
13
14 // This is mostly a duplication of FlutterView.
15 // TODO(amirh): once GL support is in evaluate if we can merge this with FlutterView.
16 @implementation FlutterOverlayView {
17 fml::CFRef<CGColorSpaceRef> _colorSpaceRef;
18 }
19
20 - (instancetype)initWithFrame:(CGRect)frame {
21 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
22 return nil;
23 }
24
25 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
26 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
27 return nil;
28 }
29
30 - (instancetype)init {
31 self = [super initWithFrame:CGRectZero];
32
33 if (self) {
34 self.layer.opaque = NO;
35 self.userInteractionEnabled = NO;
36 self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
37 }
38
39 return self;
40 }
41
42 - (instancetype)initWithContentsScale:(CGFloat)contentsScale
43 pixelFormat:(MTLPixelFormat)pixelFormat {
44 self = [self init];
45
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;
58 }
59 }
60 return self;
61 }
62
63 + (Class)layerClass {
64 return [FlutterView layerClass];
65 }
66
67 // TODO(amirh): implement drawLayer to support snapshotting.
68
69 @end
initWithFrame
instancetype initWithFrame
Definition: FlutterTextInputPlugin.h:172
FlutterOverlayView.h
initWithCoder
instancetype initWithCoder
Definition: FlutterTextInputPlugin.h:171
FlutterOverlayView
Definition: FlutterOverlayView.h:22
FlutterView
Definition: FlutterView.h:34
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
FlutterView.h