Flutter Engine
The Flutter Engine
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
10
11namespace 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|
23DlCanvas* 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|
30void IOSExternalViewEmbedder::CancelFrame() {
31 TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::CancelFrame");
32 FML_CHECK(platform_views_controller_);
33 platform_views_controller_->CancelFrame();
34}
35
36// |ExternalViewEmbedder|
37void IOSExternalViewEmbedder::BeginFrame(
38 GrDirectContext* context,
39 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {}
40
41// |ExternalViewEmbedder|
42void 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|
48void 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|
57PostPrerollResult 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|
66DlCanvas* 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|
73void 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|
88void 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|
96bool IOSExternalViewEmbedder::SupportsDynamicThreadMerging() {
97 return true;
98}
99
100// |ExternalViewEmbedder|
101void 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|
108void IOSExternalViewEmbedder::PushVisitedPlatformView(int64_t view_id) {
109 platform_views_controller_->PushVisitedPlatformView(view_id);
110}
111
112} // namespace flutter
Developer-facing API for rendering anything within the engine.
Definition: dl_canvas.h:38
IOSExternalViewEmbedder(const std::shared_ptr< FlutterPlatformViewsController > &platform_views_controller, std::shared_ptr< IOSContext > context)
virtual ~IOSExternalViewEmbedder() override
const EmbeddedViewParams * params
double frame
Definition: examples.cpp:31
GAsyncResult * result
#define FML_CHECK(condition)
Definition: logging.h:85
#define FML_DCHECK(condition)
Definition: logging.h:103
constexpr int64_t kFlutterImplicitViewId
Definition: constants.h:35
Definition: ref_ptr.h:256
flutter::DlCanvas DlCanvas
Definition: SkSize.h:16
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131