| 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 #include <CoreGraphics/CGColorSpace.h>
7 #include <Metal/Metal.h>
8
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"
17 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
18 #import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
19 #include "third_party/skia/include/utils/mac/SkCGUtils.h"
20
21 // This is mostly a duplication of FlutterView.
22 // TODO(amirh): once GL support is in evaluate if we can merge this with FlutterView.
23 @implementation FlutterOverlayView {
24 fml::CFRef<CGColorSpaceRef> _colorSpaceRef;
25 }
26
27 - (instancetype)initWithFrame:(CGRect)frame {
28 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
29 return nil;
30 }
31
32 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
33 NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
34 return nil;
35 }
36
37 - (instancetype)init {
38 self = [super initWithFrame:CGRectZero];
39
40 if (self) {
41 self.layer.opaque = NO;
42 self.userInteractionEnabled = NO;
43 self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
44 }
45
46 return self;
47 }
48
49 - (instancetype)initWithContentsScale:(CGFloat)contentsScale
50 pixelFormat:(MTLPixelFormat)pixelFormat {
51 self = [self init];
52
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;
65 }
66 }
67 return self;
68 }
69
70 + (Class)layerClass {
71 return [FlutterView layerClass];
72 }
73
74 // TODO(amirh): implement drawLayer to support snapshotting.
75
76 @end
initWithFrame
instancetype initWithFrame
Definition: FlutterTextInputPlugin.h:167
ios_surface_software.h
FlutterOverlayView.h
initWithCoder
instancetype initWithCoder
Definition: FlutterTextInputPlugin.h:166
FlutterOverlayView
Definition: FlutterOverlayView.h:31
FlutterView
Definition: FlutterView.h:39
FlutterView.h