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  @throw([NSException exceptionWithName:@"FlutterOverlayView must init or initWithContentsScale"
26  reason:nil
27  userInfo:nil]);
28 }
29 
30 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
31  @throw([NSException exceptionWithName:@"FlutterOverlayView must init or initWithContentsScale"
32  reason:nil
33  userInfo:nil]);
34 }
35 
36 - (instancetype)init {
37  self = [super initWithFrame:CGRectZero];
38 
39  if (self) {
40  self.layer.opaque = NO;
41  self.userInteractionEnabled = NO;
42  self.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
43  }
44 
45  return self;
46 }
47 
48 - (instancetype)initWithContentsScale:(CGFloat)contentsScale {
49  self = [self init];
50 
51  if ([self.layer isKindOfClass:NSClassFromString(@"CAEAGLLayer")] ||
52  [self.layer isKindOfClass:NSClassFromString(@"CAMetalLayer")]) {
53  self.layer.allowsGroupOpacity = NO;
54  self.layer.contentsScale = contentsScale;
55  self.layer.rasterizationScale = contentsScale;
56  }
57 
58  return self;
59 }
60 
61 + (Class)layerClass {
62  return [FlutterView layerClass];
63 }
64 
65 // TODO(amirh): implement drawLayer to support snapshotting.
66 
67 @end