Flutter Engine
flutter::SceneUpdateContext Class Reference

#include <scene_update_context.h>

Inheritance diagram for flutter::SceneUpdateContext:
flutter::ExternalViewEmbedder

Classes

class  Clip
 
class  Entity
 
class  Frame
 
struct  PaintTask
 
class  Transform
 

Public Member Functions

 SceneUpdateContext (std::string debug_label, fuchsia::ui::views::ViewToken view_token, scenic::ViewRefPair view_ref_pair, SessionWrapper &session)
 
 ~SceneUpdateContext ()=default
 
scenic::ContainerNode & root_node ()
 
void set_alphaf (float alpha)
 
float alphaf ()
 
std::vector< PaintTaskGetPaintTasks ()
 
void EnableWireframe (bool enable)
 
void Reset ()
 
SkCanvas * GetRootCanvas () override
 
void CancelFrame () override
 
void BeginFrame (SkISize frame_size, GrDirectContext *context, double device_pixel_ratio, fml::RefPtr< fml::RasterThreadMerger > raster_thread_merger) override
 
void PrerollCompositeEmbeddedView (int view_id, std::unique_ptr< EmbeddedViewParams > params) override
 
std::vector< SkCanvas * > GetCurrentCanvases () override
 
virtual SkCanvas * CompositeEmbeddedView (int view_id) override
 
void CreateView (int64_t view_id, bool hit_testable, bool focusable)
 
void UpdateView (int64_t view_id, bool hit_testable, bool focusable)
 
void DestroyView (int64_t view_id)
 
void UpdateView (int64_t view_id, const SkPoint &offset, const SkSize &size, std::optional< bool > override_hit_testable=std::nullopt)
 
- Public Member Functions inherited from flutter::ExternalViewEmbedder
 ExternalViewEmbedder ()=default
 
virtual ~ExternalViewEmbedder ()=default
 
virtual PostPrerollResult PostPrerollAction (fml::RefPtr< fml::RasterThreadMerger > raster_thread_merger)
 
virtual void SubmitFrame (GrDirectContext *context, std::unique_ptr< SurfaceFrame > frame)
 
virtual void EndFrame (bool should_resubmit_frame, fml::RefPtr< fml::RasterThreadMerger > raster_thread_merger)
 
virtual bool SupportsDynamicThreadMerging ()
 
 FML_DISALLOW_COPY_AND_ASSIGN (ExternalViewEmbedder)
 

Detailed Description

Definition at line 45 of file scene_update_context.h.

Constructor & Destructor Documentation

◆ SceneUpdateContext()

flutter::SceneUpdateContext::SceneUpdateContext ( std::string  debug_label,
fuchsia::ui::views::ViewToken  view_token,
scenic::ViewRefPair  view_ref_pair,
SessionWrapper session 
)

Definition at line 68 of file scene_update_context.cc.

References flutter::SessionWrapper::Present().

72  : session_(session),
73  root_view_(session_.get(),
74  std::move(view_token),
75  std::move(view_ref_pair.control_ref),
76  std::move(view_ref_pair.view_ref),
77  debug_label),
78  root_node_(session_.get()) {
79  root_view_.AddChild(root_node_);
80  root_node_.SetEventMask(fuchsia::ui::gfx::kMetricsEventMask);
81 
82  session_.Present();
83 }
virtual void Present()=0
virtual scenic::Session * get()=0

◆ ~SceneUpdateContext()

flutter::SceneUpdateContext::~SceneUpdateContext ( )
default

Member Function Documentation

◆ alphaf()

float flutter::SceneUpdateContext::alphaf ( )
inline

Definition at line 132 of file scene_update_context.h.

Referenced by UpdateView().

132 { return alpha_; }

◆ BeginFrame()

void flutter::SceneUpdateContext::BeginFrame ( SkISize  frame_size,
GrDirectContext *  context,
double  device_pixel_ratio,
fml::RefPtr< fml::RasterThreadMerger raster_thread_merger 
)
inlineoverridevirtual

Implements flutter::ExternalViewEmbedder.

Definition at line 150 of file scene_update_context.h.

154  {}

◆ CancelFrame()

void flutter::SceneUpdateContext::CancelFrame ( )
inlineoverridevirtual

Implements flutter::ExternalViewEmbedder.

Definition at line 147 of file scene_update_context.h.

147 {}

◆ CompositeEmbeddedView()

virtual SkCanvas* flutter::SceneUpdateContext::CompositeEmbeddedView ( int  view_id)
inlineoverridevirtual

Implements flutter::ExternalViewEmbedder.

Definition at line 167 of file scene_update_context.h.

References FML_DISALLOW_COPY_AND_ASSIGN, flutter::opacity, and fml::size().

167  {
168  return nullptr;
169  }

◆ CreateView()

void flutter::SceneUpdateContext::CreateView ( int64_t  view_id,
bool  hit_testable,
bool  focusable 
)

Definition at line 190 of file scene_update_context.cc.

References flutter::ViewHolder::Create(), FML_DCHECK, and flutter::ViewHolder::FromId().

192  {
193  zx_handle_t handle = (zx_handle_t)view_id;
194  flutter::ViewHolder::Create(handle, nullptr,
195  scenic::ToViewHolderToken(zx::eventpair(handle)),
196  nullptr);
197  auto* view_holder = ViewHolder::FromId(view_id);
198  FML_DCHECK(view_holder);
199 
200  view_holder->set_hit_testable(hit_testable);
201  view_holder->set_focusable(focusable);
202 }
#define FML_DCHECK(condition)
Definition: logging.h:86
static void Create(zx_koid_t id, fml::RefPtr< fml::TaskRunner > ui_task_runner, fuchsia::ui::views::ViewHolderToken view_holder_token, const BindCallback &on_bind_callback)
Definition: view_holder.cc:53
static ViewHolder * FromId(zx_koid_t id)
Definition: view_holder.cc:80

◆ DestroyView()

void flutter::SceneUpdateContext::DestroyView ( int64_t  view_id)

Definition at line 214 of file scene_update_context.cc.

References flutter::ViewHolder::Destroy().

214  {
215  ViewHolder::Destroy(view_id);
216 }
static void Destroy(zx_koid_t id)
Definition: view_holder.cc:73

◆ EnableWireframe()

void flutter::SceneUpdateContext::EnableWireframe ( bool  enable)

Definition at line 93 of file scene_update_context.cc.

References flutter::SessionWrapper::get().

93  {
94  session_.get()->Enqueue(
95  scenic::NewSetEnableDebugViewBoundsCmd(root_view_.id(), enable));
96 }
virtual scenic::Session * get()=0

◆ GetCurrentCanvases()

std::vector<SkCanvas*> flutter::SceneUpdateContext::GetCurrentCanvases ( )
inlineoverridevirtual

Implements flutter::ExternalViewEmbedder.

Definition at line 162 of file scene_update_context.h.

162  {
163  return std::vector<SkCanvas*>();
164  }

◆ GetPaintTasks()

std::vector< SceneUpdateContext::PaintTask > flutter::SceneUpdateContext::GetPaintTasks ( )

Definition at line 85 of file scene_update_context.cc.

85  {
86  std::vector<PaintTask> frame_paint_tasks = std::move(paint_tasks_);
87 
88  paint_tasks_.clear();
89 
90  return frame_paint_tasks;
91 }

◆ GetRootCanvas()

SkCanvas* flutter::SceneUpdateContext::GetRootCanvas ( )
inlineoverridevirtual

Implements flutter::ExternalViewEmbedder.

Definition at line 144 of file scene_update_context.h.

144 { return nullptr; }

◆ PrerollCompositeEmbeddedView()

void flutter::SceneUpdateContext::PrerollCompositeEmbeddedView ( int  view_id,
std::unique_ptr< EmbeddedViewParams params 
)
inlineoverridevirtual

Implements flutter::ExternalViewEmbedder.

Definition at line 157 of file scene_update_context.h.

159  {}

◆ Reset()

void flutter::SceneUpdateContext::Reset ( )

Definition at line 98 of file scene_update_context.cc.

References flutter::SessionWrapper::get(), and flutter::SceneUpdateContext::PaintTask::paint_bounds.

98  {
99  paint_tasks_.clear();
100  top_entity_ = nullptr;
101  top_scale_x_ = 1.f;
102  top_scale_y_ = 1.f;
103  top_elevation_ = 0.f;
104  next_elevation_ = 0.f;
105  alpha_ = 1.f;
106 
107  // We are going to be sending down a fresh node hierarchy every frame. So just
108  // enqueue a detach op on the imported root node.
109  session_.get()->Enqueue(scenic::NewDetachChildrenCmd(root_node_.id()));
110 }
virtual scenic::Session * get()=0

◆ root_node()

scenic::ContainerNode& flutter::SceneUpdateContext::root_node ( )
inline

Definition at line 128 of file scene_update_context.h.

128 { return root_node_; }

◆ set_alphaf()

void flutter::SceneUpdateContext::set_alphaf ( float  alpha)
inline

Definition at line 131 of file scene_update_context.h.

131 { alpha_ = alpha; }

◆ UpdateView() [1/2]

void flutter::SceneUpdateContext::UpdateView ( int64_t  view_id,
bool  hit_testable,
bool  focusable 
)

Definition at line 204 of file scene_update_context.cc.

References FML_DCHECK, and flutter::ViewHolder::FromId().

206  {
207  auto* view_holder = ViewHolder::FromId(view_id);
208  FML_DCHECK(view_holder);
209 
210  view_holder->set_hit_testable(hit_testable);
211  view_holder->set_focusable(focusable);
212 }
#define FML_DCHECK(condition)
Definition: logging.h:86
static ViewHolder * FromId(zx_koid_t id)
Definition: view_holder.cc:80

◆ UpdateView() [2/2]

void flutter::SceneUpdateContext::UpdateView ( int64_t  view_id,
const SkPoint &  offset,
const SkSize &  size,
std::optional< bool >  override_hit_testable = std::nullopt 
)

Definition at line 167 of file scene_update_context.cc.

References alphaf(), flutter::SceneUpdateContext::Entity::embedder_node(), FML_DCHECK, flutter::ViewHolder::FromId(), flutter::SessionWrapper::get(), flutter::kScenicZElevationBetweenLayers, and fml::size().

170  {
171  auto* view_holder = ViewHolder::FromId(view_id);
172  FML_DCHECK(view_holder);
173 
174  if (size.width() > 0.f && size.height() > 0.f) {
175  view_holder->SetProperties(size.width(), size.height(), 0, 0, 0, 0,
176  view_holder->focusable());
177  }
178 
179  bool hit_testable = override_hit_testable.has_value()
180  ? *override_hit_testable
181  : view_holder->hit_testable();
182  view_holder->UpdateScene(session_.get(), top_entity_->embedder_node(), offset,
183  size, SkScalarRoundToInt(alphaf() * 255),
184  hit_testable);
185 
186  // Assume embedded views are 10 "layers" wide.
187  next_elevation_ += 10 * kScenicZElevationBetweenLayers;
188 }
#define FML_DCHECK(condition)
Definition: logging.h:86
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
virtual scenic::Session * get()=0
constexpr float kScenicZElevationBetweenLayers
static ViewHolder * FromId(zx_koid_t id)
Definition: view_holder.cc:80
virtual scenic::ContainerNode & embedder_node()

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