1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_ 6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_ 7 8 #include <fuchsia/ui/scenic/cpp/fidl.h> 9 #include <fuchsia/ui/views/cpp/fidl.h> 10 #include <lib/fit/function.h> 11 12 #include "flutter/flow/compositor_context.h" 13 #include "flutter/flow/embedded_views.h" 14 #include "flutter/fml/macros.h" 15 #include "session_connection.h" 16 17 namespace flutter_runner { 18 19 // Holds composition specific state and bindings specific to composition on 20 // Fuchsia. 21 class CompositorContext final : public flutter::CompositorContext { 22 public: 23 CompositorContext(std::string debug_label, 24 fuchsia::ui::views::ViewToken view_token, 25 fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session, 26 fml::closure session_error_callback, 27 zx_handle_t vsync_event_handle); 28 29 ~CompositorContext() override; 30 31 void OnSessionMetricsDidChange(const fuchsia::ui::gfx::Metrics& metrics); 32 void OnSessionSizeChangeHint(float width_change_factor, 33 float height_change_factor); 34 35 private: 36 const std::string debug_label_; 37 SessionConnection session_connection_; 38 39 // |flutter::CompositorContext| 40 std::unique_ptr<ScopedFrame> AcquireFrame( 41 GrContext* gr_context, 42 SkCanvas* canvas, 43 flutter::ExternalViewEmbedder* view_embedder, 44 const SkMatrix& root_surface_transformation, 45 bool instrumentation_enabled, 46 fml::RefPtr<fml::GpuThreadMerger> gpu_thread_merger) override; 47 48 FML_DISALLOW_COPY_AND_ASSIGN(CompositorContext); 49 }; 50 51 } // namespace flutter_runner 52 53 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_ 54