Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 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 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
 
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 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.

16 : CacheableContainerLayer(std::numeric_limits<int>::max(), true),
17 alpha_(alpha),
18 offset_(offset) {}
CacheableContainerLayer(int layer_cached_threshold=RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer, bool can_cache_children=false)
Point 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
float fY
y-axis value

◆ 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 67 of file opacity_layer.cc.

67 {
68 FML_DCHECK(needs_painting(context));
69
70 auto mutator = context.state_stack.save();
71 mutator.translate(offset_.fX, offset_.fY);
72 if (context.raster_cache) {
73 mutator.integralTransform();
74 }
75
76 mutator.applyOpacity(child_paint_bounds(), opacity());
77
79 DlPaint paint;
80 if (layer_raster_cache_item_->Draw(context,
81 context.state_stack.fill(paint))) {
82 return;
83 }
84 }
85
86 PaintChildren(context);
87}
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:231
SkScalar opacity() const
bool children_can_accept_opacity() const
const Paint & paint

◆ 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 AutoCache auto_cache = AutoCache(layer_raster_cache_item_.get(), context,
43 context->state_stack.transform_3x3());
44 Layer::AutoPrerollSaveLayerState save =
46
48 // We store the inheritance ability of our children for |Paint|
49 set_children_can_accept_opacity((context->renderable_state_flags &
51 0);
52
53 // Now we let our parent layers know that we, too, can inherit opacity
54 // regardless of what our children are capable of
55 context->renderable_state_flags |= LayerStateStack::kCallerCanApplyOpacity;
56
57 set_paint_bounds(paint_bounds().makeOffset(offset_.fX, offset_.fY));
58
60 // For opacity layer, we can use raster_cache children only when the
61 // children can't accept opacity so if the children_can_accept_opacity we
62 // should tell the AutoCache object don't do raster_cache.
63 auto_cache.ShouldNotBeCached();
64 }
65}
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:209
void set_paint_bounds(const SkRect &paint_bounds)
Definition layer.h:222
void set_children_can_accept_opacity(bool value)
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: