Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | List of all members
flutter::EmbedderExternalView Class Reference

#include <embedder_external_view.h>

Classes

struct  RenderTargetDescriptor
 
struct  ViewIdentifier
 

Public Types

using PlatformViewID = int64_t
 
using ViewIdentifierSet = std::unordered_set< ViewIdentifier, ViewIdentifier::Hash, ViewIdentifier::Equal >
 
using PendingViews = std::unordered_map< ViewIdentifier, std::unique_ptr< EmbedderExternalView >, ViewIdentifier::Hash, ViewIdentifier::Equal >
 

Public Member Functions

 EmbedderExternalView (const SkISize &frame_size, const SkMatrix &surface_transformation)
 
 EmbedderExternalView (const SkISize &frame_size, const SkMatrix &surface_transformation, ViewIdentifier view_identifier, std::unique_ptr< EmbeddedViewParams > params)
 
 ~EmbedderExternalView ()
 
bool IsRootView () const
 
bool HasPlatformView () const
 
bool HasEngineRenderedContents ()
 
ViewIdentifier GetViewIdentifier () const
 
const EmbeddedViewParamsGetEmbeddedViewParams () const
 
RenderTargetDescriptor CreateRenderTargetDescriptor () const
 
DlCanvasGetCanvas ()
 
SkISize GetRenderSurfaceSize () const
 
bool Render (const EmbedderRenderTarget &render_target, bool clear_surface=true)
 
const DlRegionGetDlRegion () const
 

Detailed Description

Definition at line 19 of file embedder_external_view.h.

Member Typedef Documentation

◆ PendingViews

Definition at line 74 of file embedder_external_view.h.

◆ PlatformViewID

Definition at line 21 of file embedder_external_view.h.

◆ ViewIdentifierSet

Definition at line 70 of file embedder_external_view.h.

Constructor & Destructor Documentation

◆ EmbedderExternalView() [1/2]

flutter::EmbedderExternalView::EmbedderExternalView ( const SkISize frame_size,
const SkMatrix surface_transformation 
)

Definition at line 25 of file embedder_external_view.cc.

28 : EmbedderExternalView(frame_size, surface_transformation, {}, nullptr) {}
EmbedderExternalView(const SkISize &frame_size, const SkMatrix &surface_transformation)

◆ EmbedderExternalView() [2/2]

flutter::EmbedderExternalView::EmbedderExternalView ( const SkISize frame_size,
const SkMatrix surface_transformation,
ViewIdentifier  view_identifier,
std::unique_ptr< EmbeddedViewParams params 
)

Definition at line 30 of file embedder_external_view.cc.

35 : render_surface_size_(
36 TransformedSurfaceSize(frame_size, surface_transformation)),
37 surface_transformation_(surface_transformation),
38 view_identifier_(view_identifier),
39 embedded_view_params_(std::move(params)),
40 slice_(std::make_unique<DisplayListEmbedderViewSlice>(
41 SkRect::Make(frame_size))) {}
EmbedderExternalView::ViewIdentifier view_identifier
const EmbeddedViewParams * params
static SkISize TransformedSurfaceSize(const SkISize &size, const SkMatrix &transformation)
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ ~EmbedderExternalView()

flutter::EmbedderExternalView::~EmbedderExternalView ( )
default

Member Function Documentation

◆ CreateRenderTargetDescriptor()

EmbedderExternalView::RenderTargetDescriptor flutter::EmbedderExternalView::CreateRenderTargetDescriptor ( ) const

Definition at line 46 of file embedder_external_view.cc.

46 {
47 return RenderTargetDescriptor(render_surface_size_);
48}

◆ GetCanvas()

DlCanvas * flutter::EmbedderExternalView::GetCanvas ( )

Definition at line 50 of file embedder_external_view.cc.

50 {
51 return slice_->canvas();
52}

◆ GetDlRegion()

const DlRegion & flutter::EmbedderExternalView::GetDlRegion ( ) const

Definition at line 66 of file embedder_external_view.cc.

66 {
67 return slice_->getRegion();
68}

◆ GetEmbeddedViewParams()

const EmbeddedViewParams * flutter::EmbedderExternalView::GetEmbeddedViewParams ( ) const

Definition at line 87 of file embedder_external_view.cc.

87 {
88 return embedded_view_params_.get();
89}

◆ GetRenderSurfaceSize()

SkISize flutter::EmbedderExternalView::GetRenderSurfaceSize ( ) const

Definition at line 54 of file embedder_external_view.cc.

54 {
55 return render_surface_size_;
56}

◆ GetViewIdentifier()

EmbedderExternalView::ViewIdentifier flutter::EmbedderExternalView::GetViewIdentifier ( ) const

Definition at line 82 of file embedder_external_view.cc.

83 {
84 return view_identifier_;
85}

◆ HasEngineRenderedContents()

bool flutter::EmbedderExternalView::HasEngineRenderedContents ( )

Definition at line 70 of file embedder_external_view.cc.

70 {
71 if (has_engine_rendered_contents_.has_value()) {
72 return has_engine_rendered_contents_.value();
73 }
74 TryEndRecording();
75 DlOpSpy dl_op_spy;
76 slice_->dispatch(dl_op_spy);
77 has_engine_rendered_contents_ = dl_op_spy.did_draw() && !slice_->is_empty();
78 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
79 return has_engine_rendered_contents_.value();
80}

◆ HasPlatformView()

bool flutter::EmbedderExternalView::HasPlatformView ( ) const

Definition at line 62 of file embedder_external_view.cc.

62 {
63 return view_identifier_.platform_view_id.has_value();
64}
std::optional< PlatformViewID > platform_view_id

◆ IsRootView()

bool flutter::EmbedderExternalView::IsRootView ( ) const

Definition at line 58 of file embedder_external_view.cc.

58 {
59 return !HasPlatformView();
60}

◆ Render()

bool flutter::EmbedderExternalView::Render ( const EmbedderRenderTarget render_target,
bool  clear_surface = true 
)

Definition at line 91 of file embedder_external_view.cc.

92 {
93 TRACE_EVENT0("flutter", "EmbedderExternalView::Render");
94 TryEndRecording();
96 << "Unnecessarily asked to render into a render target when there was "
97 "nothing to render.";
98
99#ifdef IMPELLER_SUPPORTS_RENDERING
100 auto* impeller_target = render_target.GetImpellerRenderTarget();
101 if (impeller_target) {
102 auto aiks_context = render_target.GetAiksContext();
103
104 auto dl_builder = DisplayListBuilder();
105 dl_builder.SetTransform(&surface_transformation_);
106 slice_->render_into(&dl_builder);
107 auto display_list = dl_builder.Build();
108
109#if ENABLE_EXPERIMENTAL_CANVAS
110 auto cull_rect =
111 impeller::IRect::MakeSize(impeller_target->GetRenderTargetSize());
112 SkIRect sk_cull_rect =
113 SkIRect::MakeWH(cull_rect.GetWidth(), cull_rect.GetHeight());
114
115 impeller::TextFrameDispatcher collector(aiks_context->GetContentContext(),
117
118 impeller::ExperimentalDlDispatcher impeller_dispatcher(
119 aiks_context->GetContentContext(), *impeller_target,
120 display_list->root_has_backdrop_filter(),
121 display_list->max_root_blend_mode(), cull_rect);
122 display_list->Dispatch(impeller_dispatcher, sk_cull_rect);
123 impeller_dispatcher.FinishRecording();
124 aiks_context->GetContentContext().GetTransientsBuffer().Reset();
125 aiks_context->GetContentContext().GetLazyGlyphAtlas()->ResetTextFrames();
126
127 return true;
128#else
129 auto dispatcher = impeller::DlDispatcher();
130 dispatcher.drawDisplayList(display_list, 1);
131 return aiks_context->Render(dispatcher.EndRecordingAsPicture(),
132 *impeller_target, /*reset_host_buffer=*/true);
133#endif
134 }
135#endif // IMPELLER_SUPPORTS_RENDERING
136
137#if SLIMPELLER
138 FML_LOG(FATAL) << "Impeller opt-out unavailable.";
139 return false;
140#else // SLIMPELLER
141 auto skia_surface = render_target.GetSkiaSurface();
142 if (!skia_surface) {
143 return false;
144 }
145
146 FML_DCHECK(render_target.GetRenderTargetSize() == render_surface_size_);
147
148 auto canvas = skia_surface->getCanvas();
149 if (!canvas) {
150 return false;
151 }
152 DlSkCanvasAdapter dl_canvas(canvas);
153 int restore_count = dl_canvas.GetSaveCount();
154 dl_canvas.SetTransform(surface_transformation_);
155 if (clear_surface) {
156 dl_canvas.Clear(DlColor::kTransparent());
157 }
158 slice_->render_into(&dl_canvas);
159 dl_canvas.RestoreToCount(restore_count);
160 dl_canvas.Flush();
161#endif // !SLIMPELLER
162
163 return true;
164}
Performs a first pass over the display list to collect all text frames.
#define FATAL(error)
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_DCHECK(condition)
Definition: logging.h:103
Definition: SkRect.h:32
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
static constexpr DlColor kTransparent()
Definition: dl_color.h:21
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
static constexpr TRect MakeSize(const TSize< U > &size)
Definition: rect.h:146
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

The documentation for this class was generated from the following files: