Flutter Engine
The Flutter Engine
shell_test_external_view_embedder.cc
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
7namespace flutter {
8
10 const EndFrameCallBack& end_frame_call_back,
11 PostPrerollResult post_preroll_result,
12 bool support_thread_merging)
13 : end_frame_call_back_(end_frame_call_back),
14 post_preroll_result_(post_preroll_result),
15 support_thread_merging_(support_thread_merging),
16 submitted_frame_count_(0) {}
17
19 PostPrerollResult post_preroll_result) {
20 post_preroll_result_ = post_preroll_result;
21}
22
24 return submitted_frame_count_;
25}
26
28 return last_submitted_frame_size_;
29}
30
32 return visited_platform_views_;
33}
34
36 return mutators_stacks_[view_id];
37}
38
39// |ExternalViewEmbedder|
40void ShellTestExternalViewEmbedder::CancelFrame() {}
41
42// |ExternalViewEmbedder|
43void ShellTestExternalViewEmbedder::BeginFrame(
44 GrDirectContext* context,
45 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {}
46
47// |ExternalViewEmbedder|
48void ShellTestExternalViewEmbedder::PrepareFlutterView(
49 SkISize frame_size,
50 double device_pixel_ratio) {
51 visited_platform_views_.clear();
52 mutators_stacks_.clear();
53 current_composition_params_.clear();
54}
55
56// |ExternalViewEmbedder|
57void ShellTestExternalViewEmbedder::PrerollCompositeEmbeddedView(
58 int64_t view_id,
59 std::unique_ptr<EmbeddedViewParams> params) {
60 SkRect view_bounds = SkRect::Make(frame_size_);
61 auto view = std::make_unique<DisplayListEmbedderViewSlice>(view_bounds);
62 slices_.insert_or_assign(view_id, std::move(view));
63}
64
65// |ExternalViewEmbedder|
66PostPrerollResult ShellTestExternalViewEmbedder::PostPrerollAction(
67 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
68 FML_DCHECK(raster_thread_merger);
69 return post_preroll_result_;
70}
71
72// |ExternalViewEmbedder|
73void ShellTestExternalViewEmbedder::PushVisitedPlatformView(int64_t view_id) {
74 visited_platform_views_.push_back(view_id);
75}
76
77// |ExternalViewEmbedder|
78void ShellTestExternalViewEmbedder::PushFilterToVisitedPlatformViews(
79 const std::shared_ptr<const DlImageFilter>& filter,
80 const SkRect& filter_rect) {
81 for (int64_t id : visited_platform_views_) {
82 EmbeddedViewParams params = current_composition_params_[id];
83 params.PushImageFilter(filter, filter_rect);
84 current_composition_params_[id] = params;
85 mutators_stacks_[id] = params.mutatorsStack();
86 }
87}
88
89DlCanvas* ShellTestExternalViewEmbedder::CompositeEmbeddedView(
90 int64_t view_id) {
91 return slices_[view_id]->canvas();
92}
93
94// |ExternalViewEmbedder|
95void ShellTestExternalViewEmbedder::SubmitFlutterView(
96 int64_t flutter_view_id,
97 GrDirectContext* context,
98 const std::shared_ptr<impeller::AiksContext>& aiks_context,
99 std::unique_ptr<SurfaceFrame> frame) {
100 if (!frame) {
101 return;
102 }
103 frame->Submit();
104 if (frame->SkiaSurface()) {
105 last_submitted_frame_size_ = SkISize::Make(frame->SkiaSurface()->width(),
106 frame->SkiaSurface()->height());
107 } else {
108 last_submitted_frame_size_ = SkISize::MakeEmpty();
109 }
110 submitted_frame_count_++;
111}
112
113// |ExternalViewEmbedder|
114void ShellTestExternalViewEmbedder::EndFrame(
115 bool should_resubmit_frame,
116 const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
117 end_frame_call_back_(should_resubmit_frame, raster_thread_merger);
118}
119
120// |ExternalViewEmbedder|
121DlCanvas* ShellTestExternalViewEmbedder::GetRootCanvas() {
122 return nullptr;
123}
124
125bool ShellTestExternalViewEmbedder::SupportsDynamicThreadMerging() {
126 return support_thread_merging_;
127}
128
129} // namespace flutter
void UpdatePostPrerollResult(PostPrerollResult post_preroll_result)
std::function< void(bool, fml::RefPtr< fml::RasterThreadMerger >)> EndFrameCallBack
ShellTestExternalViewEmbedder(const EndFrameCallBack &end_frame_call_back, PostPrerollResult post_preroll_result, bool support_thread_merging)
const EmbeddedViewParams * params
double frame
Definition: examples.cpp:31
#define FML_DCHECK(condition)
Definition: logging.h:103
flutter::DlCanvas DlCanvas
Definition: SkSize.h:16
static constexpr SkISize MakeEmpty()
Definition: SkSize.h:22
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
const uintptr_t id