Flutter Engine
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 () const
 
ViewIdentifier GetViewIdentifier () const
 
const EmbeddedViewParamsGetEmbeddedViewParams () const
 
RenderTargetDescriptor CreateRenderTargetDescriptor () const
 
SkCanvas * GetCanvas () const
 
SkISize GetRenderSurfaceSize () const
 
bool Render (const EmbedderRenderTarget &render_target)
 

Detailed Description

Definition at line 21 of file embedder_external_view.h.

Member Typedef Documentation

◆ PendingViews

◆ PlatformViewID

Definition at line 23 of file embedder_external_view.h.

◆ ViewIdentifierSet

Constructor & Destructor Documentation

◆ EmbedderExternalView() [1/2]

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

Definition at line 18 of file embedder_external_view.cc.

21  : 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 23 of file embedder_external_view.cc.

References ~EmbedderExternalView().

28  : render_surface_size_(
29  TransformedSurfaceSize(frame_size, surface_transformation)),
30  surface_transformation_(surface_transformation),
31  view_identifier_(view_identifier),
32  embedded_view_params_(std::move(params)),
33  recorder_(std::make_unique<SkPictureRecorder>()),
34  canvas_spy_(std::make_unique<CanvasSpy>(
35  recorder_->beginRecording(frame_size.width(), frame_size.height()))) {
36 }
static SkISize TransformedSurfaceSize(const SkISize &size, const SkMatrix &transformation)

◆ ~EmbedderExternalView()

flutter::EmbedderExternalView::~EmbedderExternalView ( )
default

Referenced by EmbedderExternalView().

Member Function Documentation

◆ CreateRenderTargetDescriptor()

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

Definition at line 41 of file embedder_external_view.cc.

41  {
42  return {view_identifier_, render_surface_size_};
43 }

◆ GetCanvas()

SkCanvas * flutter::EmbedderExternalView::GetCanvas ( ) const

Definition at line 45 of file embedder_external_view.cc.

45  {
46  return canvas_spy_->GetSpyingCanvas();
47 }

◆ GetEmbeddedViewParams()

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

Definition at line 70 of file embedder_external_view.cc.

70  {
71  return embedded_view_params_.get();
72 }

◆ GetRenderSurfaceSize()

SkISize flutter::EmbedderExternalView::GetRenderSurfaceSize ( ) const

Definition at line 49 of file embedder_external_view.cc.

49  {
50  return render_surface_size_;
51 }

◆ GetViewIdentifier()

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

Definition at line 65 of file embedder_external_view.cc.

66  {
67  return view_identifier_;
68 }

◆ HasEngineRenderedContents()

bool flutter::EmbedderExternalView::HasEngineRenderedContents ( ) const

Definition at line 61 of file embedder_external_view.cc.

Referenced by Render().

61  {
62  return canvas_spy_->DidDrawIntoCanvas();
63 }

◆ HasPlatformView()

bool flutter::EmbedderExternalView::HasPlatformView ( ) const

Definition at line 57 of file embedder_external_view.cc.

References flutter::EmbedderExternalView::ViewIdentifier::platform_view_id.

Referenced by IsRootView().

57  {
58  return view_identifier_.platform_view_id.has_value();
59 }
std::optional< PlatformViewID > platform_view_id

◆ IsRootView()

bool flutter::EmbedderExternalView::IsRootView ( ) const

Definition at line 53 of file embedder_external_view.cc.

References HasPlatformView().

53  {
54  return !HasPlatformView();
55 }

◆ Render()

bool flutter::EmbedderExternalView::Render ( const EmbedderRenderTarget render_target)

Definition at line 74 of file embedder_external_view.cc.

References FML_DCHECK, flutter::EmbedderRenderTarget::GetRenderSurface(), HasEngineRenderedContents(), and TRACE_EVENT0.

74  {
75  TRACE_EVENT0("flutter", "EmbedderExternalView::Render");
76 
78  << "Unnecessarily asked to render into a render target when there was "
79  "nothing to render.";
80 
81  auto picture = recorder_->finishRecordingAsPicture();
82  if (!picture) {
83  return false;
84  }
85 
86  auto surface = render_target.GetRenderSurface();
87  if (!surface) {
88  return false;
89  }
90 
91  FML_DCHECK(SkISize::Make(surface->width(), surface->height()) ==
92  render_surface_size_);
93 
94  auto canvas = surface->getCanvas();
95  if (!canvas) {
96  return false;
97  }
98 
99  canvas->setMatrix(surface_transformation_);
100  canvas->clear(SK_ColorTRANSPARENT);
101  canvas->drawPicture(picture);
102  canvas->flush();
103 
104  return true;
105 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define FML_DCHECK(condition)
Definition: logging.h:86

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