Flutter Engine
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 "flutter/common/settings.h"
8 #include "flutter/common/task_runners.h"
9 #include "flutter/flow/layers/layer_tree.h"
10 #include "flutter/fml/platform/darwin/cf_utils.h"
11 #include "flutter/fml/synchronization/waitable_event.h"
12 #include "flutter/fml/trace_event.h"
13 #include "flutter/shell/common/platform_view.h"
14 #include "flutter/shell/common/rasterizer.h"
15 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
16 #import "flutter/shell/platform/darwin/ios/ios_surface_gl.h"
17 #import "flutter/shell/platform/darwin/ios/ios_surface_software.h"
18 #include "third_party/skia/include/utils/mac/SkCGUtils.h"
19 
20 // This is mostly a duplication of FlutterView.
21 // TODO(amirh): once GL support is in evaluate if we can merge this with FlutterView.
22 @implementation FlutterOverlayView
23 
24 - (instancetype)initWithFrame:(CGRect)frame {
25  NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
26  return nil;
27 }
28 
29 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
30  NSAssert(NO, @"FlutterOverlayView must init or initWithContentsScale");
31  return nil;
32 }
33 
34 - (instancetype)init {
35  self = [super initWithFrame:CGRectZero];
36 
37  if (self) {
38  self.layer.opaque = NO;
39  self.userInteractionEnabled = NO;
40  self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
41  }
42 
43  return self;
44 }
45 
46 - (instancetype)initWithContentsScale:(CGFloat)contentsScale {
47  self = [self init];
48 
49  if ([self.layer isKindOfClass:NSClassFromString(@"CAEAGLLayer")] ||
50  [self.layer isKindOfClass:NSClassFromString(@"CAMetalLayer")]) {
51  self.layer.allowsGroupOpacity = NO;
52  self.layer.contentsScale = contentsScale;
53  self.layer.rasterizationScale = contentsScale;
54  }
55 
56  return self;
57 }
58 
59 + (Class)layerClass {
60  return [FlutterView layerClass];
61 }
62 
63 // TODO(amirh): implement drawLayer to support snapshotting.
64 
65 @end