blob: 0709956326140d130a63365c1b011d0f1ac76084 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FLATLAND_PLATFORM_VIEW_H_
#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FLATLAND_PLATFORM_VIEW_H_
#include "flutter/shell/platform/fuchsia/flutter/platform_view.h"
#include <fuchsia/ui/composition/cpp/fidl.h>
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/shell/platform/fuchsia/flutter/flatland_external_view_embedder.h"
namespace flutter_runner {
using OnCreateFlatlandView = fit::function<
void(int64_t, ViewCallback, FlatlandViewCreatedCallback, bool, bool)>;
using OnDestroyFlatlandView =
fit::function<void(int64_t, FlatlandViewIdCallback)>;
// The FlatlandPlatformView that does Flatland specific...
class FlatlandPlatformView final : public flutter_runner::PlatformView {
public:
FlatlandPlatformView(
flutter::PlatformView::Delegate& delegate,
flutter::TaskRunners task_runners,
fuchsia::ui::views::ViewRef view_ref,
std::shared_ptr<flutter::ExternalViewEmbedder> external_view_embedder,
fidl::InterfaceHandle<fuchsia::ui::input::ImeService> ime_service,
fidl::InterfaceHandle<fuchsia::ui::input3::Keyboard> keyboard,
fidl::InterfaceHandle<fuchsia::ui::pointer::TouchSource> touch_source,
fidl::InterfaceHandle<fuchsia::ui::pointer::MouseSource> mouse_source,
fidl::InterfaceHandle<fuchsia::ui::views::Focuser> focuser,
fidl::InterfaceHandle<fuchsia::ui::views::ViewRefFocused>
view_ref_focused,
fidl::InterfaceHandle<fuchsia::ui::composition::ParentViewportWatcher>
parent_viewport_watcher,
OnEnableWireframe wireframe_enabled_callback,
OnCreateFlatlandView on_create_view_callback,
OnUpdateView on_update_view_callback,
OnDestroyFlatlandView on_destroy_view_callback,
OnCreateSurface on_create_surface_callback,
OnSemanticsNodeUpdate on_semantics_node_update_callback,
OnRequestAnnounce on_request_announce_callback,
OnShaderWarmup on_shader_warmup,
AwaitVsyncCallback await_vsync_callback,
AwaitVsyncForSecondaryCallbackCallback
await_vsync_for_secondary_callback_callback);
~FlatlandPlatformView() override;
void OnGetLayout(fuchsia::ui::composition::LayoutInfo info);
void OnParentViewportStatus(
fuchsia::ui::composition::ParentViewportStatus status);
void OnChildViewStatus(uint64_t content_id,
fuchsia::ui::composition::ChildViewStatus status);
private:
void OnCreateView(ViewCallback on_view_created,
int64_t view_id_raw,
bool hit_testable,
bool focusable) override;
void OnDisposeView(int64_t view_id_raw) override;
// child_view_ids_ maintains a persistent mapping from Flatland ContentId's to
// flutter view ids, which are really zx_handle_t of ViewCreationToken.
struct ChildViewInfo {
ChildViewInfo(zx_handle_t token,
fuchsia::ui::composition::ChildViewWatcherPtr watcher)
: view_id(token), child_view_watcher(std::move(watcher)) {}
zx_handle_t view_id;
fuchsia::ui::composition::ChildViewWatcherPtr child_view_watcher;
};
std::unordered_map<uint64_t /*fuchsia::ui::composition::ContentId*/,
ChildViewInfo>
child_view_info_;
fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher_;
OnCreateFlatlandView on_create_view_callback_;
OnDestroyFlatlandView on_destroy_view_callback_;
fuchsia::ui::composition::ParentViewportStatus parent_viewport_status_;
fml::WeakPtrFactory<FlatlandPlatformView>
weak_factory_; // Must be the last member.
FML_DISALLOW_COPY_AND_ASSIGN(FlatlandPlatformView);
};
} // namespace flutter_runner
#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FLATLAND_PLATFORM_VIEW_H_