Flutter Engine
The Flutter Engine
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_impeller.h"
20#include "flutter/shell/platform/embedder/embedder_surface_gl_skia.h"
21#endif
22
23#ifdef SHELL_ENABLE_METAL
24#include "flutter/shell/platform/embedder/embedder_surface_metal_skia.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:
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)>;
44 using ChanneUpdateCallback = std::function<void(const std::string&, bool)>;
45
55 };
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|
127 sk_sp<GrDirectContext> CreateResourceContext() const override;
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::function< void()> OnPreEngineRestartCallback
PlatformViewEmbedder(PlatformView::Delegate &delegate, const flutter::TaskRunners &task_runners, const EmbedderSurfaceSoftware::SoftwareDispatchTable &software_dispatch_table, PlatformDispatchTable platform_dispatch_table, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
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(std::unique_ptr< PlatformMessage >)> PlatformMessageResponseCallback
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....
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(flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions)> UpdateSemanticsCallback
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
Definition: platform_view.h:60
Platform views are created by the shell on the platform task runner. Unless explicitly specified,...
Definition: platform_view.h:51
std::function< void(intptr_t)> VsyncCallback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
Dart_NativeFunction function
Definition: fuchsia.cc:51
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
Definition: update.py:1
ComputePlatformResolvedLocaleCallback compute_platform_resolved_locale_callback
PlatformMessageResponseCallback platform_message_response_callback