Flutter Engine
embedder_engine.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_SHELL_PLATFORM_EMBEDDER_EMBEDDER_ENGINE_H_
6 #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_ENGINE_H_
7 
8 #include <memory>
9 #include <unordered_map>
10 
11 #include "flutter/fml/macros.h"
12 #include "flutter/shell/common/shell.h"
13 #include "flutter/shell/common/thread_host.h"
14 #include "flutter/shell/platform/embedder/embedder.h"
15 #include "flutter/shell/platform/embedder/embedder_external_texture_resolver.h"
16 #include "flutter/shell/platform/embedder/embedder_thread_host.h"
17 namespace flutter {
18 
19 struct ShellArgs;
20 
21 // The object that is returned to the embedder as an opaque pointer to the
22 // instance of the Flutter engine.
24  public:
25  EmbedderEngine(std::unique_ptr<EmbedderThreadHost> thread_host,
26  TaskRunners task_runners,
27  Settings settings,
28  RunConfiguration run_configuration,
29  Shell::CreateCallback<PlatformView> on_create_platform_view,
30  Shell::CreateCallback<Rasterizer> on_create_rasterizer,
31  std::unique_ptr<EmbedderExternalTextureResolver>
32  external_texture_resolver);
33 
35 
36  bool LaunchShell();
37 
38  bool CollectShell();
39 
40  const TaskRunners& GetTaskRunners() const;
41 
42  bool NotifyCreated();
43 
44  bool NotifyDestroyed();
45 
46  bool RunRootIsolate();
47 
48  bool IsValid() const;
49 
51 
53  std::unique_ptr<flutter::PointerDataPacket> packet);
54 
55  //----------------------------------------------------------------------------
56  /// @brief Notifies the platform view that the embedder has sent it a key
57  /// data packet. A key data packet contains one key event. This
58  /// call originates in the platform view and the shell has
59  /// forwarded the same to the engine on the UI task runner here.
60  /// The platform view will decide whether to handle this event,
61  /// and send the result using `callback`, which will be called
62  /// exactly once.
63  ///
64  /// @param[in] packet The key data packet.
65  /// @param[in] callback Called when the framework has decided whether
66  /// to handle this key data.
67  ///
68  bool DispatchKeyDataPacket(std::unique_ptr<flutter::KeyDataPacket> packet,
70 
71  bool SendPlatformMessage(std::unique_ptr<PlatformMessage> message);
72 
73  bool RegisterTexture(int64_t texture);
74 
75  bool UnregisterTexture(int64_t texture);
76 
77  bool MarkTextureFrameAvailable(int64_t texture);
78 
79  bool SetSemanticsEnabled(bool enabled);
80 
81  bool SetAccessibilityFeatures(int32_t flags);
82 
83  bool DispatchSemanticsAction(int id,
86 
87  bool OnVsyncEvent(intptr_t baton,
88  fml::TimePoint frame_start_time,
89  fml::TimePoint frame_target_time);
90 
91  bool ReloadSystemFonts();
92 
93  bool PostRenderThreadTask(const fml::closure& task);
94 
95  bool RunTask(const FlutterTask* task);
96 
99 
100  Shell& GetShell();
101 
102  private:
103  const std::unique_ptr<EmbedderThreadHost> thread_host_;
104  TaskRunners task_runners_;
105  RunConfiguration run_configuration_;
106  std::unique_ptr<ShellArgs> shell_args_;
107  std::unique_ptr<Shell> shell_;
108  std::unique_ptr<EmbedderExternalTextureResolver> external_texture_resolver_;
109 
110  FML_DISALLOW_COPY_AND_ASSIGN(EmbedderEngine);
111 };
112 
113 } // namespace flutter
114 
115 #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_ENGINE_H_
G_BEGIN_DECLS FlValue * args
bool DispatchPointerDataPacket(std::unique_ptr< flutter::PointerDataPacket > packet)
G_BEGIN_DECLS FlTexture * texture
std::function< std::unique_ptr< T >(Shell &)> CreateCallback
Definition: shell.h:114
bool RunTask(const FlutterTask *task)
Dart_NativeFunction function
Definition: fuchsia.cc:51
bool SetViewportMetrics(flutter::ViewportMetrics metrics)
FlKeyEvent FlKeyResponderAsyncCallback callback
bool OnVsyncEvent(intptr_t baton, fml::TimePoint frame_start_time, fml::TimePoint frame_target_time)
bool SetAccessibilityFeatures(int32_t flags)
bool PostTaskOnEngineManagedNativeThreads(std::function< void(FlutterNativeThreadType)> closure) const
std::function< void()> closure
Definition: closure.h:14
Specifies all the configuration required by the runtime library to launch the root isolate...
SemanticsAction action
EmbedderEngine(std::unique_ptr< EmbedderThreadHost > thread_host, TaskRunners task_runners, Settings settings, RunConfiguration run_configuration, Shell::CreateCallback< PlatformView > on_create_platform_view, Shell::CreateCallback< Rasterizer > on_create_rasterizer, std::unique_ptr< EmbedderExternalTextureResolver > external_texture_resolver)
bool SetSemanticsEnabled(bool enabled)
bool SendPlatformMessage(std::unique_ptr< PlatformMessage > message)
bool RegisterTexture(int64_t texture)
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition: mapping.h:129
bool UnregisterTexture(int64_t texture)
std::function< void(bool)> KeyDataResponse
FlutterNativeThreadType
Definition: embedder.h:1296
bool PostRenderThreadTask(const fml::closure &task)
bool DispatchSemanticsAction(int id, flutter::SemanticsAction action, fml::MallocMapping args)
const TaskRunners & GetTaskRunners() const
bool DispatchKeyDataPacket(std::unique_ptr< flutter::KeyDataPacket > packet, KeyDataResponse callback)
Notifies the platform view that the embedder has sent it a key data packet. A key data packet contain...
DEF_SWITCHES_START snapshot asset Path to the directory containing the four files specified by VmSnapshotInstructions and IsolateSnapshotInstructions vm snapshot The VM instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present isolate snapshot The isolate instructions snapshot that will be memory mapped as read and executable SnapshotAssetPath must be present icu symbol Prefix for the symbols representing ICU data linked into the Flutter library dart flags
Definition: switches.h:66
bool MarkTextureFrameAvailable(int64_t texture)