Flutter Engine
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/FlutterResizableBackingStoreProvider.h"
8 
9 /**
10  * Listener for view resizing.
11  */
12 @protocol FlutterViewReshapeListener <NSObject>
13 /**
14  * Called when the view's backing store changes size.
15  */
16 - (void)viewDidReshape:(nonnull NSView*)view;
17 @end
18 
19 /**
20  * View capable of acting as a rendering target and input source for the Flutter
21  * engine.
22  */
23 @interface FlutterView : NSView
24 
25 /**
26  * Initialize a FlutterView that will be rendered to using Metal rendering apis.
27  */
28 - (nullable instancetype)initWithMTLDevice:(nonnull id<MTLDevice>)device
29  commandQueue:(nonnull id<MTLCommandQueue>)commandQueue
30  reshapeListener:(nonnull id<FlutterViewReshapeListener>)reshapeListener
31  NS_DESIGNATED_INITIALIZER;
32 
33 - (nullable instancetype)initWithFrame:(NSRect)frame
34  mainContext:(nonnull NSOpenGLContext*)mainContext
35  reshapeListener:(nonnull id<FlutterViewReshapeListener>)reshapeListener
36  NS_DESIGNATED_INITIALIZER;
37 
38 - (nullable instancetype)initWithMainContext:(nonnull NSOpenGLContext*)mainContext
39  reshapeListener:
40  (nonnull id<FlutterViewReshapeListener>)reshapeListener;
41 
42 - (nullable instancetype)initWithFrame:(NSRect)frameRect
43  pixelFormat:(nullable NSOpenGLPixelFormat*)format NS_UNAVAILABLE;
44 - (nonnull instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE;
45 - (nullable instancetype)initWithCoder:(nonnull NSCoder*)coder NS_UNAVAILABLE;
46 - (nonnull instancetype)init NS_UNAVAILABLE;
47 
48 /**
49  * Flushes the OpenGL context and flips the surfaces. Expected to be called on raster thread.
50  */
51 - (void)present;
52 
53 /**
54  * Ensures that a backing store with requested size exists and returns the descriptor. Expected to
55  * be called on raster thread.
56  */
57 - (nonnull FlutterRenderBackingStore*)backingStoreForSize:(CGSize)size;
58 
59 /**
60  * Must be called when shutting down. Unblocks raster thread and prevents any further
61  * synchronization.
62  */
63 - (void)shutdown;
64 
65 @end
void present()
Definition: FlutterView.mm:71
instancetype NS_UNAVAILABLE()