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 ()
 
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
 

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 57 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, and UsesSaveLayer().

57  {
58  TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
59  FML_DCHECK(needs_painting(context));
60 
61  SkAutoCanvasRestore save(context.internal_nodes_canvas, true);
62  context.internal_nodes_canvas->clipRRect(clip_rrect_,
63  clip_behavior_ != Clip::hardEdge);
64 
65  if (UsesSaveLayer()) {
66  context.internal_nodes_canvas->saveLayer(paint_bounds(), nullptr);
67  }
68  PaintChildren(context);
69  if (UsesSaveLayer()) {
70  context.internal_nodes_canvas->restore();
71  if (context.checkerboard_offscreen_layers) {
72  DrawCheckerboard(context.internal_nodes_canvas, paint_bounds());
73  }
74  }
75 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
#define FML_DCHECK(condition)
Definition: logging.h:86
bool needs_painting(PaintContext &context) const
Definition: layer.h:249
const SkRect & paint_bounds() const
Definition: layer.h:227
void DrawCheckerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)
Definition: paint_utils.cc:29
void PaintChildren(PaintContext &context) const

◆ Preroll()

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

Reimplemented from flutter::Layer.

Definition at line 35 of file clip_rrect_layer.cc.

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

35  {
36  TRACE_EVENT0("flutter", "ClipRRectLayer::Preroll");
37 
38  SkRect previous_cull_rect = context->cull_rect;
39  SkRect clip_rrect_bounds = clip_rrect_.getBounds();
40  if (!context->cull_rect.intersect(clip_rrect_bounds)) {
41  context->cull_rect.setEmpty();
42  }
43  Layer::AutoPrerollSaveLayerState save =
45  context->mutators_stack.PushClipRRect(clip_rrect_);
46 
47  SkRect child_paint_bounds = SkRect::MakeEmpty();
48  PrerollChildren(context, matrix, &child_paint_bounds);
49  if (child_paint_bounds.intersect(clip_rrect_bounds)) {
50  set_paint_bounds(child_paint_bounds);
51  }
52 
53  context->mutators_stack.Pop();
54  context->cull_rect = previous_cull_rect;
55 }
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:90
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:44
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:240

◆ UsesSaveLayer()

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

Definition at line 26 of file clip_rrect_layer.h.

References flutter::antiAliasWithSaveLayer.

Referenced by Paint(), and Preroll().

26  {
27  return clip_behavior_ == Clip::antiAliasWithSaveLayer;
28  }

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