// 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_FLOW_VIEW_HOLDER_H_ #define FLUTTER_FLOW_VIEW_HOLDER_H_ #include #include #include #include #include #include #include #include #include #include "flutter/flow/scene_update_context.h" #include "flutter/fml/macros.h" #include "flutter/fml/memory/ref_counted.h" #include "flutter/fml/task_runner.h" namespace flow { // Represents a Scenic |ViewHolder| resource that imports a |View| from another // session. // // This object is created and destroyed on the |Rasterizer|'s thread. class ViewHolder { public: using BindCallback = std::function; static void Create(zx_koid_t id, fml::RefPtr ui_task_runner, fuchsia::ui::views::ViewHolderToken view_holder_token, BindCallback on_bind_callback); static void Destroy(zx_koid_t id); static ViewHolder* FromId(zx_koid_t id); // Sets the properties of the child view by issuing a Scenic command. void SetProperties(double width, double height, double insetTop, double insetRight, double insetBottom, double insetLeft, bool focusable); // Creates or updates the contained ViewHolder resource using the specified // |SceneUpdateContext|. void UpdateScene(SceneUpdateContext& context, const SkPoint& offset, const SkSize& size, bool hit_testable); private: ViewHolder(fml::RefPtr ui_task_runner, fuchsia::ui::views::ViewHolderToken view_holder_token, BindCallback on_bind_callback); fuchsia::ui::gfx::ViewProperties pending_properties_; fuchsia::ui::views::ViewHolderToken pending_view_holder_token_; fml::RefPtr ui_task_runner_; std::unique_ptr entity_node_; std::unique_ptr view_holder_; BindCallback pending_bind_callback_; bool has_pending_properties_ = false; FML_DISALLOW_COPY_AND_ASSIGN(ViewHolder); }; } // namespace flow #endif // FLUTTER_FLOW_VIEW_HOLDER_H_