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"
17
18#ifdef SHELL_ENABLE_GL
21#endif
22
23#ifdef SHELL_ENABLE_METAL
25#endif
26
27#ifdef SHELL_ENABLE_VULKAN
29#ifdef IMPELLER_SUPPORTS_RENDERING
31#endif // IMPELLER_SUPPORTS_RENDERING
32#endif
33
34namespace flutter {
35
36class PlatformViewEmbedder final : public PlatformView {
37 public:
39 std::function<void(int64_t view_id,
43 std::function<void(std::unique_ptr<PlatformMessage>)>;
45 std::function<std::unique_ptr<std::vector<std::string>>(
46 const std::vector<std::string>& supported_locale_data)>;
47 using OnPreEngineRestartCallback = std::function<void()>;
48 using ChanneUpdateCallback = std::function<void(const std::string&, bool)>;
50 std::function<void(const ViewFocusChangeRequest&)>;
51
64
65 // Create a platform view that sets up a software rasterizer.
67 PlatformView::Delegate& delegate,
68 const flutter::TaskRunners& task_runners,
70 software_dispatch_table,
71 PlatformDispatchTable platform_dispatch_table,
72 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
73
74#ifdef SHELL_ENABLE_GL
75 // Creates a platform view that sets up an OpenGL rasterizer.
77 PlatformView::Delegate& delegate,
78 const flutter::TaskRunners& task_runners,
79 std::unique_ptr<EmbedderSurface> embedder_surface,
80 PlatformDispatchTable platform_dispatch_table,
81 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
82#endif
83
84#ifdef SHELL_ENABLE_METAL
85 // Creates a platform view that sets up an metal rasterizer.
87 PlatformView::Delegate& delegate,
88 const flutter::TaskRunners& task_runners,
89 std::unique_ptr<EmbedderSurface> embedder_surface,
90 PlatformDispatchTable platform_dispatch_table,
91 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
92#endif
93
94#ifdef SHELL_ENABLE_VULKAN
95 // Creates a platform view that sets up an Vulkan rasterizer.
97 PlatformView::Delegate& delegate,
98 const flutter::TaskRunners& task_runners,
99 std::unique_ptr<EmbedderSurfaceVulkan> embedder_surface,
100 PlatformDispatchTable platform_dispatch_table,
101 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
102#endif
103
105
106 // |PlatformView|
107 void UpdateSemantics(
108 int64_t view_id,
111
112 // |PlatformView|
113 void HandlePlatformMessage(std::unique_ptr<PlatformMessage> message) override;
114
115 // |PlatformView|
116 std::shared_ptr<PlatformMessageHandler> GetPlatformMessageHandler()
117 const override;
118
119 private:
121 std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder_;
122 std::unique_ptr<EmbedderSurface> embedder_surface_;
123 std::shared_ptr<EmbedderPlatformMessageHandler> platform_message_handler_;
124 PlatformDispatchTable platform_dispatch_table_;
125
126 // |PlatformView|
127 std::unique_ptr<Surface> CreateRenderingSurface() override;
128
129 // |PlatformView|
130 std::shared_ptr<ExternalViewEmbedder> CreateExternalViewEmbedder() override;
131
132 // |PlatformView|
133 std::shared_ptr<impeller::Context> GetImpellerContext() const override;
134
135 // |PlatformView|
136 sk_sp<GrDirectContext> CreateResourceContext() const override;
137
138 // |PlatformView|
139 std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override;
140
141 // |PlatformView|
142 void OnPreEngineRestart() const override;
143
144 // |PlatformView|
145 std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocales(
146 const std::vector<std::string>& supported_locale_data) override;
147
148 // |PlatformView|
149 void SendChannelUpdate(const std::string& name, bool listening) override;
150
151 // |PlatformView|
152 void RequestViewFocusChange(const ViewFocusChangeRequest& request) override;
153
155};
156
157} // namespace flutter
158
159#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
void UpdateSemantics(int64_t view_id, flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) override
Used by the framework to tell the embedder to apply the specified semantics node updates....
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::function< void(int64_t view_id, flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions)> UpdateSemanticsCallback
std::function< void(std::unique_ptr< PlatformMessage >)> PlatformMessageResponseCallback
std::function< std::unique_ptr< std::vector< std::string > >(const std::vector< std::string > &supported_locale_data)> ComputePlatformResolvedLocaleCallback
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::function< void(const ViewFocusChangeRequest &)> ViewFocusChangeRequestCallback
Platform views are created by the shell on the platform task runner. Unless explicitly specified,...
std::function< void(intptr_t)> VsyncCallback
G_BEGIN_DECLS GBytes * message
G_BEGIN_DECLS FlutterViewId view_id
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
ComputePlatformResolvedLocaleCallback compute_platform_resolved_locale_callback
PlatformMessageResponseCallback platform_message_response_callback