| Flutter macOS Embedder |

FlutterView.h
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 <Cocoa/Cocoa.h>
6
7 #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h"
8 #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h"
9
10 #include <stdint.h>
11
12 typedef int64_t FlutterViewId;
13
14 /**
15 * The view ID for APIs that don't support multi-view.
16 *
17 * Some single-view APIs will eventually be replaced by their multi-view
18 * variant. During the deprecation period, the single-view APIs will coexist with
19 * and work with the multi-view APIs as if the other views don't exist. For
20 * backward compatibility, single-view APIs will always operate on the view with
21 * this ID. Also, the first view assigned to the engine will also have this ID.
22 */
23 constexpr FlutterViewId kFlutterImplicitViewId = 0ll;
24
25 /**
26 * Listener for view resizing.
27 */
28 @protocol FlutterViewReshapeListener <NSObject>
29 /**
30 * Called when the view's backing store changes size.
31 */
32 - (void)viewDidReshape:(nonnull NSView*)view;
33 @end
34
35 /**
36 * View capable of acting as a rendering target and input source for the Flutter
37 * engine.
38 */
39 @interface FlutterView : NSView
40
41 /**
42 * Initialize a FlutterView that will be rendered to using Metal rendering apis.
43 */
44 - (nullable instancetype)initWithMTLDevice:(nonnull id<MTLDevice>)device
45 commandQueue:(nonnull id<MTLCommandQueue>)commandQueue
46 reshapeListener:(nonnull id<FlutterViewReshapeListener>)reshapeListener
47 threadSynchronizer:(nonnull FlutterThreadSynchronizer*)threadSynchronizer
48 viewId:(int64_t)viewId NS_DESIGNATED_INITIALIZER;
49
50 - (nullable instancetype)initWithFrame:(NSRect)frameRect
51 pixelFormat:(nullable NSOpenGLPixelFormat*)format NS_UNAVAILABLE;
52 - (nonnull instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;
53 - (nullable instancetype)initWithCoder:(nonnull NSCoder*)coder NS_UNAVAILABLE;
54 - (nonnull instancetype)init NS_UNAVAILABLE;
55
56 /**
57 * Returns SurfaceManager for this view. SurfaceManager is responsible for
58 * providing and presenting render surfaces.
59 */
60 @property(readonly, nonatomic, nonnull) FlutterSurfaceManager* surfaceManager;
61
62 /**
63 * By default, the `FlutterSurfaceManager` creates two layers to manage Flutter
64 * content, the content layer and containing layer. To set the native background
65 * color, onto which the Flutter content is drawn, call this method with the
66 * NSColor which you would like to override the default, black background color
67 * with.
68 */
69 - (void)setBackgroundColor:(nonnull NSColor*)color;
70
71 @end
FlutterView::surfaceManager
FlutterSurfaceManager * surfaceManager
Definition: FlutterView.h:60
FlutterSurfaceManager.h
FlutterViewReshapeListener-p
Definition: FlutterView.h:28
FlutterSurfaceManager
Definition: FlutterSurfaceManager.h:41
kFlutterImplicitViewId
constexpr FlutterViewId kFlutterImplicitViewId
Definition: FlutterView.h:23
FlutterThreadSynchronizer
Definition: FlutterThreadSynchronizer.h:13
FlutterView
Definition: FlutterView.h:39
FlutterThreadSynchronizer.h
-[FlutterView NS_UNAVAILABLE]
nonnull instancetype NS_UNAVAILABLE()
FlutterViewId
int64_t FlutterViewId
Definition: FlutterView.h:12