|
22 | 22 | #include "flutter/runtime/runtime_controller.h" |
23 | 23 | #include "flutter/runtime/runtime_delegate.h" |
24 | 24 | #include "flutter/shell/common/animator.h" |
| 25 | +#include "flutter/shell/common/platform_view.h" |
| 26 | +#include "flutter/shell/common/pointer_data_dispatcher.h" |
25 | 27 | #include "flutter/shell/common/rasterizer.h" |
26 | 28 | #include "flutter/shell/common/run_configuration.h" |
27 | 29 | #include "flutter/shell/common/shell_io_manager.h" |
@@ -65,7 +67,7 @@ namespace flutter { |
65 | 67 | /// name and it does happen to be one of the older classes in the |
66 | 68 | /// repository. |
67 | 69 | /// |
68 | | -class Engine final : public RuntimeDelegate { |
| 70 | +class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { |
69 | 71 | public: |
70 | 72 | //---------------------------------------------------------------------------- |
71 | 73 | /// @brief Indicates the result of the call to `Engine::Run`. |
@@ -234,6 +236,12 @@ class Engine final : public RuntimeDelegate { |
234 | 236 | /// tasks that require access to components |
235 | 237 | /// that cannot be safely accessed by the |
236 | 238 | /// engine. This is the shell. |
| 239 | + /// @param dispatcher_maker The callback provided by `PlatformView` for |
| 240 | + /// engine to create the pointer data |
| 241 | + /// dispatcher. Similar to other engine |
| 242 | + /// resources, this dispatcher_maker and its |
| 243 | + /// returned dispatcher is only safe to be |
| 244 | + /// called from the UI thread. |
237 | 245 | /// @param vm An instance of the running Dart VM. |
238 | 246 | /// @param[in] isolate_snapshot The snapshot used to create the root |
239 | 247 | /// isolate. Even though the isolate is not |
@@ -265,6 +273,7 @@ class Engine final : public RuntimeDelegate { |
265 | 273 | /// GPU. |
266 | 274 | /// |
267 | 275 | Engine(Delegate& delegate, |
| 276 | + const PointerDataDispatcherMaker& dispatcher_maker, |
268 | 277 | DartVM& vm, |
269 | 278 | fml::RefPtr<const DartSnapshot> isolate_snapshot, |
270 | 279 | fml::RefPtr<const DartSnapshot> shared_snapshot, |
@@ -649,7 +658,7 @@ class Engine final : public RuntimeDelegate { |
649 | 658 | /// timeline and allow grouping frames and input |
650 | 659 | /// events into logical chunks. |
651 | 660 | /// |
652 | | - void DispatchPointerDataPacket(const PointerDataPacket& packet, |
| 661 | + void DispatchPointerDataPacket(std::unique_ptr<PointerDataPacket> packet, |
653 | 662 | uint64_t trace_flow_id); |
654 | 663 |
|
655 | 664 | //---------------------------------------------------------------------------- |
@@ -700,18 +709,32 @@ class Engine final : public RuntimeDelegate { |
700 | 709 | // |RuntimeDelegate| |
701 | 710 | FontCollection& GetFontCollection() override; |
702 | 711 |
|
| 712 | + // |PointerDataDispatcher::Delegate| |
| 713 | + void DoDispatchPacket(std::unique_ptr<PointerDataPacket> packet, |
| 714 | + uint64_t trace_flow_id) override; |
| 715 | + |
| 716 | + // |PointerDataDispatcher::Delegate| |
| 717 | + void ScheduleSecondaryVsyncCallback(fml::closure callback) override; |
| 718 | + |
703 | 719 | private: |
704 | 720 | Engine::Delegate& delegate_; |
705 | 721 | const Settings settings_; |
706 | 722 | std::unique_ptr<Animator> animator_; |
707 | 723 | std::unique_ptr<RuntimeController> runtime_controller_; |
| 724 | + |
| 725 | + // The pointer_data_dispatcher_ depends on animator_ and runtime_controller_. |
| 726 | + // So it should be defined after them to ensure that pointer_data_dispatcher_ |
| 727 | + // is destructed first. |
| 728 | + std::unique_ptr<PointerDataDispatcher> pointer_data_dispatcher_; |
| 729 | + |
708 | 730 | std::string initial_route_; |
709 | 731 | ViewportMetrics viewport_metrics_; |
710 | 732 | std::shared_ptr<AssetManager> asset_manager_; |
711 | 733 | bool activity_running_; |
712 | 734 | bool have_surface_; |
713 | 735 | FontCollection font_collection_; |
714 | 736 | ImageDecoder image_decoder_; |
| 737 | + TaskRunners task_runners_; |
715 | 738 | fml::WeakPtrFactory<Engine> weak_factory_; |
716 | 739 |
|
717 | 740 | // |RuntimeDelegate| |
|
0 commit comments