| Flutter macOS Embedder |

FlutterCompositor.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 #ifndef FLUTTER_COMPOSITOR_H_
6 #define FLUTTER_COMPOSITOR_H_
7
8 #include <functional>
9 #include <list>
10
11 #include "flutter/fml/macros.h"
12 #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.h"
13 #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h"
14 #include "flutter/shell/platform/embedder/embedder.h"
15
16 @class FlutterMutatorView;
17
18 namespace flutter {
19
20 // FlutterCompositor creates and manages the backing stores used for
21 // rendering Flutter content and presents Flutter content and Platform views.
22 // Platform views are not yet supported.
23 class FlutterCompositor {
24 public:
25 // Create a FlutterCompositor with a view provider.
26 //
27 // The view_provider is used to query FlutterViews from view IDs,
28 // which are used for presenting and creating backing stores.
29 // It must not be null, and is typically FlutterViewEngineProvider.
30 explicit FlutterCompositor(id<FlutterViewProvider> view_provider,
31 FlutterPlatformViewController* platform_views_controller);
32
33 ~FlutterCompositor() = default;
34
35 // Creates a backing store and saves updates the backing_store_out data with
36 // the new FlutterBackingStore data.
37 //
38 // If the backing store is being requested for the first time for a given
39 // frame, this compositor does not create a new backing store but rather
40 // returns the backing store associated with the FlutterView's
41 // FlutterSurfaceManager.
42 //
43 // Any additional state allocated for the backing store and saved as
44 // user_data in the backing store must be collected in the backing_store's
45 // destruction_callback field which will be called when the embedder collects
46 // the backing store.
47 bool CreateBackingStore(const FlutterBackingStoreConfig* config,
48 FlutterBackingStore* backing_store_out);
49
50 // Presents the FlutterLayers by updating the FlutterView specified by
51 // `view_id` using the layer content. Sets frame_started_ to false.
52 bool Present(FlutterViewId view_id, const FlutterLayer** layers, size_t layers_count);
53
54 private:
55 void PresentPlatformViews(FlutterView* default_base_view,
56 const FlutterLayer** layers,
57 size_t layers_count);
58
59 // Presents the platform view layer represented by `layer`. `layer_index` is
60 // used to position the layer in the z-axis. If the layer does not have a
61 // superview, it will become subview of `default_base_view`.
62 FlutterMutatorView* PresentPlatformView(FlutterView* default_base_view,
63 const FlutterLayer* layer,
64 size_t layer_position);
65
66 // Where the compositor can query FlutterViews. Must not be null.
67 id<FlutterViewProvider> const view_provider_;
68
69 // The controller used to manage creation and deletion of platform views.
70 const FlutterPlatformViewController* platform_view_controller_;
71
72 // Platform view to FlutterMutatorView that contains it.
73 NSMapTable<NSView*, FlutterMutatorView*>* mutator_views_;
74
75 FML_DISALLOW_COPY_AND_ASSIGN(FlutterCompositor);
76 };
77
78 } // namespace flutter
79
80 #endif // FLUTTER_COMPOSITOR_H_
FlutterMutatorView
Definition: FlutterMutatorView.h:11
flutter::FlutterCompositor::~FlutterCompositor
~FlutterCompositor()=default
FlutterPlatformViewController
Definition: FlutterPlatformViewController.h:14
FlutterPlatformViewController.h
FlutterViewProvider.h
flutter::FlutterCompositor
Definition: FlutterCompositor.h:23
flutter::FlutterCompositor::Present
bool Present(FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)
Definition: FlutterCompositor.mm:40
flutter::FlutterCompositor::CreateBackingStore
bool CreateBackingStore(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: FlutterCompositor.mm:20
flutter::FlutterCompositor::FlutterCompositor
FlutterCompositor(id< FlutterViewProvider > view_provider, FlutterPlatformViewController *platform_views_controller)
Definition: FlutterCompositor.mm:12
flutter
Definition: AccessibilityBridgeMac.h:16
FlutterView
Definition: FlutterView.h:39
FlutterViewId
int64_t FlutterViewId
Definition: FlutterView.h:12