5#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_EXTERNAL_VIEW_EMBEDDER_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_EXTERNAL_VIEW_EMBEDDER_H_
8#include <fuchsia/ui/composition/cpp/fidl.h>
9#include <fuchsia/ui/views/cpp/fidl.h>
10#include <lib/fit/function.h>
15#include <unordered_map>
18#include "flutter/flow/embedded_views.h"
19#include "flutter/fml/logging.h"
20#include "flutter/fml/macros.h"
21#include "flutter/shell/platform/fuchsia/flutter/canvas_spy.h"
22#include "flutter/shell/platform/fuchsia/flutter/rtree.h"
36 fuchsia::ui::composition::ContentId,
37 fuchsia::ui::composition::ChildViewWatcherHandle child_view_watcher)>;
48 fuchsia::ui::views::ViewCreationToken view_creation_token,
49 fuchsia::ui::views::ViewIdentityOnCreation view_identity,
50 fuchsia::ui::composition::ViewBoundProtocols endpoints,
51 fidl::InterfaceRequest<fuchsia::ui::composition::ParentViewportWatcher>
52 parent_viewport_watcher_request,
53 std::shared_ptr<FlatlandConnection> flatland,
54 std::shared_ptr<SurfaceProducer> surface_producer,
55 bool intercept_all_input =
false);
64 std::unique_ptr<flutter::EmbeddedViewParams>
params)
override;
77 raster_thread_merger)
override;
81 double device_pixel_ratio)
override;
84 void EndFrame(
bool should_resubmit_frame,
86 raster_thread_merger)
override;
90 int64_t flutter_view_id,
92 const std::shared_ptr<impeller::AiksContext>& aiks_context,
93 std::unique_ptr<flutter::SurfaceFrame>
frame)
override;
109 const SkRect& occlusion_hint,
116 std::vector<fuchsia::ui::composition::TransformId>
children;
123 struct TransformedClip {
127 bool operator==(
const TransformedClip& other)
const {
134 struct ViewMutators {
135 std::vector<TransformedClip> clips;
140 bool operator==(
const ViewMutators& other)
const {
141 return clips == other.clips && total_transform == other.total_transform &&
142 transform == other.transform && opacity == other.opacity;
148 struct EmbedderLayer {
149 EmbedderLayer(
const SkISize& frame_size,
150 std::optional<flutter::EmbeddedViewParams> view_params,
152 : rtree(rtree_factory.getInstance()),
153 embedded_view_params(
std::move(view_params)),
155 canvas_spy(
std::make_unique<
flutter::CanvasSpy>(
156 recorder->beginRecording(
SkRect::
Make(frame_size),
158 surface_size(frame_size),
168 std::optional<flutter::EmbeddedViewParams> embedded_view_params;
169 std::unique_ptr<SkPictureRecorder> recorder;
172 std::unique_ptr<flutter::CanvasSpy> canvas_spy;
176 using EmbedderLayerId = std::optional<uint32_t>;
177 constexpr static EmbedderLayerId kRootLayerId = EmbedderLayerId{};
180 std::vector<ClipTransform> clip_transforms;
181 fuchsia::ui::composition::TransformId transform_id;
182 fuchsia::ui::composition::ContentId viewport_id;
183 ViewMutators mutators;
188 pending_create_viewport_callback;
193 fuchsia::ui::composition::TransformId transform_id;
196 std::shared_ptr<FlatlandConnection> flatland_;
197 std::shared_ptr<SurfaceProducer> surface_producer_;
199 fuchsia::ui::composition::ParentViewportWatcherPtr parent_viewport_watcher_;
201 fuchsia::ui::composition::TransformId root_transform_id_;
203 std::unordered_map<int64_t, View> views_;
204 std::vector<Layer> layers_;
206 std::unordered_map<EmbedderLayerId, EmbedderLayer> frame_layers_;
207 std::vector<EmbedderLayerId> frame_composition_order_;
208 std::vector<fuchsia::ui::composition::TransformId> child_transforms_;
210 float frame_dpr_ = 1.f;
214 std::optional<fuchsia::ui::composition::TransformId>
215 input_interceptor_transform_;
static const SkMatrix & I()
Developer-facing API for rendering anything within the engine.
ExternalViewEmbedder()=default
void EndFrame(bool should_resubmit_frame, const fml::RefPtr< fml::RasterThreadMerger > &raster_thread_merger) override
flutter::PostPrerollResult PostPrerollAction(const fml::RefPtr< fml::RasterThreadMerger > &raster_thread_merger) override
void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override
static constexpr uint32_t kDefaultViewportSize
void DestroyView(int64_t view_id, ViewIdCallback on_view_unbound)
void CreateView(int64_t view_id, ViewCallback on_view_created, ViewCreatedCallback on_view_bound)
bool SupportsDynamicThreadMerging() override
flutter::DlCanvas * CompositeEmbeddedView(int64_t view_id) override
flutter::DlCanvas * GetRootCanvas() override
void SubmitFlutterView(int64_t flutter_view_id, GrDirectContext *context, const std::shared_ptr< impeller::AiksContext > &aiks_context, std::unique_ptr< flutter::SurfaceFrame > frame) override
void BeginFrame(GrDirectContext *context, const fml::RefPtr< fml::RasterThreadMerger > &raster_thread_merger) override
void SetViewProperties(int64_t view_id, const SkRect &occlusion_hint, bool hit_testable, bool focusable)
void PrerollCompositeEmbeddedView(int64_t view_id, std::unique_ptr< flutter::EmbeddedViewParams > params) override
void CancelFrame() override
const EmbeddedViewParams * params
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Dart_NativeFunction function
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
sk_sp< const SkPicture > picture
sk_sp< SkBlender > blender SkRect rect
std::function< void()> ViewCallback
std::function< void(fuchsia::ui::composition::ContentId)> ViewIdCallback
std::function< void(fuchsia::ui::composition::ContentId, fuchsia::ui::composition::ChildViewWatcherHandle child_view_watcher)> ViewCreatedCallback
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
bool operator==(C p1, const scoped_nsprotocol< C > &p2)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeEmpty()
static constexpr SkSize MakeEmpty()