Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
impeller::Paint::MaskBlurDescriptor Struct Reference

#include <paint.h>

Public Member Functions

std::shared_ptr< FilterContentsCreateMaskBlur (std::shared_ptr< ColorSourceContents > color_source_contents, const std::shared_ptr< ColorFilter > &color_filter) const
 
std::shared_ptr< FilterContentsCreateMaskBlur (std::shared_ptr< TextureContents > texture_contents) const
 
std::shared_ptr< FilterContentsCreateMaskBlur (const FilterInput::Ref &input, bool is_solid_color) const
 

Public Attributes

FilterContents::BlurStyle style
 
Sigma sigma
 

Detailed Description

Definition at line 39 of file paint.h.

Member Function Documentation

◆ CreateMaskBlur() [1/3]

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

Definition at line 203 of file paint.cc.

205 {
206 if (is_solid_color) {
209 }
211}
static std::shared_ptr< FilterContents > MakeGaussianBlur(const FilterInput::Ref &input, Sigma sigma_x, Sigma sigma_y, Entity::TileMode tile_mode=Entity::TileMode::kDecal, BlurStyle mask_blur_style=BlurStyle::kNormal, const std::shared_ptr< Geometry > &mask_geometry=nullptr)
static std::shared_ptr< FilterContents > MakeBorderMaskBlur(FilterInput::Ref input, Sigma sigma_x, Sigma sigma_y, BlurStyle blur_style=BlurStyle::kNormal)
FilterContents::BlurStyle style
Definition paint.h:40

◆ CreateMaskBlur() [2/3]

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.
  1. Blur the mask.
  1. 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.
  1. Apply the user set color filter on the GPU, if applicable.
  1. Composite the color source with the blurred mask.

Definition at line 153 of file paint.cc.

155 {
156 // If it's a solid color and there is no color filter, then we can just get
157 // away with doing one Gaussian blur.
158 if (color_source_contents->IsSolidColor() && !color_filter) {
160 FilterInput::Make(color_source_contents), sigma, sigma,
161 Entity::TileMode::kDecal, style, color_source_contents->GetGeometry());
162 }
163
164 /// 1. Create an opaque white mask of the original geometry.
165
166 auto mask = std::make_shared<SolidColorContents>();
167 mask->SetColor(Color::White());
168 mask->SetGeometry(color_source_contents->GetGeometry());
169
170 /// 2. Blur the mask.
171
172 auto blurred_mask = FilterContents::MakeGaussianBlur(
174 color_source_contents->GetGeometry());
175
176 /// 3. Replace the geometry of the original color source with a rectangle that
177 /// covers the full region of the blurred mask. Note that geometry is in
178 /// local bounds.
179
180 auto expanded_local_bounds = blurred_mask->GetCoverage({});
181 if (!expanded_local_bounds.has_value()) {
182 expanded_local_bounds = Rect();
183 }
184 color_source_contents->SetGeometry(
185 Geometry::MakeRect(*expanded_local_bounds));
186 std::shared_ptr<Contents> color_contents = color_source_contents;
187
188 /// 4. Apply the user set color filter on the GPU, if applicable.
189
190 if (color_filter) {
191 color_contents = color_filter->WrapWithGPUColorFilter(
192 FilterInput::Make(color_source_contents),
194 }
195
196 /// 5. Composite the color source with the blurred mask.
197
200 {FilterInput::Make(blurred_mask), FilterInput::Make(color_contents)});
201}
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.
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
static std::shared_ptr< Geometry > MakeRect(const Rect &rect)
Definition geometry.cc:89
TRect< Scalar > Rect
Definition rect.h:746
static constexpr Color White()
Definition color.h:256
std::shared_ptr< ColorFilter > color_filter
Definition paint.h:68

◆ CreateMaskBlur() [3/3]

std::shared_ptr< FilterContents > impeller::Paint::MaskBlurDescriptor::CreateMaskBlur ( std::shared_ptr< TextureContents texture_contents) const

Definition at line 125 of file paint.cc.

126 {
129 texture_contents->SetSourceRect(
130 texture_contents->GetSourceRect().Expand(expand_amount, expand_amount));
131 auto mask = std::make_shared<SolidColorContents>();
132 mask->SetColor(Color::White());
133 std::optional<Rect> coverage = texture_contents->GetCoverage({});
134 std::shared_ptr<Geometry> geometry;
135 if (coverage) {
136 texture_contents->SetDestinationRect(
137 coverage.value().Expand(expand_amount, expand_amount));
138 geometry = Geometry::MakeRect(coverage.value());
139 }
140 mask->SetGeometry(geometry);
141 auto descriptor = texture_contents->GetSamplerDescriptor();
142 texture_contents->SetSamplerDescriptor(descriptor);
143 std::shared_ptr<FilterContents> blurred_mask =
146 geometry);
147
150 {FilterInput::Make(blurred_mask), FilterInput::Make(texture_contents)});
151}
float Scalar
Definition scalar.h:18
Scalar sigma
Definition sigma.h:33

Member Data Documentation

◆ sigma

Sigma impeller::Paint::MaskBlurDescriptor::sigma

Definition at line 41 of file paint.h.

◆ style

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

Definition at line 40 of file paint.h.


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