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