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

#include <opacity_layer.h>

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

Public Member Functions

 OpacityLayer (uint8_t alpha, const DlPoint &offset)
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
bool children_can_accept_opacity () const
 
void set_children_can_accept_opacity (bool value)
 
DlScalar opacity () const
 
- 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 17 of file opacity_layer.h.

Constructor & Destructor Documentation

◆ OpacityLayer()

flutter::OpacityLayer::OpacityLayer ( uint8_t  alpha,
const DlPoint offset 
)

Definition at line 14 of file opacity_layer.cc.

15 : CacheableContainerLayer(std::numeric_limits<int>::max(), true),
16 alpha_(alpha),
17 offset_(offset) {}
CacheableContainerLayer(int layer_cached_threshold=RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer, bool can_cache_children=false)

Member Function Documentation

◆ children_can_accept_opacity()

bool flutter::OpacityLayer::children_can_accept_opacity ( ) const
inline

Definition at line 40 of file opacity_layer.h.

40 {
41 return children_can_accept_opacity_;
42 }

Referenced by Paint(), and Preroll().

◆ Diff()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 19 of file opacity_layer.cc.

19 {
20 DiffContext::AutoSubtreeRestore subtree(context);
21 auto* prev = static_cast<const OpacityLayer*>(old_layer);
22 if (!context->IsSubtreeDirty()) {
23 FML_DCHECK(prev);
24 if (alpha_ != prev->alpha_ || offset_ != prev->offset_) {
25 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
26 }
27 }
28 context->PushTransform(DlMatrix::MakeTranslation(offset_));
29 if (context->has_raster_cache()) {
30 context->WillPaintWithIntegralTransform();
31 }
32 DiffChildren(context, prev);
33 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
34}
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)
OpacityLayer(uint8_t alpha, const DlPoint &offset)
#define FML_DCHECK(condition)
Definition logging.h:122
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition matrix.h:95

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

◆ opacity()

DlScalar flutter::OpacityLayer::opacity ( ) const
inline

Definition at line 47 of file opacity_layer.h.

47{ return DlColor::toOpacity(alpha_); }
static constexpr DlScalar toOpacity(uint8_t alpha)
Definition dl_color.h:65

References flutter::DlColor::toOpacity().

Referenced by Paint(), and Preroll().

◆ Paint()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 71 of file opacity_layer.cc.

71 {
72 FML_DCHECK(needs_painting(context));
73
74 auto mutator = context.state_stack.save();
75 mutator.translate(offset_.x, offset_.y);
76
77#if !SLIMPELLER
78 if (context.raster_cache) {
79 mutator.integralTransform();
80 }
81#endif // !SLIMPELLER
82
83 mutator.applyOpacity(child_paint_bounds(), opacity());
84
85#if !SLIMPELLER
87 DlPaint paint;
88 if (layer_raster_cache_item_->Draw(context,
89 context.state_stack.fill(paint))) {
90 return;
91 }
92 }
93#endif // !SLIMPELLER
94
95 PaintChildren(context);
96}
std::unique_ptr< LayerRasterCacheItem > layer_raster_cache_item_
const DlRect & child_paint_bounds() const
void PaintChildren(PaintContext &context) const override
bool needs_painting(PaintContext &context) const
Definition layer.h:218
bool children_can_accept_opacity() const
DlScalar opacity() const
flutter::DlPaint DlPaint

References flutter::ContainerLayer::child_paint_bounds(), children_can_accept_opacity(), flutter::LayerStateStack::fill(), FML_DCHECK, flutter::CacheableContainerLayer::layer_raster_cache_item_, flutter::Layer::needs_painting(), opacity(), flutter::ContainerLayer::PaintChildren(), flutter::LayerStateStack::save(), flutter::PaintContext::state_stack, flutter::LayerStateStack::MutatorContext::translate(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ Preroll()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 36 of file opacity_layer.cc.

36 {
37 auto mutator = context->state_stack.save();
38 mutator.translate(offset_);
39 mutator.applyOpacity(DlRect(), opacity());
40
41#if !SLIMPELLER
42 AutoCache auto_cache = AutoCache(layer_raster_cache_item_.get(), context,
43 context->state_stack.matrix());
44#endif // !SLIMPELLER
45
46 Layer::AutoPrerollSaveLayerState save =
48
50 // We store the inheritance ability of our children for |Paint|
51 set_children_can_accept_opacity((context->renderable_state_flags &
53 0);
54
55 // Now we let our parent layers know that we, too, can inherit opacity
56 // regardless of what our children are capable of
57 context->renderable_state_flags |= LayerStateStack::kCallerCanApplyOpacity;
58
59 set_paint_bounds(paint_bounds().Shift(offset_));
60
61#if !SLIMPELLER
63 // For opacity layer, we can use raster_cache children only when the
64 // children can't accept opacity so if the children_can_accept_opacity we
65 // should tell the AutoCache object don't do raster_cache.
66 auto_cache.ShouldNotBeCached();
67 }
68#endif // !SLIMPELLER
69}
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
void set_paint_bounds(const DlRect &paint_bounds)
Definition layer.h:209
const DlRect & paint_bounds() const
Definition layer.h:196
static constexpr int kCallerCanApplyOpacity
void set_children_can_accept_opacity(bool value)
impeller::Rect DlRect

References children_can_accept_opacity(), flutter::Layer::AutoPrerollSaveLayerState::Create(), flutter::LayerStateStack::kCallerCanApplyOpacity, flutter::CacheableContainerLayer::layer_raster_cache_item_, flutter::LayerStateStack::matrix(), opacity(), flutter::Layer::paint_bounds(), flutter::ContainerLayer::Preroll(), flutter::PrerollContext::renderable_state_flags, flutter::LayerStateStack::save(), set_children_can_accept_opacity(), flutter::Layer::set_paint_bounds(), flutter::AutoCache::ShouldNotBeCached(), flutter::PrerollContext::state_stack, and flutter::LayerStateStack::MutatorContext::translate().

◆ set_children_can_accept_opacity()

void flutter::OpacityLayer::set_children_can_accept_opacity ( bool  value)
inline

Definition at line 43 of file opacity_layer.h.

43 {
44 children_can_accept_opacity_ = value;
45 }
int32_t value

References value.

Referenced by Preroll().


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