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