Flutter iOS Embedder
ios_external_view_embedder.mm
Go to the documentation of this file.
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 
6 
7 #include "flutter/common/constants.h"
8 
9 namespace flutter {
10 
12  const std::shared_ptr<FlutterPlatformViewsController>& platform_views_controller,
13  std::shared_ptr<IOSContext> context)
14  : platform_views_controller_(platform_views_controller), ios_context_(std::move(context)) {
15  FML_CHECK(ios_context_);
16 }
17 
19 
20 // |ExternalViewEmbedder|
21 DlCanvas* IOSExternalViewEmbedder::GetRootCanvas() {
22  // On iOS, the root surface is created from the on-screen render target. Only the surfaces for the
23  // various overlays are controlled by this class.
24  return nullptr;
25 }
26 
27 // |ExternalViewEmbedder|
28 void IOSExternalViewEmbedder::CancelFrame() {
29  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::CancelFrame");
30  FML_CHECK(platform_views_controller_);
31  platform_views_controller_->CancelFrame();
32 }
33 
34 // |ExternalViewEmbedder|
35 void IOSExternalViewEmbedder::BeginFrame(
36  GrDirectContext* context,
37  const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {}
38 
39 // |ExternalViewEmbedder|
40 void IOSExternalViewEmbedder::PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) {
41  FML_CHECK(platform_views_controller_);
42  platform_views_controller_->BeginFrame(frame_size);
43 }
44 
45 // |ExternalViewEmbedder|
46 void IOSExternalViewEmbedder::PrerollCompositeEmbeddedView(
47  int64_t view_id,
48  std::unique_ptr<EmbeddedViewParams> params) {
49  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::PrerollCompositeEmbeddedView");
50  FML_CHECK(platform_views_controller_);
51  platform_views_controller_->PrerollCompositeEmbeddedView(view_id, std::move(params));
52 }
53 
54 // |ExternalViewEmbedder|
55 PostPrerollResult IOSExternalViewEmbedder::PostPrerollAction(
56  const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
57  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::PostPrerollAction");
58  FML_CHECK(platform_views_controller_);
59  PostPrerollResult result = platform_views_controller_->PostPrerollAction(raster_thread_merger);
60  return result;
61 }
62 
63 // |ExternalViewEmbedder|
64 DlCanvas* IOSExternalViewEmbedder::CompositeEmbeddedView(int64_t view_id) {
65  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::CompositeEmbeddedView");
66  FML_CHECK(platform_views_controller_);
67  return platform_views_controller_->CompositeEmbeddedView(view_id);
68 }
69 
70 // |ExternalViewEmbedder|
71 void IOSExternalViewEmbedder::SubmitFlutterView(
72  int64_t flutter_view_id,
73  GrDirectContext* context,
74  const std::shared_ptr<impeller::AiksContext>& aiks_context,
75  std::unique_ptr<SurfaceFrame> frame) {
76  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::SubmitFlutterView");
77  // TODO(dkwingsmt): This class only supports rendering into the implicit view.
78  // Properly support multi-view in the future.
79  FML_DCHECK(flutter_view_id == kFlutterImplicitViewId);
80  FML_CHECK(platform_views_controller_);
81  platform_views_controller_->SubmitFrame(context, ios_context_, std::move(frame));
82  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::DidSubmitFrame");
83 }
84 
85 // |ExternalViewEmbedder|
86 void IOSExternalViewEmbedder::EndFrame(
87  bool should_resubmit_frame,
88  const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
89  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::EndFrame");
90  platform_views_controller_->EndFrame(should_resubmit_frame, raster_thread_merger);
91 }
92 
93 // |ExternalViewEmbedder|
94 bool IOSExternalViewEmbedder::SupportsDynamicThreadMerging() {
95  return true;
96 }
97 
98 // |ExternalViewEmbedder|
99 void IOSExternalViewEmbedder::PushFilterToVisitedPlatformViews(
100  const std::shared_ptr<const DlImageFilter>& filter,
101  const SkRect& filter_rect) {
102  platform_views_controller_->PushFilterToVisitedPlatformViews(filter, filter_rect);
103 }
104 
105 // |ExternalViewEmbedder|
106 void IOSExternalViewEmbedder::PushVisitedPlatformView(int64_t view_id) {
107  platform_views_controller_->PushVisitedPlatformView(view_id);
108 }
109 
110 } // namespace flutter
ios_external_view_embedder.h
flutter::IOSExternalViewEmbedder::~IOSExternalViewEmbedder
virtual ~IOSExternalViewEmbedder() override
flutter
Definition: accessibility_bridge.h:28
flutter::IOSExternalViewEmbedder::IOSExternalViewEmbedder
IOSExternalViewEmbedder(const std::shared_ptr< FlutterPlatformViewsController > &platform_views_controller, std::shared_ptr< IOSContext > context)
Definition: ios_external_view_embedder.mm:11