mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Add PlatformView support for Fuchsia This change allows embedding views provided by fuchsia components into a flutter app running on Fuchsia. This conforms to Flutters idiomatic approach to composite PlatformView alongside other rendered layers. This uses the `view embedder` infrastructure to allow `PlatformViewLayer` to hold fuchsia views. This is meant to eventually supplant the legacy `SceneHost` and `ChildViewLayer` mechanism to embed fuchsia `ChildView`. To see how this will get used check out: https://fuchsia-review.googlesource.com/c/experiences/+/398536/6/examples/hello_experiences/lib/fuchsia_view.dart Includes unittests for platform_view.cc. Note: This change has no impact on the legacy code to embed fuchsia views. * Rename OnCreateViewMethodCall to OnCreateView Same for OnDestroyViewMethodCall to OnDestroyView Co-authored-by: Sanjay Chouksey <sanjayc@google.com>
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
// 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_COMPOSITOR_CONTEXT_H_
|
|
#define FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_
|
|
|
|
#include <fuchsia/ui/scenic/cpp/fidl.h>
|
|
#include <fuchsia/ui/views/cpp/fidl.h>
|
|
#include <lib/fit/function.h>
|
|
#include <lib/ui/scenic/cpp/view_ref_pair.h>
|
|
|
|
#include "flutter/flow/compositor_context.h"
|
|
#include "flutter/flow/embedded_views.h"
|
|
#include "flutter/fml/macros.h"
|
|
#include "session_connection.h"
|
|
|
|
namespace flutter_runner {
|
|
|
|
// Holds composition specific state and bindings specific to composition on
|
|
// Fuchsia.
|
|
class CompositorContext final : public flutter::CompositorContext {
|
|
public:
|
|
CompositorContext(std::string debug_label,
|
|
fuchsia::ui::views::ViewToken view_token,
|
|
scenic::ViewRefPair view_ref_pair,
|
|
fidl::InterfaceHandle<fuchsia::ui::scenic::Session> session,
|
|
fml::closure session_error_callback,
|
|
zx_handle_t vsync_event_handle);
|
|
|
|
~CompositorContext() override;
|
|
|
|
void OnSessionMetricsDidChange(const fuchsia::ui::gfx::Metrics& metrics);
|
|
void OnSessionSizeChangeHint(float width_change_factor,
|
|
float height_change_factor);
|
|
|
|
void OnWireframeEnabled(bool enabled);
|
|
void OnCreateView(int64_t view_id, bool hit_testable, bool focusable);
|
|
void OnDestroyView(int64_t view_id);
|
|
|
|
flutter::ExternalViewEmbedder* GetViewEmbedder() {
|
|
return &session_connection_.scene_update_context();
|
|
}
|
|
|
|
private:
|
|
const std::string debug_label_;
|
|
scenic::ViewRefPair view_ref_pair_;
|
|
SessionConnection session_connection_;
|
|
|
|
// |flutter::CompositorContext|
|
|
std::unique_ptr<ScopedFrame> AcquireFrame(
|
|
GrContext* gr_context,
|
|
SkCanvas* canvas,
|
|
flutter::ExternalViewEmbedder* view_embedder,
|
|
const SkMatrix& root_surface_transformation,
|
|
bool instrumentation_enabled,
|
|
bool surface_supports_readback,
|
|
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(CompositorContext);
|
|
};
|
|
|
|
} // namespace flutter_runner
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_COMPOSITOR_CONTEXT_H_
|