| 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
5 #import "flutter/shell/platform/darwin/ios/ios_external_view_embedder.h"
6
7 #include "flutter/common/constants.h"
8
9 namespace flutter {
10
11 IOSExternalViewEmbedder::IOSExternalViewEmbedder(
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
18 IOSExternalViewEmbedder::~IOSExternalViewEmbedder() = default;
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(int64_t flutter_view_id,
41 SkISize frame_size,
42 double device_pixel_ratio) {
43 // TODO(dkwingsmt): This class only supports rendering into the implicit view.
44 // Properly support multi-view in the future.
45 FML_DCHECK(flutter_view_id == kFlutterImplicitViewId);
46 FML_CHECK(platform_views_controller_);
47 platform_views_controller_->BeginFrame(frame_size);
48 }
49
50 // |ExternalViewEmbedder|
51 void IOSExternalViewEmbedder::PrerollCompositeEmbeddedView(
52 int64_t view_id,
53 std::unique_ptr<EmbeddedViewParams> params) {
54 TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::PrerollCompositeEmbeddedView");
55 FML_CHECK(platform_views_controller_);
56 platform_views_controller_->PrerollCompositeEmbeddedView(view_id, std::move(params));
57 }
58
59 // |ExternalViewEmbedder|
60 PostPrerollResult IOSExternalViewEmbedder::PostPrerollAction(
61 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
62 TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::PostPrerollAction");
63 FML_CHECK(platform_views_controller_);
64 PostPrerollResult result = platform_views_controller_->PostPrerollAction(raster_thread_merger);
65 return result;
66 }
67
68 // |ExternalViewEmbedder|
69 DlCanvas* IOSExternalViewEmbedder::CompositeEmbeddedView(int64_t view_id) {
70 TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::CompositeEmbeddedView");
71 FML_CHECK(platform_views_controller_);
72 return platform_views_controller_->CompositeEmbeddedView(view_id);
73 }
74
75 // |ExternalViewEmbedder|
76 void IOSExternalViewEmbedder::SubmitFlutterView(
77 GrDirectContext* context,
78 const std::shared_ptr<impeller::AiksContext>& aiks_context,
79 std::unique_ptr<SurfaceFrame> frame) {
80 TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::SubmitFlutterView");
81 FML_CHECK(platform_views_controller_);
82 platform_views_controller_->SubmitFrame(context, ios_context_, std::move(frame));
83 TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::DidSubmitFrame");
84 }
85
86 // |ExternalViewEmbedder|
87 void IOSExternalViewEmbedder::EndFrame(
88 bool should_resubmit_frame,
89 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
90 TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::EndFrame");
91 platform_views_controller_->EndFrame(should_resubmit_frame, raster_thread_merger);
92 }
93
94 // |ExternalViewEmbedder|
95 bool IOSExternalViewEmbedder::SupportsDynamicThreadMerging() {
96 return true;
97 }
98
99 // |ExternalViewEmbedder|
100 void IOSExternalViewEmbedder::PushFilterToVisitedPlatformViews(
101 const std::shared_ptr<const DlImageFilter>& filter,
102 const SkRect& filter_rect) {
103 platform_views_controller_->PushFilterToVisitedPlatformViews(filter, filter_rect);
104 }
105
106 // |ExternalViewEmbedder|
107 void IOSExternalViewEmbedder::PushVisitedPlatformView(int64_t view_id) {
108 platform_views_controller_->PushVisitedPlatformView(view_id);
109 }
110
111 } // 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