Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 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 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)
Point 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()
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)
float fX
x-axis value
float fY
y-axis value
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 99 of file image_filter_layer.cc.

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

◆ 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 AutoCache cache = AutoCache(layer_raster_cache_item_.get(), context,
60 context->state_stack.transform_3x3());
61
62 SkRect child_bounds = SkRect::MakeEmpty();
63
64 PrerollChildren(context, &child_bounds);
65
66 if (!filter_) {
67 child_bounds.offset(offset_);
68 set_paint_bounds(child_bounds);
69 return;
70 }
71
72 // Our saveLayer would apply any outstanding opacity or any outstanding
73 // color filter after it applies our image filter. So we can apply either
74 // of those attributes with our saveLayer.
75 context->renderable_state_flags =
78
79 const SkIRect filter_in_bounds = child_bounds.roundOut();
80 SkIRect filter_out_bounds;
81 filter_->map_device_bounds(filter_in_bounds, SkMatrix::I(),
82 filter_out_bounds);
83 child_bounds.set(filter_out_bounds);
84 child_bounds.offset(offset_);
85
86 set_paint_bounds(child_bounds);
87
88 // CacheChildren only when the transformed_filter_ doesn't equal null.
89 // So in here we reset the LayerRasterCacheItem cache state.
90 layer_raster_cache_item_->MarkNotCacheChildren();
91
92 transformed_filter_ =
93 filter_->makeWithLocalMatrix(context->state_stack.transform_3x3());
94 if (transformed_filter_) {
95 layer_raster_cache_item_->MarkCacheChildren();
96 }
97}
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:222
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: