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

#include <shader_mask_layer.h>

Inheritance diagram for flutter::ShaderMaskLayer:
flutter::CacheableContainerLayer flutter::ContainerLayer flutter::Layer

Public Member Functions

 ShaderMaskLayer (std::shared_ptr< DlColorSource > color_source, const DlRect &mask_rect, DlBlendMode blend_mode)
 
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::CacheableContainerLayer
 CacheableContainerLayer (int layer_cached_threshold=RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer, bool can_cache_children=false)
 
const LayerRasterCacheItemraster_cache_item () const
 
- Public Member Functions inherited from flutter::ContainerLayer
 ContainerLayer ()
 
void PreservePaintRegion (DiffContext *context) override
 
virtual void Add (std::shared_ptr< Layer > layer)
 
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)
 
- Protected Attributes inherited from flutter::CacheableContainerLayer
std::unique_ptr< LayerRasterCacheItemlayer_raster_cache_item_
 

Detailed Description

Definition at line 13 of file shader_mask_layer.h.

Constructor & Destructor Documentation

◆ ShaderMaskLayer()

flutter::ShaderMaskLayer::ShaderMaskLayer ( std::shared_ptr< DlColorSource color_source,
const DlRect mask_rect,
DlBlendMode  blend_mode 
)

Definition at line 10 of file shader_mask_layer.cc.

15 color_source_(std::move(color_source)),
16 mask_rect_(mask_rect),
17 blend_mode_(blend_mode) {}
CacheableContainerLayer(int layer_cached_threshold=RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer, bool can_cache_children=false)
static constexpr int kMinimumRendersBeforeCachingFilterLayer

Member Function Documentation

◆ Diff()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 19 of file shader_mask_layer.cc.

19 {
20 DiffContext::AutoSubtreeRestore subtree(context);
21 auto* prev = static_cast<const ShaderMaskLayer*>(old_layer);
22 if (!context->IsSubtreeDirty()) {
23 FML_DCHECK(prev);
24 if (color_source_ != prev->color_source_ ||
25 mask_rect_ != prev->mask_rect_ || blend_mode_ != prev->blend_mode_) {
26 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
27 }
28 }
29 if (context->has_raster_cache()) {
30 context->WillPaintWithIntegralTransform();
31 }
32 DiffChildren(context, prev);
33
34 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
35}
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)
ShaderMaskLayer(std::shared_ptr< DlColorSource > color_source, const DlRect &mask_rect, DlBlendMode blend_mode)
#define FML_DCHECK(condition)
Definition logging.h:122

References flutter::DiffContext::CurrentSubtreeRegion(), flutter::ContainerLayer::DiffChildren(), FML_DCHECK, flutter::DiffContext::GetOldLayerPaintRegion(), flutter::DiffContext::has_raster_cache(), flutter::DiffContext::IsSubtreeDirty(), flutter::DiffContext::MarkSubtreeDirty(), flutter::DiffContext::SetLayerPaintRegion(), and flutter::DiffContext::WillPaintWithIntegralTransform().

◆ Paint()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 50 of file shader_mask_layer.cc.

50 {
51 FML_DCHECK(needs_painting(context));
52
53 auto mutator = context.state_stack.save();
54
55#if !SLIMPELLER
56 if (context.raster_cache) {
57 mutator.integralTransform();
58
59 DlPaint paint;
60 if (layer_raster_cache_item_->Draw(context,
61 context.state_stack.fill(paint))) {
62 return;
63 }
64 }
65#endif // !SLIMPELLER
66 auto shader_rect = DlRect::MakeSize(mask_rect_.GetSize());
67
68 mutator.saveLayer(paint_bounds());
69
70 PaintChildren(context);
71
72 DlPaint dl_paint;
73 dl_paint.setBlendMode(blend_mode_);
74 if (color_source_) {
75 dl_paint.setColorSource(color_source_.get());
76 }
77 context.canvas->Translate(mask_rect_.GetLeft(), mask_rect_.GetTop());
78 context.canvas->DrawRect(shader_rect, dl_paint);
79}
std::unique_ptr< LayerRasterCacheItem > layer_raster_cache_item_
void PaintChildren(PaintContext &context) const override
DlPaint & setBlendMode(DlBlendMode mode)
Definition dl_paint.h:85
DlPaint & setColorSource(std::nullptr_t source)
Definition dl_paint.h:131
bool needs_painting(PaintContext &context) const
Definition layer.h:218
const DlRect & paint_bounds() const
Definition layer.h:196
flutter::DlPaint DlPaint
constexpr auto GetTop() const
Definition rect.h:353
constexpr TSize< Type > GetSize() const
Returns the size of the rectangle which may be negative in either width or height and may have been c...
Definition rect.h:327
constexpr auto GetLeft() const
Definition rect.h:351
static constexpr TRect MakeSize(const TSize< U > &size)
Definition rect.h:150

References flutter::PaintContext::canvas, flutter::DlCanvas::DrawRect(), flutter::LayerStateStack::fill(), FML_DCHECK, impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetSize(), impeller::TRect< T >::GetTop(), flutter::LayerStateStack::MutatorContext::integralTransform(), flutter::CacheableContainerLayer::layer_raster_cache_item_, impeller::TRect< Scalar >::MakeSize(), flutter::Layer::needs_painting(), flutter::Layer::paint_bounds(), flutter::ContainerLayer::PaintChildren(), flutter::LayerStateStack::save(), flutter::DlPaint::setBlendMode(), flutter::DlPaint::setColorSource(), flutter::PaintContext::state_stack, and flutter::DlCanvas::Translate().

◆ Preroll()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 37 of file shader_mask_layer.cc.

37 {
38 Layer::AutoPrerollSaveLayerState save =
40#if !SLIMPELLER
41 AutoCache cache = AutoCache(layer_raster_cache_item_.get(), context,
42 context->state_stack.matrix());
43#endif // !SLIMPELLER
45 // We always paint with a saveLayer (or a cached rendering),
46 // so we can always apply opacity in any of those cases.
47 context->renderable_state_flags = kSaveLayerRenderFlags;
48}
void Preroll(PrerollContext *context) override
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

References flutter::Layer::AutoPrerollSaveLayerState::Create(), flutter::Layer::kSaveLayerRenderFlags, flutter::CacheableContainerLayer::layer_raster_cache_item_, flutter::LayerStateStack::matrix(), flutter::ContainerLayer::Preroll(), flutter::PrerollContext::renderable_state_flags, and flutter::PrerollContext::state_stack.


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