Flutter Engine
flutter::BackdropFilterLayer Class Reference

#include <backdrop_filter_layer.h>

Inheritance diagram for flutter::BackdropFilterLayer:
flutter::ContainerLayer flutter::Layer

Public Member Functions

 BackdropFilterLayer (sk_sp< SkImageFilter > filter, SkBlendMode blend_mode)
 
void Preroll (PrerollContext *context, const SkMatrix &matrix) override
 
void Paint (PaintContext &context) const override
 
- 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 13 of file backdrop_filter_layer.h.

Constructor & Destructor Documentation

◆ BackdropFilterLayer()

flutter::BackdropFilterLayer::BackdropFilterLayer ( sk_sp< SkImageFilter >  filter,
SkBlendMode  blend_mode 
)

Definition at line 9 of file backdrop_filter_layer.cc.

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

11  : filter_(std::move(filter)), blend_mode_(blend_mode) {}

Member Function Documentation

◆ Paint()

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

Implements flutter::Layer.

Definition at line 57 of file backdrop_filter_layer.cc.

References flutter::Layer::AutoSaveLayer::Create(), FML_DCHECK, flutter::Layer::needs_painting(), flutter::Layer::paint_bounds(), flutter::ContainerLayer::PaintChildren(), and TRACE_EVENT0.

57  {
58  TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint");
59  FML_DCHECK(needs_painting(context));
60 
61  SkPaint paint;
62  paint.setBlendMode(blend_mode_);
63  Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create(
64  context,
65  SkCanvas::SaveLayerRec{&paint_bounds(), &paint, filter_.get(), 0},
66  // BackdropFilter should only happen on the leaf nodes canvas.
67  // See https:://flutter.dev/go/backdrop-filter-with-overlay-canvas
68  AutoSaveLayer::SaveMode::kLeafNodesCanvas);
69  PaintChildren(context);
70 }
#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 PaintChildren(PaintContext &context) const
static AutoSaveLayer Create(const PaintContext &paint_context, const SkRect &bounds, const SkPaint *paint, SaveMode save_mode=SaveMode::kInternalNodesCanvas)
Definition: layer.cc:82

◆ Preroll()

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

Reimplemented from flutter::Layer.

Definition at line 47 of file backdrop_filter_layer.cc.

References flutter::Layer::AutoPrerollSaveLayerState::Create(), flutter::PrerollContext::cull_rect, flutter::ContainerLayer::PrerollChildren(), and flutter::Layer::set_paint_bounds().

48  {
49  Layer::AutoPrerollSaveLayerState save =
50  Layer::AutoPrerollSaveLayerState::Create(context, true, bool(filter_));
51  SkRect child_paint_bounds = SkRect::MakeEmpty();
52  PrerollChildren(context, matrix, &child_paint_bounds);
53  child_paint_bounds.join(context->cull_rect);
54  set_paint_bounds(child_paint_bounds);
55 }
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

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