Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::OpacityLayer Class Reference

#include <opacity_layer.h>

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

Public Member Functions

 OpacityLayer (SkAlpha alpha, const SkPoint &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)
 
SkScalar 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 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 SkRectchild_paint_bounds () const
 
void set_child_paint_bounds (const SkRect &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
 
virtual void Diff (DiffContext *context, const Layer *old_layer)
 
virtual void PreservePaintRegion (DiffContext *context)
 
virtual void Preroll (PrerollContext *context)=0
 
virtual void Paint (PaintContext &context) const =0
 
virtual void PaintChildren (PaintContext &context) const
 
bool subtree_has_platform_view () const
 
void set_subtree_has_platform_view (bool value)
 
const SkRectpaint_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
 
virtual RasterCacheKeyID caching_key_id () const
 
virtual const ContainerLayeras_container_layer () 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, SkRect *child_paint_bounds)
 
- Protected Attributes inherited from flutter::CacheableContainerLayer
std::unique_ptr< LayerRasterCacheItemlayer_raster_cache_item_
 

Detailed Description

Definition at line 18 of file opacity_layer.h.

Constructor & Destructor Documentation

◆ OpacityLayer()

flutter::OpacityLayer::OpacityLayer ( SkAlpha  alpha,
const SkPoint offset 
)

Definition at line 15 of file opacity_layer.cc.

17 alpha_(alpha),
18 offset_(offset) {}
CacheableContainerLayer(int layer_cached_threshold=RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer, bool can_cache_children=false)
static float max(float r, float g, float b)
Definition: hsl.cpp:49
SeparatedVector2 offset

Member Function Documentation

◆ children_can_accept_opacity()

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

Definition at line 41 of file opacity_layer.h.

41 {
42 return children_can_accept_opacity_;
43 }

◆ Diff()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 20 of file opacity_layer.cc.

20 {
21 DiffContext::AutoSubtreeRestore subtree(context);
22 auto* prev = static_cast<const OpacityLayer*>(old_layer);
23 if (!context->IsSubtreeDirty()) {
25 if (alpha_ != prev->alpha_ || offset_ != prev->offset_) {
26 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
27 }
28 }
29 context->PushTransform(SkMatrix::Translate(offset_.fX, offset_.fY));
30 if (context->has_raster_cache()) {
31 context->WillPaintWithIntegralTransform();
32 }
33 DiffChildren(context, prev);
34 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
35}
static float prev(float f)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)
OpacityLayer(SkAlpha alpha, const SkPoint &offset)
#define FML_DCHECK(condition)
Definition: logging.h:103
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ opacity()

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

Definition at line 48 of file opacity_layer.h.

48{ return alpha_ * 1.0f / SK_AlphaOPAQUE; }
constexpr SkAlpha SK_AlphaOPAQUE
Definition: SkColor.h:94

◆ Paint()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 72 of file opacity_layer.cc.

72 {
73 FML_DCHECK(needs_painting(context));
74
75 auto mutator = context.state_stack.save();
76 mutator.translate(offset_.fX, offset_.fY);
77
78#if !SLIMPELLER
79 if (context.raster_cache) {
80 mutator.integralTransform();
81 }
82#endif // !SLIMPELLER
83
84 mutator.applyOpacity(child_paint_bounds(), opacity());
85
86#if !SLIMPELLER
89 if (layer_raster_cache_item_->Draw(context,
90 context.state_stack.fill(paint))) {
91 return;
92 }
93 }
94#endif // !SLIMPELLER
95
96 PaintChildren(context);
97}
std::unique_ptr< LayerRasterCacheItem > layer_raster_cache_item_
void PaintChildren(PaintContext &context) const override
const SkRect & child_paint_bounds() const
bool needs_painting(PaintContext &context) const
Definition: layer.h:232
SkScalar opacity() const
Definition: opacity_layer.h:48
bool children_can_accept_opacity() const
Definition: opacity_layer.h:41
const Paint & paint
Definition: color_source.cc:38
flutter::DlPaint DlPaint

◆ Preroll()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 37 of file opacity_layer.cc.

37 {
38 auto mutator = context->state_stack.save();
39 mutator.translate(offset_);
40 mutator.applyOpacity(SkRect(), DlColor::toOpacity(alpha_));
41
42#if !SLIMPELLER
43 AutoCache auto_cache = AutoCache(layer_raster_cache_item_.get(), context,
44 context->state_stack.transform_3x3());
45#endif // !SLIMPELLER
46
47 Layer::AutoPrerollSaveLayerState save =
49
51 // We store the inheritance ability of our children for |Paint|
52 set_children_can_accept_opacity((context->renderable_state_flags &
54 0);
55
56 // Now we let our parent layers know that we, too, can inherit opacity
57 // regardless of what our children are capable of
58 context->renderable_state_flags |= LayerStateStack::kCallerCanApplyOpacity;
59
60 set_paint_bounds(paint_bounds().makeOffset(offset_.fX, offset_.fY));
61
62#if !SLIMPELLER
64 // For opacity layer, we can use raster_cache children only when the
65 // children can't accept opacity so if the children_can_accept_opacity we
66 // should tell the AutoCache object don't do raster_cache.
67 auto_cache.ShouldNotBeCached();
68 }
69#endif // !SLIMPELLER
70}
void Preroll(PrerollContext *context) override
static constexpr int kCallerCanApplyOpacity
static AutoPrerollSaveLayerState Create(PrerollContext *preroll_context, bool save_layer_is_active=true, bool layer_itself_performs_readback=false)
Definition: layer.cc:40
const SkRect & paint_bounds() const
Definition: layer.h:210
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:223
void set_children_can_accept_opacity(bool value)
Definition: opacity_layer.h:44
static constexpr SkScalar toOpacity(uint8_t alpha)
Definition: dl_color.h:18

◆ set_children_can_accept_opacity()

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

Definition at line 44 of file opacity_layer.h.

44 {
45 children_can_accept_opacity_ = value;
46 }
uint8_t value

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