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

#include <image_filter_layer.h>

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

Public Member Functions

 ImageFilterLayer (std::shared_ptr< const DlImageFilter > filter, const SkPoint &offset=SkPoint::Make(0, 0))
 
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 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 13 of file image_filter_layer.h.

Constructor & Destructor Documentation

◆ ImageFilterLayer()

flutter::ImageFilterLayer::ImageFilterLayer ( std::shared_ptr< const DlImageFilter filter,
const SkPoint offset = SkPoint::Make(0, 0) 
)
explicit

Definition at line 13 of file image_filter_layer.cc.

17 offset_(offset),
18 filter_(std::move(filter)),
19 transformed_filter_(nullptr) {}
CacheableContainerLayer(int layer_cached_threshold=RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer, bool can_cache_children=false)
SeparatedVector2 offset
static constexpr int kMinimumRendersBeforeCachingFilterLayer

Member Function Documentation

◆ Diff()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 21 of file image_filter_layer.cc.

21 {
22 DiffContext::AutoSubtreeRestore subtree(context);
23 auto* prev = static_cast<const ImageFilterLayer*>(old_layer);
24 if (!context->IsSubtreeDirty()) {
26 if (NotEquals(filter_, prev->filter_) || offset_ != prev->offset_) {
27 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
28 }
29 }
30
31 context->PushTransform(SkMatrix::Translate(offset_.fX, offset_.fY));
32 if (context->has_raster_cache()) {
33 context->WillPaintWithIntegralTransform();
34 }
35
36 if (filter_) {
37 auto filter = filter_->makeWithLocalMatrix(context->GetTransform3x3());
38 if (filter) {
39 // This transform will be applied to every child rect in the subtree
40 context->PushFilterBoundsAdjustment([filter](SkRect rect) {
41 SkIRect filter_out_bounds;
42 filter->map_device_bounds(rect.roundOut(), SkMatrix::I(),
43 filter_out_bounds);
44 return SkRect::Make(filter_out_bounds);
45 });
46 }
47 }
48 DiffChildren(context, prev);
49 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
50}
static float prev(float f)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)
ImageFilterLayer(std::shared_ptr< const DlImageFilter > filter, const SkPoint &offset=SkPoint::Make(0, 0))
#define FML_DCHECK(condition)
Definition: logging.h:103
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
bool NotEquals(const T *a, const T *b)
Definition: dl_comparable.h:70
Definition: SkRect.h:32
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ Paint()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 106 of file image_filter_layer.cc.

106 {
107 FML_DCHECK(needs_painting(context));
108
109 auto mutator = context.state_stack.save();
110
111#if !SLIMPELLER
112 if (context.raster_cache) {
113 // Try drawing the layer cache item from the cache before applying the
114 // image filter if it was cached with the filter applied.
115 if (!layer_raster_cache_item_->IsCacheChildren()) {
117 if (layer_raster_cache_item_->Draw(context,
118 context.state_stack.fill(paint))) {
119 return;
120 }
121 }
122 }
123#endif // !SLIMPELLER
124
125 // Only apply the offset if not being raster-cached to avoid the offset being
126 // applied twice.
127 mutator.translate(offset_);
128
129#if !SLIMPELLER
130 if (context.raster_cache) {
131 mutator.integralTransform();
132 }
133
134 if (context.raster_cache && layer_raster_cache_item_->IsCacheChildren()) {
135 // If we render the children from cache then we need the special
136 // transformed version of the filter so we must process it into the
137 // cache paint object manually.
138 FML_DCHECK(transformed_filter_ != nullptr);
140 context.state_stack.fill(paint);
141 paint.setImageFilter(transformed_filter_);
142 if (layer_raster_cache_item_->Draw(context, &paint)) {
143 return;
144 }
145 }
146#endif // !SLIMPELLER
147
148 // Now apply the image filter and then try rendering the children.
149 mutator.applyImageFilter(child_paint_bounds(), filter_);
150
151 PaintChildren(context);
152}
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
const Paint & paint
Definition: color_source.cc:38
flutter::DlPaint DlPaint

◆ Preroll()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 52 of file image_filter_layer.cc.

52 {
53 auto mutator = context->state_stack.save();
54 mutator.translate(offset_);
55
56 Layer::AutoPrerollSaveLayerState save =
58
59#if !SLIMPELLER
60 AutoCache cache = AutoCache(layer_raster_cache_item_.get(), context,
61 context->state_stack.transform_3x3());
62#endif // !SLIMPELLER
63
64 SkRect child_bounds = SkRect::MakeEmpty();
65
66 PrerollChildren(context, &child_bounds);
67
68 if (!filter_) {
69 child_bounds.offset(offset_);
70 set_paint_bounds(child_bounds);
71 return;
72 }
73
74 // Our saveLayer would apply any outstanding opacity or any outstanding
75 // color filter after it applies our image filter. So we can apply either
76 // of those attributes with our saveLayer.
77 context->renderable_state_flags =
80
81 const SkIRect filter_in_bounds = child_bounds.roundOut();
82 SkIRect filter_out_bounds;
83 filter_->map_device_bounds(filter_in_bounds, SkMatrix::I(),
84 filter_out_bounds);
85 child_bounds.set(filter_out_bounds);
86 child_bounds.offset(offset_);
87
88 set_paint_bounds(child_bounds);
89
90#if !SLIMPELLER
91 // CacheChildren only when the transformed_filter_ doesn't equal null.
92 // So in here we reset the LayerRasterCacheItem cache state.
93 layer_raster_cache_item_->MarkNotCacheChildren();
94#endif // !SLIMPELLER
95
96 transformed_filter_ =
97 filter_->makeWithLocalMatrix(context->state_stack.transform_3x3());
98
99#if !SLIMPELLER
100 if (transformed_filter_) {
101 layer_raster_cache_item_->MarkCacheChildren();
102 }
103#endif // !SLIMPELLER
104}
void PrerollChildren(PrerollContext *context, SkRect *child_paint_bounds)
static constexpr int kCallerCanApplyColorFilter
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
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:223
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241
void offset(float dx, float dy)
Definition: SkRect.h:1016
void set(const SkIRect &src)
Definition: SkRect.h:849

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