| Flutter Impeller |

Public Member Functions | Public Attributes | List of all members
impeller::Paint::MaskBlurDescriptor Struct Reference

`#include <paint.h>`

## Public Member Functions
std::shared_ptr< FilterContents > | CreateMaskBlur (std::shared_ptr< ColorSourceContents > color_source_contents, const std::shared_ptr< ColorFilter > &color_filter) const
std::shared_ptr< FilterContents > | CreateMaskBlur (const FilterInput::Ref &input, bool is_solid_color) const

## Public Attributes
FilterContents::BlurStyle | style
Sigma | sigma

## Detailed Description

Definition at line 38 of file paint.h.

## Member Function Documentation

## ◆ CreateMaskBlur() [1/2]

std::shared_ptr< FilterContents > impeller::Paint::MaskBlurDescriptor::CreateMaskBlur | ( | const FilterInput::Ref & | input,
|  | bool | is_solid_color
| ) |  | const

Definition at line 174 of file paint.cc.

176 {
177 if (is_solid_color) {
178 return FilterContents::MakeGaussianBlur(input, sigma, sigma, style,
179 Entity::TileMode::kDecal);
180 }
181 return FilterContents::MakeBorderMaskBlur(input, sigma, sigma, style);
182 }

References impeller::Entity::kDecal, impeller::FilterContents::MakeBorderMaskBlur(), impeller::FilterContents::MakeGaussianBlur(), and impeller::Paint::style.

## ◆ CreateMaskBlur() [2/2]

std::shared_ptr< FilterContents > impeller::Paint::MaskBlurDescriptor::CreateMaskBlur | ( | std::shared_ptr< ColorSourceContents > | color_source_contents,
|  | const std::shared_ptr< ColorFilter > & | color_filter
| ) |  | const

1. Create an opaque white mask of the original geometry.
2. Blur the mask.
3. Replace the geometry of the original color source with a rectangle that covers the full region of the blurred mask. Note that geometry is in local bounds.
4. Apply the user set color filter on the GPU, if applicable.
5. Composite the color source with the blurred mask.

Definition at line 124 of file paint.cc.

126 {
127 // If it's a solid color and there is no color filter, then we can just get
128 // away with doing one Gaussian blur.
129 if (color_source_contents->IsSolidColor() && !color_filter) {
130 return FilterContents::MakeGaussianBlur(
131 FilterInput::Make(color_source_contents), sigma, sigma, style,
132 Entity::TileMode::kDecal);
133 }
134
135 /// 1. Create an opaque white mask of the original geometry.
136
137 auto mask = std::make_shared<SolidColorContents>();
138 mask->SetColor(Color::White());
139 mask->SetGeometry(color_source_contents->GetGeometry());
140
141 /// 2. Blur the mask.
142
143 auto blurred_mask = FilterContents::MakeGaussianBlur(
144 FilterInput::Make(mask), sigma, sigma, style, Entity::TileMode::kDecal);
145
146 /// 3. Replace the geometry of the original color source with a rectangle that
147 /// covers the full region of the blurred mask. Note that geometry is in
148 /// local bounds.
149
150 auto expanded_local_bounds = blurred_mask->GetCoverage({});
151 if (!expanded_local_bounds.has_value()) {
152 expanded_local_bounds = Rect();
153 }
154 color_source_contents->SetGeometry(
155 Geometry::MakeRect(*expanded_local_bounds));
156
157 std::shared_ptr<Contents> color_contents = color_source_contents;
158
159 /// 4. Apply the user set color filter on the GPU, if applicable.
160
161 if (color_filter) {
162 color_contents = color_filter->WrapWithGPUColorFilter(
163 FilterInput::Make(color_source_contents),
164 ColorFilterContents::AbsorbOpacity::kYes);
165 }
166
167 /// 5. Composite the color source with the blurred mask.
168
169 return ColorFilterContents::MakeBlend(
170 BlendMode::kSourceIn,
171 {FilterInput::Make(blurred_mask), FilterInput::Make(color_contents)});
172 }

References impeller::Paint::color_filter, impeller::Entity::kDecal, impeller::kSourceIn, impeller::ColorFilterContents::kYes, impeller::FilterInput::Make(), impeller::ColorFilterContents::MakeBlend(), impeller::FilterContents::MakeGaussianBlur(), impeller::Geometry::MakeRect(), sigma, style, and impeller::Color::White().

## Member Data Documentation

## ◆ sigma

Sigma impeller::Paint::MaskBlurDescriptor::sigma

Definition at line 40 of file paint.h.

Referenced by CreateMaskBlur().

## ◆ style

FilterContents::BlurStyle impeller::Paint::MaskBlurDescriptor::style

Definition at line 39 of file paint.h.

Referenced by CreateMaskBlur(), impeller::DlDispatcher::drawShadow(), and impeller::testing::TEST_P().

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

- impeller/aiks/paint.h
- impeller/aiks/paint.cc

impeller::FilterInput::Make
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
impeller::Paint::MaskBlurDescriptor::sigma
Sigma sigma
Definition: paint.h:40
impeller::Entity::TileMode::kDecal
@ kDecal
impeller::Paint::MaskBlurDescriptor::style
FilterContents::BlurStyle style
Definition: paint.h:39
impeller::Paint::color_filter
std::shared_ptr< ColorFilter > color_filter
Definition: paint.h:64
impeller::FilterContents::MakeGaussianBlur
static std::shared_ptr< FilterContents > MakeGaussianBlur(const FilterInput::Ref &input, Sigma sigma_x, Sigma sigma_y, BlurStyle blur_style=BlurStyle::kNormal, Entity::TileMode tile_mode=Entity::TileMode::kDecal)
Definition: filter_contents.cc:53
impeller::Color::White
static constexpr Color White()
Definition: color.h:256
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:488
impeller::FilterContents::MakeBorderMaskBlur
static std::shared_ptr< FilterContents > MakeBorderMaskBlur(FilterInput::Ref input, Sigma sigma_x, Sigma sigma_y, BlurStyle blur_style=BlurStyle::kNormal)
Definition: filter_contents.cc:93
impeller::Geometry::MakeRect
static std::shared_ptr< Geometry > MakeRect(const Rect &rect)
Definition: geometry.cc:179
impeller::BlendMode::kSourceIn
@ kSourceIn
impeller::ColorFilterContents::AbsorbOpacity::kYes
@ kYes
impeller::ColorFilterContents::MakeBlend
static std::shared_ptr< ColorFilterContents > MakeBlend(BlendMode blend_mode, FilterInput::Vector inputs, std::optional< Color > foreground_color=std::nullopt)
the [inputs] are expected to be in the order of dst, src.
Definition: color_filter_contents.cc:17