Flutter Engine
 
Loading...
Searching...
No Matches
flutter::BackdropFilterLayer Class Reference

#include <backdrop_filter_layer.h>

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

Public Member Functions

 BackdropFilterLayer (const std::shared_ptr< DlImageFilter > &filter, DlBlendMode blend_mode, std::optional< int64_t > backdrop_id=std::nullopt)
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
- Public Member Functions inherited from flutter::ContainerLayer
 ContainerLayer ()
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
void PreservePaintRegion (DiffContext *context) override
 
virtual void Add (std::shared_ptr< Layer > layer)
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
const std::vector< std::shared_ptr< Layer > > & layers () const
 
virtual void DiffChildren (DiffContext *context, const ContainerLayer *old_layer)
 
void PaintChildren (PaintContext &context) const override
 
const ContainerLayeras_container_layer () const override
 
const DlRectchild_paint_bounds () const
 
void set_child_paint_bounds (const DlRect &bounds)
 
int children_renderable_state_flags () const
 
void set_children_renderable_state_flags (int flags)
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
void AssignOldLayer (Layer *old_layer)
 
virtual bool IsReplacing (DiffContext *context, const Layer *old_layer) const
 
bool subtree_has_platform_view () const
 
void set_subtree_has_platform_view (bool value)
 
const DlRectpaint_bounds () const
 
void set_paint_bounds (const DlRect &paint_bounds)
 
bool is_empty () const
 
bool needs_painting (PaintContext &context) const
 
uint64_t original_layer_id () const
 
uint64_t unique_id () const
 
virtual RasterCacheKeyID caching_key_id () const
 
virtual const DisplayListLayeras_display_list_layer () const
 
virtual const TextureLayeras_texture_layer () const
 
virtual const PerformanceOverlayLayeras_performance_overlay_layer () const
 
virtual const testing::MockLayeras_mock_layer () const
 

Additional Inherited Members

- Static Public Attributes inherited from flutter::Layer
static constexpr int kSaveLayerRenderFlags
 
static constexpr int kRasterCacheRenderFlags
 
- Protected Member Functions inherited from flutter::ContainerLayer
void PrerollChildren (PrerollContext *context, DlRect *child_paint_bounds)
 

Detailed Description

Definition at line 12 of file backdrop_filter_layer.h.

Constructor & Destructor Documentation

◆ BackdropFilterLayer()

flutter::BackdropFilterLayer::BackdropFilterLayer ( const std::shared_ptr< DlImageFilter > &  filter,
DlBlendMode  blend_mode,
std::optional< int64_t >  backdrop_id = std::nullopt 
)

Definition at line 9 of file backdrop_filter_layer.cc.

13 : filter_(filter), blend_mode_(blend_mode), backdrop_id_(backdrop_id) {}

Member Function Documentation

◆ Diff()

void flutter::BackdropFilterLayer::Diff ( DiffContext context,
const Layer old_layer 
)
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 15 of file backdrop_filter_layer.cc.

15 {
16 DiffContext::AutoSubtreeRestore subtree(context);
17 auto* prev = static_cast<const BackdropFilterLayer*>(old_layer);
18 if (!context->IsSubtreeDirty()) {
19 FML_DCHECK(prev);
20 if (NotEquals(filter_, prev->filter_)) {
21 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
22 }
23 }
24
25 // Backdrop filter paints everywhere in cull rect
26 auto paint_bounds = context->GetCullRect();
27 context->AddLayerBounds(paint_bounds);
28
29 if (filter_) {
30 paint_bounds = context->MapRect(paint_bounds);
31 auto filter_target_bounds = DlIRect::RoundOut(paint_bounds);
32 DlIRect filter_input_bounds; // in screen coordinates
33 filter_->get_input_device_bounds(filter_target_bounds, context->GetMatrix(),
34 filter_input_bounds);
35 context->AddReadbackRegion(filter_target_bounds, filter_input_bounds);
36 }
37
38 DiffChildren(context, prev);
39
40 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
41}
BackdropFilterLayer(const std::shared_ptr< DlImageFilter > &filter, DlBlendMode blend_mode, std::optional< int64_t > backdrop_id=std::nullopt)
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)
const DlRect & paint_bounds() const
Definition layer.h:196
#define FML_DCHECK(condition)
Definition logging.h:122
impeller::IRect32 DlIRect
bool NotEquals(const T *a, const U *b)
RoundOut(const TRect< U > &r)
Definition rect.h:679

References flutter::DiffContext::AddLayerBounds(), flutter::DiffContext::AddReadbackRegion(), flutter::DiffContext::CurrentSubtreeRegion(), flutter::ContainerLayer::DiffChildren(), FML_DCHECK, flutter::DiffContext::GetCullRect(), flutter::DiffContext::GetMatrix(), flutter::DiffContext::GetOldLayerPaintRegion(), flutter::DiffContext::IsSubtreeDirty(), flutter::DiffContext::MapRect(), flutter::DiffContext::MarkSubtreeDirty(), flutter::NotEquals(), flutter::Layer::paint_bounds(), impeller::TRect< T >::RoundOut(), and flutter::DiffContext::SetLayerPaintRegion().

◆ Paint()

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

Implements flutter::Layer.

Definition at line 58 of file backdrop_filter_layer.cc.

58 {
59 FML_DCHECK(needs_painting(context));
60
61 auto mutator = context.state_stack.save();
62 mutator.applyBackdropFilter(paint_bounds(), filter_, blend_mode_,
63 backdrop_id_);
64
65 PaintChildren(context);
66}
void PaintChildren(PaintContext &context) const override
bool needs_painting(PaintContext &context) const
Definition layer.h:218

References flutter::LayerStateStack::MutatorContext::applyBackdropFilter(), FML_DCHECK, flutter::Layer::needs_painting(), flutter::Layer::paint_bounds(), flutter::ContainerLayer::PaintChildren(), flutter::LayerStateStack::save(), and flutter::PaintContext::state_stack.

◆ Preroll()

void flutter::BackdropFilterLayer::Preroll ( PrerollContext context)
overridevirtual

Implements flutter::Layer.

Definition at line 43 of file backdrop_filter_layer.cc.

43 {
44 Layer::AutoPrerollSaveLayerState save =
45 Layer::AutoPrerollSaveLayerState::Create(context, true, bool{filter_});
46 if (filter_ && context->view_embedder != nullptr) {
47 context->view_embedder->PushFilterToVisitedPlatformViews(
48 filter_, context->state_stack.device_cull_rect());
49 }
53 child_paint_bounds.Union(context->state_stack.local_cull_rect());
55 context->renderable_state_flags = kSaveLayerRenderFlags;
56}
const DlRect & child_paint_bounds() const
void PrerollChildren(PrerollContext *context, DlRect *child_paint_bounds)
static AutoPrerollSaveLayerState Create(PrerollContext *preroll_context, bool save_layer_is_active=true, bool layer_itself_performs_readback=false)
Definition layer.cc:37
static constexpr int kSaveLayerRenderFlags
Definition layer.h:118
void set_paint_bounds(const DlRect &paint_bounds)
Definition layer.h:209
impeller::Rect DlRect
constexpr TRect Union(const TRect &o) const
Definition rect.h:513

References flutter::ContainerLayer::child_paint_bounds(), flutter::Layer::AutoPrerollSaveLayerState::Create(), flutter::LayerStateStack::device_cull_rect(), flutter::Layer::kSaveLayerRenderFlags, flutter::LayerStateStack::local_cull_rect(), flutter::ContainerLayer::PrerollChildren(), flutter::ExternalViewEmbedder::PushFilterToVisitedPlatformViews(), flutter::PrerollContext::renderable_state_flags, flutter::Layer::set_paint_bounds(), flutter::PrerollContext::state_stack, impeller::TRect< T >::Union(), and flutter::PrerollContext::view_embedder.


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