Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
FlutterView Class Reference

#include <FlutterView.h>

Inheritance diagram for FlutterView:
TestFlutterView

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(instancetype) - initWithFrame:
 
(instancetype) - initWithCoder:
 
(instancetype) - initWithDelegate:opaque:enableWideGamut:
 
(UIScreen *) - screen
 
(MTLPixelFormat) - pixelFormat
 
(void) - setIntrinsicContentSize:
 
(void) - resetIntrinsicContentSize
 
(nullable instancetype) - initWithMTLDevice:commandQueue:delegate:viewIdentifier:
 
(nullable instancetype) - initWithFrame:pixelFormat:
 
(nonnull instancetype) - initWithFrame:
 
(nullable instancetype) - initWithCoder:
 
(nonnull instancetype) - NS_UNAVAILABLE
 
(void) - setBackgroundColor:
 
(void) - didUpdateMouseCursor:
 
(void) - shutDown
 

Class Methods

(instancetype) + NS_UNAVAILABLE
 

Properties

BOOL autoResizable
 
FlutterSurfaceManagersurfaceManager
 

Detailed Description

View capable of acting as a rendering target and input source for the Flutter engine.

Definition at line 49 of file FlutterView.h.

Method Documentation

◆ didUpdateMouseCursor:

- (void) didUpdateMouseCursor: (nonnull NSCursor *)  cursor

Called from the engine to notify the view that mouse cursor was updated while the mouse is over the view. The view is responsible from restoring the cursor when the mouse enters the view from another subview.

Referenced by TEST(), and TEST().

◆ initWithCoder: [1/2]

- (nullable instancetype) initWithCoder: (nonnull NSCoder *)  NS_UNAVAILABLE

◆ initWithCoder: [2/2]

- (instancetype) initWithCoder: (NSCoder*)  NS_UNAVAILABLE

Definition at line 24 of file FlutterView.mm.

37 :(NSCoder*)aDecoder {
38 NSAssert(NO, @"FlutterView must initWithDelegate");
39 return nil;
40}

◆ initWithDelegate:opaque:enableWideGamut:

- (instancetype) initWithDelegate: (id<FlutterViewEngineDelegate>)  delegate
opaque: (BOOL opaque
enableWideGamut: (BOOL NS_DESIGNATED_INITIALIZER 

Definition at line 24 of file FlutterView.mm.

137 :(id<FlutterViewEngineDelegate>)delegate
138 opaque:(BOOL)opaque
139 enableWideGamut:(BOOL)isWideGamutEnabled {
140 if (delegate == nil) {
141 NSLog(@"FlutterView delegate was nil.");
142 return nil;
143 }
144
145 self = [super initWithFrame:CGRectNull];
146
147 if (self) {
148 _delegate = delegate;
149 _isWideGamutEnabled = isWideGamutEnabled;
150 self.layer.opaque = opaque;
151 _autoResizable = NO;
152 _intrinsicSize = CGSizeMake(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric);
153 }
154
155 return self;
156}
if(engine==nullptr)
CGSize _intrinsicSize
int BOOL

◆ initWithFrame: [1/2]

- (instancetype) initWithFrame: (CGRect)  NS_UNAVAILABLE

Definition at line 24 of file FlutterView.mm.

32 :(CGRect)frame {
33 NSAssert(NO, @"FlutterView must initWithDelegate");
34 return nil;
35}

◆ initWithFrame: [2/2]

- (nonnull instancetype) initWithFrame: (NSRect)  NS_UNAVAILABLE

◆ initWithFrame:pixelFormat:

- (nullable instancetype) initWithFrame: (NSRect)  frameRect
pixelFormat: (nullable NSOpenGLPixelFormat *)  NS_UNAVAILABLE 

◆ initWithMTLDevice:commandQueue:delegate:viewIdentifier:

- (nullable instancetype) initWithMTLDevice: (nonnull id< MTLDevice >)  device
commandQueue: (nonnull id< MTLCommandQueue >)  commandQueue
delegate: (nonnull id< FlutterViewDelegate >)  delegate
viewIdentifier: (FlutterViewIdentifier NS_DESIGNATED_INITIALIZER 

Initialize a FlutterView that will be rendered to using Metal rendering apis.

◆ NS_UNAVAILABLE [1/3]

+ (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE [2/3]

- (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE [3/3]

- (nonnull instancetype) NS_UNAVAILABLE

◆ pixelFormat

- (MTLPixelFormat) pixelFormat

Definition at line 24 of file FlutterView.mm.

111 {
112 if ([self.layer isKindOfClass:[CAMetalLayer class]]) {
113// It is a known Apple bug that CAMetalLayer incorrectly reports its supported
114// SDKs. It is, in fact, available since iOS 8.
115#pragma clang diagnostic push
116#pragma clang diagnostic ignored "-Wunguarded-availability-new"
117 CAMetalLayer* layer = (CAMetalLayer*)self.layer;
118 return layer.pixelFormat;
119 }
120 return MTLPixelFormatBGRA8Unorm;
121}

◆ resetIntrinsicContentSize

- (void) resetIntrinsicContentSize

A method that resets and recalculates the instrinsic content size Currently called when the device orientation changes.

Definition at line 24 of file FlutterView.mm.

98 {
99 _intrinsicSize = CGSizeMake(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric);
100 [self removeAutoResizeLayoutConstraints];
101}

◆ screen

- (UIScreen *) screen

Definition at line 24 of file FlutterView.mm.

42 {
43 return self.window.windowScene.screen;
44}

◆ setBackgroundColor:

- (void) setBackgroundColor: (nonnull NSColor *)  color

By default, the FlutterSurfaceManager creates two layers to manage Flutter content, the content layer and containing layer. To set the native background color, onto which the Flutter content is drawn, call this method with the NSColor which you would like to override the default, black background color with.

◆ setIntrinsicContentSize:

- (void) setIntrinsicContentSize: (CGSize)  size

A method that sets the instrinsic content size This is used when autoResizable is enabled.

Definition at line 24 of file FlutterView.mm.

52 :(CGSize)size {
53 if (!self.autoResizable) {
54 return;
55 }
56
57 UIWindow* window = self.window;
58 CGFloat scale = window ? self.window.windowScene.screen.scale : self.traitCollection.displayScale;
59 CGSize scaledSize = CGSizeMake(size.width / scale, size.height / scale);
60
61 CGSize roundedScaleSize = CGSizeMake(roundf(scaledSize.width), roundf(scaledSize.height));
62 CGSize roundedIntrinsicSize =
63 CGSizeMake(roundf(_intrinsicSize.width), roundf(_intrinsicSize.height));
64
65 // If the size has not changed, don't update constraints.
66 if (CGSizeEqualToSize(roundedIntrinsicSize, roundedScaleSize)) {
67 return;
68 }
69 _intrinsicSize = scaledSize;
70
71 self.translatesAutoresizingMaskIntoConstraints = false;
72
73 // Remove any existing FlutterAutoResizeLayoutConstraint
74 [self removeAutoResizeLayoutConstraints];
75
76 FlutterAutoResizeLayoutConstraint* widthConstraint =
77 [FlutterAutoResizeLayoutConstraint constraintWithItem:self
78 attribute:NSLayoutAttributeWidth
79 relatedBy:NSLayoutRelationEqual
80 toItem:nil
81 attribute:NSLayoutAttributeNotAnAttribute
82 multiplier:1.0
83 constant:scaledSize.width];
84
85 FlutterAutoResizeLayoutConstraint* heightConstraint =
86 [FlutterAutoResizeLayoutConstraint constraintWithItem:self
87 attribute:NSLayoutAttributeHeight
88 relatedBy:NSLayoutRelationEqual
89 toItem:nil
90 attribute:NSLayoutAttributeNotAnAttribute
91 multiplier:1.0
92 constant:scaledSize.height];
93
94 [NSLayoutConstraint activateConstraints:@[ widthConstraint, heightConstraint ]];
95 [self setNeedsLayout];
96}
GLFWwindow * window
Definition main.cc:60
BOOL autoResizable
Definition FlutterView.h:74
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size

◆ shutDown

- (void) shutDown

Called from the controller to unblock resize synchronizer when shutting down.

Definition at line 18 of file FlutterView.mm.

53 {
54 [_resizeSynchronizer shutDown];
55}

Property Documentation

◆ autoResizable

- (BOOL) autoResizable
readwritenonatomicassign

Definition at line 74 of file FlutterView.h.

◆ surfaceManager

- (FlutterSurfaceManager *) surfaceManager
readnonatomicassign

Returns SurfaceManager for this view. SurfaceManager is responsible for providing and presenting render surfaces.

Definition at line 56 of file FlutterView.h.


The documentation for this class was generated from the following files: