5#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_POINTER_INJECTOR_DELEGATE_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_POINTER_INJECTOR_DELEGATE_H_
8#include <fuchsia/ui/pointerinjector/cpp/fidl.h>
9#include <fuchsia/ui/views/cpp/fidl.h>
12#include <unordered_map>
15#include "flutter/fml/macros.h"
16#include "flutter/fml/memory/weak_ptr.h"
17#include "flutter/lib/ui/window/platform_message.h"
18#include "third_party/rapidjson/include/rapidjson/document.h"
28 "View.pointerinjector.inject";
31 fuchsia::ui::views::ViewRef host_view_ref)
32 : registry_(
std::make_shared<
fuchsia::
ui::pointerinjector::RegistryPtr>(
34 host_view_ref_(
std::make_shared<
fuchsia::
ui::views::ViewRef>(
35 std::move(host_view_ref))) {}
42 rapidjson::Value request,
49 std::optional<fuchsia::ui::views::ViewRef> view_ref = std::nullopt);
56 using ViewId = int64_t;
58 struct PointerInjectorRequest {
60 float x = 0.f,
y = 0.f;
63 uint32_t pointer_id = 0;
66 fuchsia::ui::pointerinjector::EventPhase phase =
70 uint64_t trace_flow_id = 0;
73 std::array<float, 2> logical_size = {0.f, 0.f};
76 zx_time_t timestamp = 0;
83 class PointerInjectorEndpoint {
85 PointerInjectorEndpoint(
86 std::shared_ptr<fuchsia::ui::pointerinjector::RegistryPtr> registry,
87 std::shared_ptr<fuchsia::ui::views::ViewRef> host_view_ref,
88 std::optional<fuchsia::ui::views::ViewRef> view_ref)
89 : registry_(
std::move(registry)),
90 host_view_ref_(
std::move(host_view_ref)),
95 device_.set_error_handler(
96 [weak = weak_factory_.GetWeakPtr()](
auto status) {
98 <<
"fuchsia.ui.pointerinjector.Device closed " << status;
112 void InjectEvent(PointerInjectorRequest request);
121 void RegisterInjector(
const PointerInjectorRequest& request);
125 void DispatchPendingEvents();
138 bool injection_in_flight_ =
false;
142 bool registered_ =
false;
144 std::shared_ptr<fuchsia::ui::pointerinjector::RegistryPtr> registry_;
147 std::shared_ptr<fuchsia::ui::views::ViewRef> host_view_ref_;
151 std::optional<fuchsia::ui::views::ViewRef>
view_ref_;
153 fuchsia::ui::pointerinjector::DevicePtr device_;
159 std::queue<std::vector<fuchsia::ui::pointerinjector::Event>>
165 FML_DISALLOW_COPY_AND_ASSIGN(PointerInjectorEndpoint);
175 PointerInjectorRequest request);
179 std::unordered_map<ViewId, PointerInjectorEndpoint> valid_views_;
181 std::shared_ptr<fuchsia::ui::pointerinjector::RegistryPtr> registry_;
184 std::shared_ptr<fuchsia::ui::views::ViewRef> host_view_ref_;
GrAATriangulator::Event Event
PointerInjectorDelegate(fuchsia::ui::pointerinjector::RegistryHandle registry, fuchsia::ui::views::ViewRef host_view_ref)
bool HandlePlatformMessage(rapidjson::Value request, fml::RefPtr< flutter::PlatformMessageResponse > response)
static constexpr auto kPointerInjectorMethodPrefix
void OnDestroyView(uint64_t view_id)
void OnCreateView(uint64_t view_id, std::optional< fuchsia::ui::views::ViewRef > view_ref=std::nullopt)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
static bool Bind(PassBindingsCacheMTL &pass, ShaderStage stage, size_t bind_index, const BufferView &view)