Flutter Engine
 
Loading...
Searching...
No Matches
impeller::Paint::MaskBlurDescriptor Struct Reference

#include <paint.h>

Public Member Functions

std::shared_ptr< FilterContentsCreateMaskBlur (std::shared_ptr< ColorSourceContents > color_source_contents, const flutter::DlColorFilter *color_filter, bool invert_colors, FillRectGeometry *rect_geom) const
 
std::shared_ptr< FilterContentsCreateMaskBlur (std::shared_ptr< TextureContents > texture_contents, FillRectGeometry *rect_geom) const
 
std::shared_ptr< FilterContentsCreateMaskBlur (const FilterInput::Ref &input, bool is_solid_color, const Matrix &ctm) const
 

Public Attributes

FilterContents::BlurStyle style
 
Sigma sigma
 
bool respect_ctm = true
 

Detailed Description

Definition at line 52 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 Matrix ctm 
) const

Definition at line 451 of file paint.cc.

454 {
455 Vector2 blur_sigma(sigma.sigma, sigma.sigma);
456 if (!respect_ctm) {
457 blur_sigma /=
458 Vector2(ctm.GetBasisX().GetLength(), ctm.GetBasisY().GetLength());
459 }
460 if (is_solid_color) {
461 return FilterContents::MakeGaussianBlur(input, Sigma(blur_sigma.x),
462 Sigma(blur_sigma.y),
464 }
465 return FilterContents::MakeBorderMaskBlur(input, Sigma(blur_sigma.x),
466 Sigma(blur_sigma.y), style);
467}
static std::shared_ptr< FilterContents > MakeBorderMaskBlur(FilterInput::Ref input, Sigma sigma_x, Sigma sigma_y, BlurStyle blur_style=BlurStyle::kNormal)
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 Geometry *mask_geometry=nullptr)
static int input(yyscan_t yyscanner)
Point Vector2
Definition point.h:331
FilterContents::BlurStyle style
Definition paint.h:53
Scalar sigma
Definition sigma.h:33

References impeller::Matrix::GetBasisX(), impeller::Matrix::GetBasisY(), impeller::Vector3::GetLength(), input(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ CreateMaskBlur() [2/3]

std::shared_ptr< FilterContents > impeller::Paint::MaskBlurDescriptor::CreateMaskBlur ( std::shared_ptr< ColorSourceContents color_source_contents,
const flutter::DlColorFilter color_filter,
bool  invert_colors,
FillRectGeometry rect_geom 
) 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 395 of file paint.cc.

399 {
400 // If it's a solid color then we can just get away with doing one Gaussian
401 // blur. The color filter will always be applied on the CPU.
402 if (color_source_contents->IsSolidColor()) {
404 FilterInput::Make(color_source_contents), sigma, sigma,
405 Entity::TileMode::kDecal, style, color_source_contents->GetGeometry());
406 }
407
408 /// 1. Create an opaque white mask of the original geometry.
409
410 auto mask = std::make_shared<SolidColorContents>();
411 mask->SetColor(Color::White());
412 mask->SetGeometry(color_source_contents->GetGeometry());
413
414 /// 2. Blur the mask.
415
416 auto blurred_mask = FilterContents::MakeGaussianBlur(
418 color_source_contents->GetGeometry());
419
420 /// 3. Replace the geometry of the original color source with a rectangle that
421 /// covers the full region of the blurred mask. Note that geometry is in
422 /// local bounds.
423
424 auto expanded_local_bounds = blurred_mask->GetCoverage({});
425 if (!expanded_local_bounds.has_value()) {
426 expanded_local_bounds = Rect();
427 }
428 *rect_geom = FillRectGeometry(expanded_local_bounds.value());
429 color_source_contents->SetGeometry(rect_geom);
430 std::shared_ptr<Contents> color_contents = color_source_contents;
431
432 /// 4. Apply the user set color filter on the GPU, if applicable.
433 if (color_filter) {
434 color_contents =
437 }
438 if (invert_colors) {
439 color_contents =
442 }
443
444 /// 5. Composite the color source with the blurred mask.
445
448 {FilterInput::Make(blurred_mask), FilterInput::Make(color_contents)});
449}
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)
std::shared_ptr< ColorFilterContents > WrapWithGPUColorFilter(const flutter::DlColorFilter *filter, const std::shared_ptr< FilterInput > &input, ColorFilterContents::AbsorbOpacity absorb_opacity)
std::shared_ptr< ColorFilterContents > WrapWithInvertColors(const std::shared_ptr< FilterInput > &input, ColorFilterContents::AbsorbOpacity absorb_opacity)
TRect< Scalar > Rect
Definition rect.h:788
static constexpr Color White()
Definition color.h:264
const flutter::DlColorFilter * color_filter
Definition paint.h:77
bool invert_colors
Definition paint.h:83

References impeller::WrapWithGPUColorFilter(), and impeller::WrapWithInvertColors().

◆ CreateMaskBlur() [3/3]

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

Definition at line 365 of file paint.cc.

367 {
370 texture_contents->SetSourceRect(
371 texture_contents->GetSourceRect().Expand(expand_amount, expand_amount));
372 auto mask = std::make_shared<SolidColorContents>();
373 mask->SetColor(Color::White());
374 std::optional<Rect> coverage = texture_contents->GetCoverage({});
375 Geometry* geometry = nullptr;
376 if (coverage) {
377 texture_contents->SetDestinationRect(
378 coverage.value().Expand(expand_amount, expand_amount));
379 *rect_geom = FillRectGeometry(coverage.value());
380 geometry = rect_geom;
381 }
382 mask->SetGeometry(geometry);
383 auto descriptor = texture_contents->GetSamplerDescriptor();
384 texture_contents->SetSamplerDescriptor(descriptor);
385 std::shared_ptr<FilterContents> blurred_mask =
388 geometry);
389
392 {FilterInput::Make(blurred_mask), FilterInput::Make(texture_contents)});
393}
float Scalar
Definition scalar.h:19

Member Data Documentation

◆ respect_ctm

bool impeller::Paint::MaskBlurDescriptor::respect_ctm = true

Text mask blurs need to not apply the CTM to the blur kernel. See: https://github.com/flutter/flutter/issues/115112

Definition at line 57 of file paint.h.

◆ sigma

Sigma impeller::Paint::MaskBlurDescriptor::sigma

Definition at line 54 of file paint.h.

Referenced by impeller::testing::TEST_P().

◆ style

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

Definition at line 53 of file paint.h.

Referenced by impeller::DlDispatcherBase::drawShadow().


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