// 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_EMBEDDER_EMBEDDER_ENGINE_H_ #define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_ENGINE_H_ #include #include #include "flutter/fml/macros.h" #include "flutter/shell/common/shell.h" #include "flutter/shell/common/thread_host.h" #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/embedder/embedder_engine.h" #include "flutter/shell/platform/embedder/embedder_external_texture_gl.h" #include "flutter/shell/platform/embedder/embedder_thread_host.h" namespace flutter { // The object that is returned to the embedder as an opaque pointer to the // instance of the Flutter engine. class EmbedderEngine { public: using IdleCallback = std::function; EmbedderEngine(std::unique_ptr thread_host, flutter::TaskRunners task_runners, flutter::Settings settings, Shell::CreateCallback on_create_platform_view, Shell::CreateCallback on_create_rasterizer, EmbedderExternalTextureGL::ExternalTextureCallback external_texture_callback); ~EmbedderEngine(); const TaskRunners& GetTaskRunners() const; bool NotifyCreated(); bool NotifyDestroyed(); bool Run(RunConfiguration run_configuration); bool IsValid() const; bool SetIdleNotificationCallback(const IdleCallback& idle_notification_callback); bool SetViewportMetrics(flutter::ViewportMetrics metrics); bool DispatchPointerDataPacket( std::unique_ptr packet); bool SendPlatformMessage(fml::RefPtr message); bool RegisterTexture(int64_t texture); bool UnregisterTexture(int64_t texture); bool MarkTextureFrameAvailable(int64_t texture); bool OnVsyncEvent(intptr_t baton, fml::TimePoint frame_start_time, fml::TimePoint frame_target_time); bool PostRenderThreadTask(fml::closure task); bool RunTask(const FlutterTask* task); private: const std::unique_ptr thread_host_; TaskRunners task_runners_; std::unique_ptr shell_; const EmbedderExternalTextureGL::ExternalTextureCallback external_texture_callback_; bool is_valid_ = false; FML_DISALLOW_COPY_AND_ASSIGN(EmbedderEngine); }; } // namespace flutter #endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_ENGINE_H_