Flutter Engine
flutter::ClipPathLayer Class Reference

#include <clip_path_layer.h>

Inheritance diagram for flutter::ClipPathLayer:
flutter::ContainerLayer flutter::Layer

Public Member Functions

 ClipPathLayer (const SkPath &clip_path, Clip clip_behavior=Clip::antiAlias)
 
void Preroll (PrerollContext *context, const SkMatrix &matrix) override
 
void Paint (PaintContext &context) const override
 
bool UsesSaveLayer () const
 
- Public Member Functions inherited from flutter::ContainerLayer
 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
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::ContainerLayer
void PrerollChildren (PrerollContext *context, const SkMatrix &child_matrix, SkRect *child_paint_bounds)
 
void PaintChildren (PaintContext &context) const
 
- Static Protected Member Functions inherited from flutter::ContainerLayer
static void TryToPrepareRasterCache (PrerollContext *context, Layer *layer, const SkMatrix &matrix)
 

Detailed Description

Definition at line 12 of file clip_path_layer.h.

Constructor & Destructor Documentation

◆ ClipPathLayer()

flutter::ClipPathLayer::ClipPathLayer ( const SkPath &  clip_path,
Clip  clip_behavior = Clip::antiAlias 
)

Definition at line 14 of file clip_path_layer.cc.

References FML_DCHECK, and flutter::none.

15  : clip_path_(clip_path), clip_behavior_(clip_behavior) {
16  FML_DCHECK(clip_behavior != Clip::none);
17 }
#define FML_DCHECK(condition)
Definition: logging.h:86

Member Function Documentation

◆ Paint()

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

Implements flutter::Layer.

Definition at line 55 of file clip_path_layer.cc.

References flutter::Layer::PaintContext::checkerboard_offscreen_layers, flutter::DrawCheckerboard(), FML_DCHECK, flutter::hardEdge, flutter::Layer::PaintContext::internal_nodes_canvas, flutter::Layer::needs_painting(), flutter::Layer::paint_bounds(), flutter::ContainerLayer::PaintChildren(), TRACE_EVENT0, TRACE_EVENT_INSTANT0, and UsesSaveLayer().

55  {
56  TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
58 
59  if (!children_inside_clip_) {
60  TRACE_EVENT_INSTANT0("flutter", "children not inside clip rect, skipping");
61  return;
62  }
63 
64  SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
65  context.internal_nodes_canvas->clipPath(clip_path_,
66  clip_behavior_ != Clip::hardEdge);
67 
68  if (UsesSaveLayer()) {
69  context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr);
70  }
71  PaintChildren(context);
72  if (UsesSaveLayer()) {
73  context.internal_nodes_canvas->restore();
74  if (context.checkerboard_offscreen_layers) {
75  DrawCheckerboard(context.internal_nodes_canvas, paint_bounds());
76  }
77  }
78 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define FML_DCHECK(condition)
Definition: logging.h:86
#define TRACE_EVENT_INSTANT0(category_group, name)
Definition: trace_event.h:104
bool UsesSaveLayer() const
bool needs_painting() const
Definition: layer.h:174
const SkRect & paint_bounds() const
Definition: layer.h:166
void DrawCheckerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)
Definition: paint_utils.cc:28
void PaintChildren(PaintContext &context) const

◆ Preroll()

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

Reimplemented from flutter::Layer.

Definition at line 19 of file clip_path_layer.cc.

References flutter::Layer::AutoPrerollSaveLayerState::Create(), flutter::PrerollContext::cull_rect, FML_DCHECK, flutter::PrerollContext::mutators_stack, flutter::Layer::needs_system_composite(), flutter::MutatorsStack::Pop(), flutter::ContainerLayer::PrerollChildren(), flutter::MutatorsStack::PushClipPath(), flutter::Layer::set_paint_bounds(), TRACE_EVENT0, TRACE_EVENT_INSTANT0, and UsesSaveLayer().

19  {
20  TRACE_EVENT0("flutter", "ClipPathLayer::Preroll");
21 
22  SkRect previous_cull_rect = context->cull_rect;
23  SkRect clip_path_bounds = clip_path_.getBounds();
24  children_inside_clip_ = context->cull_rect.intersect(clip_path_bounds);
25  if (children_inside_clip_) {
26  TRACE_EVENT_INSTANT0("flutter", "children inside clip rect");
27 
28  Layer::AutoPrerollSaveLayerState save =
30  context->mutators_stack.PushClipPath(clip_path_);
31  SkRect child_paint_bounds = SkRect::MakeEmpty();
32  PrerollChildren(context, matrix, &child_paint_bounds);
33 
34  if (child_paint_bounds.intersect(clip_path_bounds)) {
35  set_paint_bounds(child_paint_bounds);
36  }
37  context->mutators_stack.Pop();
38  }
39  context->cull_rect = previous_cull_rect;
40 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:75
#define TRACE_EVENT_INSTANT0(category_group, name)
Definition: trace_event.h:104
void PrerollChildren(PrerollContext *context, const SkMatrix &child_matrix, SkRect *child_paint_bounds)
bool UsesSaveLayer() const
static AutoPrerollSaveLayerState Create(PrerollContext *preroll_context, bool save_layer_is_active=true, bool layer_itself_performs_readback=false)
Definition: layer.cc:43
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:170

◆ UsesSaveLayer()

bool flutter::ClipPathLayer::UsesSaveLayer ( ) const
inline

Definition at line 20 of file clip_path_layer.h.

References flutter::antiAliasWithSaveLayer.

Referenced by Paint(), and Preroll().

20  {
21  return clip_behavior_ == Clip::antiAliasWithSaveLayer;
22  }

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