Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
embedder_external_view.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
10#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
11#include "third_party/skia/include/gpu/ganesh/GrRecordingContext.h"
12
13namespace flutter {
14
16 const DlMatrix& transformation) {
17 const auto source_rect = DlRect::MakeSize(size);
18 const auto transformed_rect =
19 source_rect.TransformAndClipBounds(transformation);
20 return DlIRect::RoundOut(transformed_rect).GetSize();
21}
22
24 const DlISize& frame_size,
25 const DlMatrix& surface_transformation)
26 : EmbedderExternalView(frame_size, surface_transformation, {}, nullptr) {}
27
29 const DlISize& frame_size,
30 const DlMatrix& surface_transformation,
32 std::unique_ptr<EmbeddedViewParams> params)
33 : render_surface_size_(
34 TransformedSurfaceSize(frame_size, surface_transformation)),
35 surface_transformation_(surface_transformation),
36 view_identifier_(view_identifier),
37 embedded_view_params_(std::move(params)),
38 slice_(std::make_unique<DisplayListEmbedderViewSlice>(
39 DlRect::MakeSize(frame_size))) {}
40
42
47
49 return slice_->canvas();
50}
51
53 return render_surface_size_;
54}
55
57 return !HasPlatformView();
58}
59
61 return view_identifier_.platform_view_id.has_value();
62}
63
65 return slice_->getRegion();
66}
67
69 if (has_engine_rendered_contents_.has_value()) {
70 return has_engine_rendered_contents_.value();
71 }
72 TryEndRecording();
73 DlOpSpy dl_op_spy;
74 slice_->dispatch(dl_op_spy);
75 has_engine_rendered_contents_ = dl_op_spy.did_draw() && !slice_->is_empty();
76 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
77 return has_engine_rendered_contents_.value();
78}
79
84
86 return embedded_view_params_.get();
87}
88
89void EmbedderExternalView::Render(DlCanvas& dl_canvas, bool clear_surface) {
90 TRACE_EVENT0("flutter", "EmbedderExternalView::Render");
91 TryEndRecording();
93 << "Unnecessarily asked to render into a render target when there was "
94 "nothing to render.";
95
96 int restore_count = dl_canvas.GetSaveCount();
97 dl_canvas.SetTransform(surface_transformation_);
98 if (clear_surface) {
99 dl_canvas.Clear(DlColor::kTransparent());
100 }
101 slice_->render_into(&dl_canvas);
102 dl_canvas.RestoreToCount(restore_count);
103}
104
105void EmbedderExternalView::TryEndRecording() const {
106 if (slice_->recording_ended()) {
107 return;
108 }
109 slice_->end_recording();
110}
111
112} // namespace flutter
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:32
virtual int GetSaveCount() const =0
virtual void SetTransform(const DlMatrix &matrix)=0
virtual void RestoreToCount(int restore_count)=0
void Clear(DlColor color)
Definition dl_canvas.h:104
bool did_draw()
Returns true if any non transparent content has been drawn.
Definition dl_op_spy.cc:9
const EmbeddedViewParams * GetEmbeddedViewParams() const
void Render(DlCanvas &dl_canvas, bool clear_surface)
RenderTargetDescriptor CreateRenderTargetDescriptor() const
EmbedderExternalView(const DlISize &frame_size, const DlMatrix &surface_transformation)
const DlRegion & GetDlRegion() const
ViewIdentifier GetViewIdentifier() const
EmbedderExternalView::ViewIdentifier view_identifier
const EmbeddedViewParams * params
#define FML_DCHECK(condition)
Definition logging.h:122
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static DlISize TransformedSurfaceSize(const DlISize &size, const DlMatrix &transformation)
Definition ref_ptr.h:261
static constexpr DlColor kTransparent()
Definition dl_color.h:68
A 4x4 matrix using column-major storage.
Definition matrix.h:37
RoundOut(const TRect< U > &r)
Definition rect.h:713
static constexpr TRect MakeSize(const TSize< U > &size)
Definition rect.h:150
#define TRACE_EVENT0(category_group, name)