| 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 41 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 201 of file paint.cc.

203 {
204 if (is_solid_color) {
205 return FilterContents::MakeGaussianBlur(input, sigma, sigma, style,
206 Entity::TileMode::kDecal);
207 }
208 return FilterContents::MakeBorderMaskBlur(input, sigma, sigma, style);
209 }

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 151 of file paint.cc.

153 {
154 // If it's a solid color and there is no color filter, then we can just get
155 // away with doing one Gaussian blur.
156 if (color_source_contents->IsSolidColor() && !color_filter) {
157 return FilterContents::MakeGaussianBlur(
158 FilterInput::Make(color_source_contents), sigma, sigma, style,
159 Entity::TileMode::kDecal);
160 }
161
162 /// 1. Create an opaque white mask of the original geometry.
163
164 auto mask = std::make_shared<SolidColorContents>();
165 mask->SetColor(Color::White());
166 mask->SetGeometry(color_source_contents->GetGeometry());
167
168 /// 2. Blur the mask.
169
170 auto blurred_mask = FilterContents::MakeGaussianBlur(
171 FilterInput::Make(mask), sigma, sigma, style, Entity::TileMode::kDecal);
172
173 /// 3. Replace the geometry of the original color source with a rectangle that
174 /// covers the full region of the blurred mask. Note that geometry is in
175 /// local bounds.
176
177 auto expanded_local_bounds = blurred_mask->GetCoverage({});
178 if (!expanded_local_bounds.has_value()) {
179 return nullptr;
180 }
181 color_source_contents->SetGeometry(
182 Geometry::MakeRect(*expanded_local_bounds));
183
184 std::shared_ptr<Contents> color_contents = color_source_contents;
185
186 /// 4. Apply the user set color filter on the GPU, if applicable.
187
188 if (color_filter) {
189 color_contents = color_filter->WrapWithGPUColorFilter(
190 FilterInput::Make(color_source_contents),
191 ColorFilterContents::AbsorbOpacity::kYes);
192 }
193
194 /// 5. Composite the color source with the blurred mask.
195
196 return ColorFilterContents::MakeBlend(
197 BlendMode::kSourceIn,
198 {FilterInput::Make(blurred_mask), FilterInput::Make(color_contents)});
199 }

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 43 of file paint.h.

Referenced by CreateMaskBlur().

## ◆ style

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

Definition at line 42 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:43
impeller::Entity::TileMode::kDecal
@ kDecal
impeller::Paint::MaskBlurDescriptor::style
FilterContents::BlurStyle style
Definition: paint.h:42
impeller::BlendMode::kSourceIn
@ kSourceIn
impeller::Geometry::MakeRect
static std::unique_ptr< Geometry > MakeRect(Rect rect)
Definition: geometry.cc:142
impeller::Paint::color_filter
std::shared_ptr< ColorFilter > color_filter
Definition: paint.h:67
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:52
impeller::Color::White
static constexpr Color White()
Definition: color.h:254
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:66
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