Flutter Engine
flutter::ClipRectLayer Class Reference

#include <clip_rect_layer.h>

Inheritance diagram for flutter::ClipRectLayer:
flutter::ContainerLayer flutter::Layer

Public Member Functions

 ClipRectLayer (const SkRect &clip_rect, Clip clip_behavior)
 
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_rect_layer.h.

Constructor & Destructor Documentation

◆ ClipRectLayer()

flutter::ClipRectLayer::ClipRectLayer ( const SkRect &  clip_rect,
Clip  clip_behavior 
)

Definition at line 10 of file clip_rect_layer.cc.

References FML_DCHECK, and flutter::none.

11  : clip_rect_(clip_rect), clip_behavior_(clip_behavior) {
12  FML_DCHECK(clip_behavior != Clip::none);
13 }
#define FML_DCHECK(condition)
Definition: logging.h:86

Member Function Documentation

◆ Paint()

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

Implements flutter::Layer.

Definition at line 50 of file clip_rect_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::ContainerLayer::PaintChildren(), TRACE_EVENT0, TRACE_EVENT_INSTANT0, and UsesSaveLayer().

50  {
51  TRACE_EVENT0("flutter", "ClipRectLayer::Paint");
53 
54  if (!children_inside_clip_) {
55  TRACE_EVENT_INSTANT0("flutter", "children not inside clip rect, skipping");
56  return;
57  }
58 
59  SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
60  context.internal_nodes_canvas->clipRect(clip_rect_,
61  clip_behavior_ != Clip::hardEdge);
62 
63  if (UsesSaveLayer()) {
64  context.internal_nodes_canvas->saveLayer(clip_rect_, nullptr);
65  }
66  PaintChildren(context);
67  if (UsesSaveLayer()) {
68  context.internal_nodes_canvas->restore();
69  if (context.checkerboard_offscreen_layers) {
70  DrawCheckerboard(context.internal_nodes_canvas, clip_rect_);
71  }
72  }
73 }
#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 needs_painting() const
Definition: layer.h:174
bool UsesSaveLayer() const
void DrawCheckerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)
Definition: paint_utils.cc:28
void PaintChildren(PaintContext &context) const

◆ Preroll()

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

Reimplemented from flutter::Layer.

Definition at line 15 of file clip_rect_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::PushClipRect(), flutter::Layer::set_paint_bounds(), TRACE_EVENT0, TRACE_EVENT_INSTANT0, and UsesSaveLayer().

15  {
16  TRACE_EVENT0("flutter", "ClipRectLayer::Preroll");
17 
18  SkRect previous_cull_rect = context->cull_rect;
19  children_inside_clip_ = context->cull_rect.intersect(clip_rect_);
20  if (children_inside_clip_) {
21  TRACE_EVENT_INSTANT0("flutter", "children inside clip rect");
22 
23  Layer::AutoPrerollSaveLayerState save =
25  context->mutators_stack.PushClipRect(clip_rect_);
26  SkRect child_paint_bounds = SkRect::MakeEmpty();
27  PrerollChildren(context, matrix, &child_paint_bounds);
28 
29  if (child_paint_bounds.intersect(clip_rect_)) {
30  set_paint_bounds(child_paint_bounds);
31  }
32  context->mutators_stack.Pop();
33  }
34  context->cull_rect = previous_cull_rect;
35 }
#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)
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
bool UsesSaveLayer() const

◆ UsesSaveLayer()

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

Definition at line 19 of file clip_rect_layer.h.

References flutter::antiAliasWithSaveLayer.

Referenced by Paint(), and Preroll().

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

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