Flutter Engine
flutter::ContainerLayer Class Reference

#include <container_layer.h>

Inheritance diagram for flutter::ContainerLayer:
flutter::Layer flutter::BackdropFilterLayer flutter::ClipPathLayer flutter::ClipRectLayer flutter::ClipRRectLayer flutter::ColorFilterLayer flutter::MergedContainerLayer flutter::PhysicalShapeLayer flutter::ShaderMaskLayer flutter::TransformLayer

Public Member Functions

 ContainerLayer ()
 
virtual void Add (std::shared_ptr< Layer > layer)
 
void Preroll (PrerollContext *context, const SkMatrix &matrix) override
 
void Paint (PaintContext &context) const override
 
const std::vector< std::shared_ptr< Layer > > & layers () const
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
void AssignOldLayer (Layer *old_layer)
 
bool subtree_has_platform_view () const
 
void set_subtree_has_platform_view (bool value)
 
const SkRect & paint_bounds () const
 
void set_paint_bounds (const SkRect &paint_bounds)
 
bool is_empty () const
 
bool needs_painting (PaintContext &context) const
 
uint64_t original_layer_id () const
 
uint64_t unique_id () const
 

Protected Member Functions

void PrerollChildren (PrerollContext *context, const SkMatrix &child_matrix, SkRect *child_paint_bounds)
 
void PaintChildren (PaintContext &context) const
 

Static Protected Member Functions

static void TryToPrepareRasterCache (PrerollContext *context, Layer *layer, const SkMatrix &matrix)
 

Detailed Description

Definition at line 14 of file container_layer.h.

Constructor & Destructor Documentation

◆ ContainerLayer()

flutter::ContainerLayer::ContainerLayer ( )

Definition at line 11 of file container_layer.cc.

References FML_DCHECK.

11 {}

Member Function Documentation

◆ Add()

void flutter::ContainerLayer::Add ( std::shared_ptr< Layer layer)
virtual

Reimplemented in flutter::MergedContainerLayer.

Definition at line 109 of file container_layer.cc.

Referenced by flutter::MergedContainerLayer::MergedContainerLayer().

109  {
110  layers_.emplace_back(std::move(layer));
111 }

◆ layers()

const std::vector<std::shared_ptr<Layer> >& flutter::ContainerLayer::layers ( ) const
inline

◆ Paint()

void flutter::ContainerLayer::Paint ( PaintContext context) const
overridevirtual

Implements flutter::Layer.

Reimplemented in flutter::PhysicalShapeLayer, flutter::OpacityLayer, flutter::ShaderMaskLayer, flutter::TransformLayer, and flutter::ImageFilterLayer.

Definition at line 121 of file container_layer.cc.

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

121  {
122  FML_DCHECK(needs_painting(context));
123 
124  PaintChildren(context);
125 }
#define FML_DCHECK(condition)
Definition: logging.h:86
bool needs_painting(PaintContext &context) const
Definition: layer.h:249
void PaintChildren(PaintContext &context) const

◆ PaintChildren()

void flutter::ContainerLayer::PaintChildren ( PaintContext context) const
protected

Definition at line 155 of file container_layer.cc.

Referenced by layers(), flutter::ClipRectLayer::Paint(), flutter::ClipRRectLayer::Paint(), flutter::ClipPathLayer::Paint(), flutter::BackdropFilterLayer::Paint(), flutter::ImageFilterLayer::Paint(), flutter::ColorFilterLayer::Paint(), flutter::TransformLayer::Paint(), flutter::ShaderMaskLayer::Paint(), Paint(), flutter::OpacityLayer::Paint(), and flutter::PhysicalShapeLayer::Paint().

155  {
156  // We can no longer call FML_DCHECK here on the needs_painting(context)
157  // condition as that test is only valid for the PaintContext that
158  // is initially handed to a layer's Paint() method. By the time the
159  // layer calls PaintChildren(), though, it may have modified the
160  // PaintContext so the test doesn't work in this "context".
161 
162  // Intentionally not tracing here as there should be no self-time
163  // and the trace event on this common function has a small overhead.
164  for (auto& layer : layers_) {
165  if (layer->needs_painting(context)) {
166  layer->Paint(context);
167  }
168  }
169 }

◆ Preroll()

void flutter::ContainerLayer::Preroll ( PrerollContext context,
const SkMatrix &  matrix 
)
overridevirtual

Reimplemented from flutter::Layer.

Reimplemented in flutter::PhysicalShapeLayer, flutter::OpacityLayer, flutter::ShaderMaskLayer, flutter::TransformLayer, and flutter::ImageFilterLayer.

Definition at line 113 of file container_layer.cc.

References PrerollChildren(), flutter::Layer::set_paint_bounds(), and TRACE_EVENT0.

Referenced by flutter::ColorFilterLayer::Preroll(), flutter::ShaderMaskLayer::Preroll(), and flutter::OpacityLayer::Preroll().

113  {
114  TRACE_EVENT0("flutter", "ContainerLayer::Preroll");
115 
116  SkRect child_paint_bounds = SkRect::MakeEmpty();
117  PrerollChildren(context, matrix, &child_paint_bounds);
118  set_paint_bounds(child_paint_bounds);
119 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
void PrerollChildren(PrerollContext *context, const SkMatrix &child_matrix, SkRect *child_paint_bounds)
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:240

◆ PrerollChildren()

void flutter::ContainerLayer::PrerollChildren ( PrerollContext context,
const SkMatrix &  child_matrix,
SkRect *  child_paint_bounds 
)
protected

Definition at line 127 of file container_layer.cc.

References FML_DCHECK, flutter::PrerollContext::has_platform_view, flutter::PrerollContext::has_texture_layer, and flutter::Layer::set_subtree_has_platform_view().

Referenced by layers(), flutter::ClipRRectLayer::Preroll(), flutter::ClipPathLayer::Preroll(), flutter::ClipRectLayer::Preroll(), flutter::BackdropFilterLayer::Preroll(), flutter::ImageFilterLayer::Preroll(), flutter::TransformLayer::Preroll(), Preroll(), and flutter::PhysicalShapeLayer::Preroll().

129  {
130  // Platform views have no children, so context->has_platform_view should
131  // always be false.
132  FML_DCHECK(!context->has_platform_view);
133  bool child_has_platform_view = false;
134  bool child_has_texture_layer = false;
135  for (auto& layer : layers_) {
136  // Reset context->has_platform_view to false so that layers aren't treated
137  // as if they have a platform view based on one being previously found in a
138  // sibling tree.
139  context->has_platform_view = false;
140 
141  layer->Preroll(context, child_matrix);
142  child_paint_bounds->join(layer->paint_bounds());
143 
144  child_has_platform_view =
145  child_has_platform_view || context->has_platform_view;
146  child_has_texture_layer =
147  child_has_texture_layer || context->has_texture_layer;
148  }
149 
150  context->has_platform_view = child_has_platform_view;
151  context->has_texture_layer = child_has_texture_layer;
152  set_subtree_has_platform_view(child_has_platform_view);
153 }
void set_subtree_has_platform_view(bool value)
Definition: layer.h:219
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ TryToPrepareRasterCache()

void flutter::ContainerLayer::TryToPrepareRasterCache ( PrerollContext context,
Layer layer,
const SkMatrix &  matrix 
)
staticprotected

Definition at line 171 of file container_layer.cc.

References flutter::PrerollContext::cull_rect, flutter::PrerollContext::has_platform_view, flutter::PrerollContext::has_texture_layer, flutter::Layer::paint_bounds(), flutter::RasterCache::Prepare(), and flutter::PrerollContext::raster_cache.

Referenced by layers(), flutter::ImageFilterLayer::Preroll(), and flutter::OpacityLayer::Preroll().

173  {
174  if (!context->has_platform_view && !context->has_texture_layer &&
175  context->raster_cache &&
176  SkRect::Intersects(context->cull_rect, layer->paint_bounds())) {
177  context->raster_cache->Prepare(context, layer, matrix);
178  }
179 }

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