| // Copyright 2018 The Fuchsia 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 SRC_UI_EXAMPLES_EMBEDDER_APP_H_ | |
| #define SRC_UI_EXAMPLES_EMBEDDER_APP_H_ | |
| #include <fuchsia/sys/cpp/fidl.h> | |
| #include <fuchsia/ui/app/cpp/fidl.h> | |
| #include <fuchsia/ui/scenic/cpp/fidl.h> | |
| #include <lib/async-loop/cpp/loop.h> | |
| #include <lib/async-loop/default.h> | |
| #include <lib/fidl/cpp/binding_set.h> | |
| #include <lib/sys/cpp/component_context.h> | |
| #include <lib/ui/scenic/cpp/resources.h> | |
| #include <lib/ui/scenic/cpp/session.h> | |
| namespace embedder { | |
| enum class AppType : unsigned char { CONTAINER, SUBVIEW }; | |
| class App : public fuchsia::sys::ServiceProvider { | |
| public: | |
| App(async::Loop* loop, AppType type); | |
| ~App(); | |
| App(const App&) = delete; | |
| App& operator=(const App&) = delete; | |
| // |sys::ServiceProvider| | |
| void ConnectToService(std::string service_name, zx::channel channel) {} | |
| private: | |
| // Called asynchronously when the session dies. | |
| void ReleaseSessionResources(); | |
| // Updates and presents the scene. Called first by Init(). Each invocation | |
| // schedules another call to Update() when the result of the previous | |
| // presentation is asynchronously received. | |
| void Update(uint64_t next_presentation_time); | |
| // Creates all of the scene resources and sets up the scene graph. | |
| void CreateScene(float display_width, float display_height); | |
| std::unique_ptr<sys::ComponentContext> component_context_; | |
| async::Loop* const loop_; | |
| AppType type_; | |
| fidl::BindingSet<fuchsia::sys::ServiceProvider> service_bindings_; | |
| fuchsia::sys::ServiceProviderPtr incoming_services_; | |
| fuchsia::ui::app::ViewProviderPtr view_provider_; | |
| std::unique_ptr<fuchsia::ui::app::ViewProvider> view_provider_impl_; | |
| fuchsia::ui::scenic::ScenicPtr scenic_; | |
| std::unique_ptr<scenic::Session> session_; | |
| std::unique_ptr<scenic::DisplayCompositor> compositor_; | |
| std::unique_ptr<scenic::Camera> camera_; | |
| uint32_t view_id_ = 0; | |
| uint32_t root_node_id_ = 0; | |
| }; | |
| } // namespace embedder | |
| #endif // SRC_UI_EXAMPLES_EMBEDDER_APP_H_ |