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 ()
 
bool needs_system_composite () const
 
void set_needs_system_composite (bool value)
 
const SkRect & paint_bounds () const
 
void set_paint_bounds (const SkRect &paint_bounds)
 
bool needs_painting () 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.

11 {}

Member Function Documentation

◆ Add()

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

Reimplemented in flutter::MergedContainerLayer.

Definition at line 13 of file container_layer.cc.

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

13  {
14  layers_.emplace_back(std::move(layer));
15 }

◆ 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::OpacityLayer, flutter::PhysicalShapeLayer, flutter::ShaderMaskLayer, flutter::TransformLayer, and flutter::ImageFilterLayer.

Definition at line 25 of file container_layer.cc.

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

25  {
27 
28  PaintChildren(context);
29 }
#define FML_DCHECK(condition)
Definition: logging.h:86
bool needs_painting() const
Definition: layer.h:174
void PaintChildren(PaintContext &context) const

◆ PaintChildren()

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

Definition at line 74 of file container_layer.cc.

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

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

74  {
76 
77  // Intentionally not tracing here as there should be no self-time
78  // and the trace event on this common function has a small overhead.
79  for (auto& layer : layers_) {
80  if (layer->needs_painting()) {
81  layer->Paint(context);
82  }
83  }
84 }
#define FML_DCHECK(condition)
Definition: logging.h:86
bool needs_painting() const
Definition: layer.h:174

◆ Preroll()

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

Reimplemented from flutter::Layer.

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

Definition at line 17 of file container_layer.cc.

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

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

17  {
18  TRACE_EVENT0("flutter", "ContainerLayer::Preroll");
19 
20  SkRect child_paint_bounds = SkRect::MakeEmpty();
21  PrerollChildren(context, matrix, &child_paint_bounds);
22  set_paint_bounds(child_paint_bounds);
23 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
void PrerollChildren(PrerollContext *context, const SkMatrix &child_matrix, SkRect *child_paint_bounds)
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:170

◆ PrerollChildren()

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

Definition at line 31 of file container_layer.cc.

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

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

33  {
34 #if defined(LEGACY_FUCHSIA_EMBEDDER)
35  // If there is embedded Fuchsia content in the scene (a ChildSceneLayer),
36  // Layers that appear above the embedded content will be turned into their own
37  // Scenic layers.
38  child_layer_exists_below_ = context->child_scene_layer_exists_below;
39  context->child_scene_layer_exists_below = false;
40 #endif
41 
42  // Platform views have no children, so context->has_platform_view should
43  // always be false.
44  FML_DCHECK(!context->has_platform_view);
45  bool child_has_platform_view = false;
46  for (auto& layer : layers_) {
47  // Reset context->has_platform_view to false so that layers aren't treated
48  // as if they have a platform view based on one being previously found in a
49  // sibling tree.
50  context->has_platform_view = false;
51 
52  layer->Preroll(context, child_matrix);
53 
54  if (layer->needs_system_composite()) {
56  }
57  child_paint_bounds->join(layer->paint_bounds());
58 
59  child_has_platform_view =
60  child_has_platform_view || context->has_platform_view;
61  }
62 
63  context->has_platform_view = child_has_platform_view;
64 
65 #if defined(LEGACY_FUCHSIA_EMBEDDER)
66  if (child_layer_exists_below_) {
68  }
69  context->child_scene_layer_exists_below =
70  context->child_scene_layer_exists_below || child_layer_exists_below_;
71 #endif
72 }
#define FML_DCHECK(condition)
Definition: logging.h:86
void set_needs_system_composite(bool value)
Definition: layer.h:162

◆ TryToPrepareRasterCache()

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

Definition at line 86 of file container_layer.cc.

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

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

88  {
89  if (!context->has_platform_view && context->raster_cache &&
90  SkRect::Intersects(context->cull_rect, layer->paint_bounds())) {
91  context->raster_cache->Prepare(context, layer, matrix);
92  }
93 }

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