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.h"
20 #endif
21 
22 #ifdef SHELL_ENABLE_METAL
23 #include "flutter/shell/platform/embedder/embedder_surface_metal.h"
24 #endif
25 
26 namespace flutter {
27 
28 class PlatformViewEmbedder final : public PlatformView {
29  public:
31  std::function<void(flutter::SemanticsNodeUpdates update)>;
33  std::function<void(flutter::CustomAccessibilityActionUpdates actions)>;
35  std::function<void(std::unique_ptr<PlatformMessage>)>;
37  std::function<std::unique_ptr<std::vector<std::string>>(
38  const std::vector<std::string>& supported_locale_data)>;
39  using OnPreEngineRestartCallback = std::function<void()>;
40 
51  };
52 
53  // Create a platform view that sets up a software rasterizer.
55  PlatformView::Delegate& delegate,
56  flutter::TaskRunners task_runners,
57  EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table,
58  PlatformDispatchTable platform_dispatch_table,
59  std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
60 
61 #ifdef SHELL_ENABLE_GL
62  // Creates a platform view that sets up an OpenGL rasterizer.
64  PlatformView::Delegate& delegate,
65  flutter::TaskRunners task_runners,
66  EmbedderSurfaceGL::GLDispatchTable gl_dispatch_table,
67  bool fbo_reset_after_present,
68  PlatformDispatchTable platform_dispatch_table,
69  std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
70 #endif
71 
72 #ifdef SHELL_ENABLE_METAL
73  // Creates a platform view that sets up an metal rasterizer.
75  PlatformView::Delegate& delegate,
76  flutter::TaskRunners task_runners,
77  std::unique_ptr<EmbedderSurfaceMetal> embedder_surface,
78  PlatformDispatchTable platform_dispatch_table,
79  std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
80 #endif
81 
82  ~PlatformViewEmbedder() override;
83 
84  // |PlatformView|
85  void UpdateSemantics(
88 
89  // |PlatformView|
90  void HandlePlatformMessage(std::unique_ptr<PlatformMessage> message) override;
91 
92  private:
93  std::shared_ptr<EmbedderExternalViewEmbedder> external_view_embedder_;
94  std::unique_ptr<EmbedderSurface> embedder_surface_;
95  PlatformDispatchTable platform_dispatch_table_;
96 
97  // |PlatformView|
98  std::unique_ptr<Surface> CreateRenderingSurface() override;
99 
100  // |PlatformView|
101  std::shared_ptr<ExternalViewEmbedder> CreateExternalViewEmbedder() override;
102 
103  // |PlatformView|
104  sk_sp<GrDirectContext> CreateResourceContext() const override;
105 
106  // |PlatformView|
107  std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override;
108 
109  // |PlatformView|
110  void OnPreEngineRestart() const override;
111 
112  // |PlatformView|
113  std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocales(
114  const std::vector<std::string>& supported_locale_data) override;
115 
117 };
118 
119 } // namespace flutter
120 
121 #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_PLATFORM_VIEW_EMBEDDER_H_
std::function< void()> OnPreEngineRestartCallback
ComputePlatformResolvedLocaleCallback compute_platform_resolved_locale_callback
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
Platform views are created by the shell on the platform task runner. Unless explicitly specified...
Definition: platform_view.h:47
void UpdateSemantics(flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) override
Used by the framework to tell the embedder to apply the specified semantics node updates. The default implementation of this method does nothing.
PlatformMessageResponseCallback platform_message_response_callback
PlatformViewEmbedder(PlatformView::Delegate &delegate, flutter::TaskRunners task_runners, EmbedderSurfaceSoftware::SoftwareDispatchTable software_dispatch_table, PlatformDispatchTable platform_dispatch_table, std::shared_ptr< EmbedderExternalViewEmbedder > external_view_embedder)
UpdateSemanticsCustomActionsCallback update_semantics_custom_actions_callback
std::function< void(flutter::CustomAccessibilityActionUpdates actions)> UpdateSemanticsCustomActionsCallback
std::function< void(std::unique_ptr< PlatformMessage >)> PlatformMessageResponseCallback
std::function< void(flutter::SemanticsNodeUpdates update)> UpdateSemanticsNodesCallback
std::function< void(intptr_t)> VsyncCallback
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::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: macros.h:27
Used to forward events from the platform view to interested subsystems. This forwarding is done by th...
Definition: platform_view.h:54
std::function< std::unique_ptr< std::vector< std::string > >(const std::vector< std::string > &supported_locale_data)> ComputePlatformResolvedLocaleCallback