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 namespace flutter {
8 
10  FlutterPlatformViewsController* platform_views_controller,
11  std::shared_ptr<IOSContext> context)
12  : platform_views_controller_(platform_views_controller), ios_context_(context) {
13  FML_CHECK(ios_context_);
14 }
15 
17 
18 // |ExternalViewEmbedder|
19 SkCanvas* IOSExternalViewEmbedder::GetRootCanvas() {
20  // On iOS, the root surface is created from the on-screen render target. Only the surfaces for the
21  // various overlays are controlled by this class.
22  return nullptr;
23 }
24 
25 // |ExternalViewEmbedder|
26 void IOSExternalViewEmbedder::CancelFrame() {
27  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::CancelFrame");
28  FML_CHECK(platform_views_controller_);
29  platform_views_controller_->CancelFrame();
30 }
31 
32 // |ExternalViewEmbedder|
33 void IOSExternalViewEmbedder::BeginFrame(
34  SkISize frame_size,
35  GrDirectContext* context,
36  double device_pixel_ratio,
37  fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
38  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::BeginFrame");
39  FML_CHECK(platform_views_controller_);
40  platform_views_controller_->SetFrameSize(frame_size);
41 }
42 
43 // |ExternalViewEmbedder|
44 void IOSExternalViewEmbedder::PrerollCompositeEmbeddedView(
45  int view_id,
46  std::unique_ptr<EmbeddedViewParams> params) {
47  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::PrerollCompositeEmbeddedView");
48  FML_CHECK(platform_views_controller_);
49  platform_views_controller_->PrerollCompositeEmbeddedView(view_id, std::move(params));
50 }
51 
52 // |ExternalViewEmbedder|
53 PostPrerollResult IOSExternalViewEmbedder::PostPrerollAction(
54  fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
55  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::PostPrerollAction");
56  FML_CHECK(platform_views_controller_);
57  PostPrerollResult result = platform_views_controller_->PostPrerollAction(raster_thread_merger);
58  return result;
59 }
60 
61 // |ExternalViewEmbedder|
62 std::vector<SkCanvas*> IOSExternalViewEmbedder::GetCurrentCanvases() {
63  FML_CHECK(platform_views_controller_);
64  return platform_views_controller_->GetCurrentCanvases();
65 }
66 
67 // |ExternalViewEmbedder|
68 SkCanvas* IOSExternalViewEmbedder::CompositeEmbeddedView(int view_id) {
69  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::CompositeEmbeddedView");
70  FML_CHECK(platform_views_controller_);
71  return platform_views_controller_->CompositeEmbeddedView(view_id);
72 }
73 
74 // |ExternalViewEmbedder|
75 void IOSExternalViewEmbedder::SubmitFrame(GrDirectContext* context,
76  std::unique_ptr<SurfaceFrame> frame) {
77  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::SubmitFrame");
78  FML_CHECK(platform_views_controller_);
79  platform_views_controller_->SubmitFrame(std::move(context), ios_context_, std::move(frame));
80  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::DidSubmitFrame");
81 }
82 
83 // |ExternalViewEmbedder|
84 void IOSExternalViewEmbedder::EndFrame(bool should_resubmit_frame,
85  fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
86  TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::EndFrame");
87  FML_CHECK(platform_views_controller_);
88  return platform_views_controller_->EndFrame(should_resubmit_frame, raster_thread_merger);
89 }
90 
91 // |ExternalViewEmbedder|
92 bool IOSExternalViewEmbedder::SupportsDynamicThreadMerging() {
93  return true;
94 }
95 
96 } // namespace flutter
void PrerollCompositeEmbeddedView(int view_id, std::unique_ptr< flutter::EmbeddedViewParams > params)
virtual ~IOSExternalViewEmbedder() override
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
IOSExternalViewEmbedder(FlutterPlatformViewsController *platform_views_controller, std::shared_ptr< IOSContext > context)
PostPrerollResult PostPrerollAction(fml::RefPtr< fml::RasterThreadMerger > raster_thread_merger)
bool SubmitFrame(GrDirectContext *gr_context, std::shared_ptr< IOSContext > ios_context, std::unique_ptr< SurfaceFrame > frame)
#define FML_CHECK(condition)
Definition: logging.h:68
void EndFrame(bool should_resubmit_frame, fml::RefPtr< fml::RasterThreadMerger > raster_thread_merger)