Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
platform_view_embedder.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_PLATFORM_VIEW_EMBEDDER_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
7
8#include <functional>
9
10#include "flow/embedded_views.h"
11#include "flutter/fml/macros.h"
12#include "flutter/shell/common/platform_view.h"
13#include "flutter/shell/platform/embedder/embedder.h"
14#include "flutter/shell/platform/embedder/embedder_surface.h"
15#include "flutter/shell/platform/embedder/embedder_surface_software.h"
16#include "flutter/shell/platform/embedder/vsync_waiter_embedder.h"
17
18#ifdef SHELL_ENABLE_GL
19#include "flutter/shell/platform/embedder/embedder_surface_gl.h"
20#include "flutter/shell/platform/embedder/embedder_surface_gl_impeller.h"
21#endif
22
23#ifdef SHELL_ENABLE_METAL
24#include "flutter/shell/platform/embedder/embedder_surface_metal.h"
25#endif
26
27#ifdef SHELL_ENABLE_VULKAN
28#include "flutter/shell/platform/embedder/embedder_surface_vulkan.h"
29#endif
30
31namespace flutter {
32
33class PlatformViewEmbedder final : public PlatformView {
34 public:
36 std::function<void(flutter::SemanticsNodeUpdates update,
39 std::function<void(std::unique_ptr<PlatformMessage>)>;
41 std::function<std::unique_ptr<std::vector<std::string>>(
42 const std::vector<std::string>& supported_locale_data)>;
43 using OnPreEngineRestartCallback = std::function<void()>;
44 using ChanneUpdateCallback = std::function<void(const std::string&, bool)>;
45
56
57 // Create a platform view that sets up a software rasterizer.
59 PlatformView::Delegate& delegate,
60 const flutter::TaskRunners& task_runners,
62 software_dispatch_table,
63 PlatformDispatchTable platform_dispatch_table,
64 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
65
66#ifdef SHELL_ENABLE_GL
67 // Creates a platform view that sets up an OpenGL rasterizer.
69 PlatformView::Delegate& delegate,
70 const flutter::TaskRunners& task_runners,
71 std::unique_ptr<EmbedderSurface> embedder_surface,
72 PlatformDispatchTable platform_dispatch_table,
73 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
74#endif
75
76#ifdef SHELL_ENABLE_METAL
77 // Creates a platform view that sets up an metal rasterizer.
79 PlatformView::Delegate& delegate,
80 const flutter::TaskRunners& task_runners,
81 std::unique_ptr<EmbedderSurface> embedder_surface,
82 PlatformDispatchTable platform_dispatch_table,
83 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
84#endif
85
86#ifdef SHELL_ENABLE_VULKAN
87 // Creates a platform view that sets up an Vulkan rasterizer.
89 PlatformView::Delegate& delegate,
90 const flutter::TaskRunners& task_runners,
91 std::unique_ptr<EmbedderSurfaceVulkan> embedder_surface,
92 PlatformDispatchTable platform_dispatch_table,
93 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
94#endif
95
97
98 // |PlatformView|
99 void UpdateSemantics(
102
103 // |PlatformView|
104 void HandlePlatformMessage(std::unique_ptr<PlatformMessage> message) override;
105
106 // |PlatformView|
107 std::shared_ptr<PlatformMessageHandler> GetPlatformMessageHandler()
108 const override;
109
110 private:
112 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder_;
113 std::unique_ptr<EmbedderSurface> embedder_surface_;
114 std::shared_ptr<EmbedderPlatformMessageHandler> platform_message_handler_;
115 PlatformDispatchTable platform_dispatch_table_;
116
117 // |PlatformView|
118 std::unique_ptr<Surface> CreateRenderingSurface() override;
119
120 // |PlatformView|
121 std::shared_ptr<ExternalViewEmbedder> CreateExternalViewEmbedder() override;
122
123 // |PlatformView|
124 std::shared_ptr<impeller::Context> GetImpellerContext() const override;
125
126 // |PlatformView|
128
129 // |PlatformView|
130 std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override;
131
132 // |PlatformView|
133 void OnPreEngineRestart() const override;
134
135 // |PlatformView|
136 std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocales(
137 const std::vector<std::string>& supported_locale_data) override;
138
139 // |PlatformView|
140 void SendChannelUpdate(const std::string& name, bool listening) override;
141
143};
144
145} // namespace flutter
146
147#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
std::shared_ptr< ExternalViewEmbedder > CreateExternalViewEmbedder() override
std::function< void()> OnPreEngineRestartCallback
void HandlePlatformMessage(std::unique_ptr< PlatformMessage > message) override
Overridden by embedders to perform actions in response to platform messages sent from the framework t...
std::shared_ptr< impeller::Context > GetImpellerContext() const override
std::function< void(std::unique_ptr< PlatformMessage >)> PlatformMessageResponseCallback
std::unique_ptr< VsyncWaiter > CreateVSyncWaiter() override
Invoked by the shell to obtain a platform specific vsync waiter. It is optional for platforms to over...
std::function< std::unique_ptr< std::vector< std::string > >(const std::vector< std::string > &supported_locale_data)> ComputePlatformResolvedLocaleCallback
void UpdateSemantics(flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) override
Used by the framework to tell the embedder to apply the specified semantics node updates....
void OnPreEngineRestart() const override
Gives embedders a chance to react to a "cold restart" of the running isolate. The default implementat...
std::function< void(const std::string &, bool)> ChanneUpdateCallback
std::shared_ptr< PlatformMessageHandler > GetPlatformMessageHandler() const override
Specifies a delegate that will receive PlatformMessages from Flutter to the host platform.
std::unique_ptr< std::vector< std::string > > ComputePlatformResolvedLocales(const std::vector< std::string > &supported_locale_data) override
Directly invokes platform-specific APIs to compute the locale the platform would have natively resolv...
sk_sp< GrDirectContext > CreateResourceContext() const override
Used by the shell to obtain a Skia GPU context that is capable of operating on the IO thread....
void SendChannelUpdate(const std::string &name, bool listening) override
Used by the framework to tell the embedder that it has registered a listener on a given channel.
std::unique_ptr< Surface > CreateRenderingSurface() override
std::function< void(flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions)> UpdateSemanticsCallback
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
Platform views are created by the shell on the platform task runner. Unless explicitly specified,...
std::function< void(intptr_t)> VsyncCallback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
Win32Message message
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
DEF_SWITCHES_START aot vmservice shared library name
Definition switches.h:32
ComputePlatformResolvedLocaleCallback compute_platform_resolved_locale_callback
PlatformMessageResponseCallback platform_message_response_callback