Flutter Engine
flutter::ClipRRectLayer Class Reference

#include <clip_rrect_layer.h>

Inheritance diagram for flutter::ClipRRectLayer:
flutter::ContainerLayer flutter::Layer

Public Member Functions

 ClipRRectLayer (const SkRRect &clip_rrect, 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_rrect_layer.h.

Constructor & Destructor Documentation

◆ ClipRRectLayer()

flutter::ClipRRectLayer::ClipRRectLayer ( const SkRRect &  clip_rrect,
Clip  clip_behavior 
)

Definition at line 10 of file clip_rrect_layer.cc.

References FML_DCHECK, and flutter::none.

11  : clip_rrect_(clip_rrect), 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::ClipRRectLayer::Paint ( PaintContext context) const
overridevirtual

Implements flutter::Layer.

Definition at line 51 of file clip_rrect_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().

51  {
52  TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
54 
55  if (!children_inside_clip_) {
56  TRACE_EVENT_INSTANT0("flutter", "children not inside clip rect, skipping");
57  return;
58  }
59 
60  SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
61  context.internal_nodes_canvas->clipRRect(clip_rrect_,
62  clip_behavior_ != Clip::hardEdge);
63 
64  if (UsesSaveLayer()) {
65  context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr);
66  }
67  PaintChildren(context);
68  if (UsesSaveLayer()) {
69  context.internal_nodes_canvas->restore();
70  if (context.checkerboard_offscreen_layers) {
71  DrawCheckerboard(context.internal_nodes_canvas, paint_bounds());
72  }
73  }
74 }
#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
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::ClipRRectLayer::Preroll ( PrerollContext context,
const SkMatrix &  matrix 
)
overridevirtual

Reimplemented from flutter::Layer.

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

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

◆ UsesSaveLayer()

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

Definition at line 20 of file clip_rrect_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: