Flutter Engine
flutter::SceneUpdateContext::Frame Class Reference

#include <scene_update_context.h>

Inheritance diagram for flutter::SceneUpdateContext::Frame:
flutter::SceneUpdateContext::Entity

Public Member Functions

 Frame (std::shared_ptr< SceneUpdateContext > context, const SkRRect &rrect, SkColor color, SkAlpha opacity, std::string label)
 
virtual ~Frame ()
 
scenic::ContainerNode & embedder_node () override
 
void AddPaintLayer (Layer *layer)
 
- Public Member Functions inherited from flutter::SceneUpdateContext::Entity
 Entity (std::shared_ptr< SceneUpdateContext > context)
 
virtual ~Entity ()
 
std::shared_ptr< SceneUpdateContextcontext ()
 
scenic::EntityNode & entity_node ()
 

Detailed Description

Definition at line 78 of file scene_update_context.h.

Constructor & Destructor Documentation

◆ Frame()

flutter::SceneUpdateContext::Frame::Frame ( std::shared_ptr< SceneUpdateContext context,
const SkRRect &  rrect,
SkColor  color,
SkAlpha  opacity,
std::string  label 
)

Definition at line 292 of file scene_update_context.cc.

References flutter::SceneUpdateContext::Entity::entity_node(), flutter::kOneMinusEpsilon, and flutter::kScenicZElevationBetweenLayers.

297  : Entity(context),
298  previous_elevation_(context->top_elevation_),
299  rrect_(rrect),
300  color_(color),
301  opacity_(opacity),
302  opacity_node_(context->session_.get()),
303  paint_bounds_(SkRect::MakeEmpty()) {
304  // Increment elevation trackers before calculating any local elevation.
305  // |UpdateView| can modify context->next_elevation_, which is why it is
306  // neccesary to track this addtional state.
307  context->top_elevation_ += kScenicZElevationBetweenLayers;
308  context->next_elevation_ += kScenicZElevationBetweenLayers;
309 
310  float local_elevation = context->next_elevation_ - previous_elevation_;
311  entity_node().SetTranslation(0.f, 0.f, -local_elevation);
312  entity_node().SetLabel(label);
313  entity_node().AddChild(opacity_node_);
314 
315  // Scenic currently lacks an API to enable rendering of alpha channel; alpha
316  // channels are only rendered if there is a OpacityNode higher in the tree
317  // with opacity != 1. For now, clamp to a infinitesimally smaller value than
318  // 1, which does not cause visual problems in practice.
319  opacity_node_.SetOpacity(std::min(kOneMinusEpsilon, opacity_ / 255.0f));
320 }
constexpr float kOneMinusEpsilon
Entity(std::shared_ptr< SceneUpdateContext > context)
constexpr float kScenicZElevationBetweenLayers
std::shared_ptr< SceneUpdateContext > context()

◆ ~Frame()

flutter::SceneUpdateContext::Frame::~Frame ( )
virtual

Definition at line 322 of file scene_update_context.cc.

References flutter::SceneUpdateContext::Entity::context(), and flutter::SceneUpdateContext::Entity::entity_node().

322  {
323  context()->top_elevation_ = previous_elevation_;
324 
325  // Add a part which represents the frame's geometry for clipping purposes
326  context()->CreateFrame(entity_node(), rrect_, color_, opacity_, paint_bounds_,
327  std::move(paint_layers_));
328 }
std::shared_ptr< SceneUpdateContext > context()

Member Function Documentation

◆ AddPaintLayer()

void flutter::SceneUpdateContext::Frame::AddPaintLayer ( Layer layer)

Definition at line 330 of file scene_update_context.cc.

References FML_DCHECK, flutter::Layer::needs_painting(), and flutter::Layer::paint_bounds().

Referenced by flutter::Layer::AutoPrerollSaveLayerState::~AutoPrerollSaveLayerState().

330  {
331  FML_DCHECK(layer->needs_painting());
332  paint_layers_.push_back(layer);
333  paint_bounds_.join(layer->paint_bounds());
334 }
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ embedder_node()

scenic::ContainerNode& flutter::SceneUpdateContext::Frame::embedder_node ( )
inlineoverridevirtual

Reimplemented from flutter::SceneUpdateContext::Entity.

Definition at line 90 of file scene_update_context.h.

90 { return opacity_node_; }

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