Flutter Engine
 
Loading...
Searching...
No Matches
flutter::DlImageFilter Class Referenceabstract

#include <dl_image_filter.h>

Inheritance diagram for flutter::DlImageFilter:
flutter::DlAttribute< DlImageFilter, DlImageFilterType > flutter::DlBlurImageFilter flutter::DlColorFilterImageFilter flutter::DlComposeImageFilter flutter::DlDilateImageFilter flutter::DlErodeImageFilter flutter::DlLocalMatrixImageFilter flutter::DlMatrixImageFilter flutter::DlRuntimeEffectImageFilter

Public Types

enum class  MatrixCapability {
  kTranslate ,
  kScaleTranslate ,
  kComplex
}
 

Public Member Functions

virtual const DlBlurImageFilterasBlur () const
 
virtual const DlDilateImageFilterasDilate () const
 
virtual const DlErodeImageFilterasErode () const
 
virtual const DlMatrixImageFilterasMatrix () const
 
virtual const DlLocalMatrixImageFilterasLocalMatrix () const
 
virtual std::shared_ptr< DlImageFiltermakeWithLocalMatrix (const DlMatrix &matrix) const
 
virtual const DlComposeImageFilterasCompose () const
 
virtual const DlColorFilterImageFilterasColorFilter () const
 
virtual const DlRuntimeEffectImageFilterasRuntimeEffectFilter () const
 
virtual bool modifies_transparent_black () const =0
 
virtual DlRectmap_local_bounds (const DlRect &input_bounds, DlRect &output_bounds) const =0
 
virtual DlIRectmap_device_bounds (const DlIRect &input_bounds, const DlMatrix &ctm, DlIRect &output_bounds) const =0
 
virtual DlIRectget_input_device_bounds (const DlIRect &output_bounds, const DlMatrix &ctm, DlIRect &input_bounds) const =0
 
virtual MatrixCapability matrix_capability () const
 
- Public Member Functions inherited from flutter::DlAttribute< DlImageFilter, DlImageFilterType >
virtual DlImageFilterType type () const=0
 
virtual size_t size () const=0
 
virtual std::shared_ptr< DlImageFiltershared () const=0
 
bool operator== (DlImageFilter const &other) const
 
bool operator!= (DlImageFilter const &other) const
 
virtual ~DlAttribute ()=default
 

Static Public Member Functions

static std::shared_ptr< DlImageFilterMakeBlur (DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)
 
static std::shared_ptr< DlImageFilterMakeDilate (DlScalar radius_x, DlScalar radius_y)
 
static std::shared_ptr< DlImageFilterMakeErode (DlScalar radius_x, DlScalar radius_y)
 
static std::shared_ptr< DlImageFilterMakeMatrix (const DlMatrix &matrix, DlImageSampling sampling)
 
static std::shared_ptr< DlImageFilterMakeRuntimeEffect (sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)
 
static std::shared_ptr< DlImageFilterMakeColorFilter (const std::shared_ptr< const DlColorFilter > &filter)
 
static std::shared_ptr< DlImageFilterMakeCompose (const std::shared_ptr< DlImageFilter > &outer, const std::shared_ptr< DlImageFilter > &inner)
 

Static Protected Member Functions

static DlVector2 map_vectors_affine (const DlMatrix &ctm, DlScalar x, DlScalar y)
 
static DlIRectinset_device_bounds (const DlIRect &input_bounds, DlScalar radius_x, DlScalar radius_y, const DlMatrix &ctm, DlIRect &output_bounds)
 
static DlIRectoutset_device_bounds (const DlIRect &input_bounds, DlScalar radius_x, DlScalar radius_y, const DlMatrix &ctm, DlIRect &output_bounds)
 

Additional Inherited Members

- Protected Member Functions inherited from flutter::DlAttribute< DlImageFilter, DlImageFilterType >
virtual bool equals_ (DlImageFilter const &other) const=0
 

Detailed Description

Definition at line 46 of file dl_image_filter.h.

Member Enumeration Documentation

◆ MatrixCapability

Enumerator
kTranslate 
kScaleTranslate 
kComplex 

Definition at line 48 of file dl_image_filter.h.

Member Function Documentation

◆ asBlur()

virtual const DlBlurImageFilter * flutter::DlImageFilter::asBlur ( ) const
inlinevirtual

◆ asColorFilter()

virtual const DlColorFilterImageFilter * flutter::DlImageFilter::asColorFilter ( ) const
inlinevirtual

Reimplemented in flutter::DlColorFilterImageFilter.

Definition at line 108 of file dl_image_filter.h.

108 {
109 return nullptr;
110 }

Referenced by flutter::testing::DisplayListStreamDispatcher::out(), flutter::ToSk(), and impeller::WrapInput().

◆ asCompose()

virtual const DlComposeImageFilter * flutter::DlImageFilter::asCompose ( ) const
inlinevirtual

Reimplemented in flutter::DlComposeImageFilter.

Definition at line 104 of file dl_image_filter.h.

104{ return nullptr; }

Referenced by flutter::testing::DisplayListStreamDispatcher::out(), flutter::ToSk(), and impeller::WrapInput().

◆ asDilate()

virtual const DlDilateImageFilter * flutter::DlImageFilter::asDilate ( ) const
inlinevirtual

Reimplemented in flutter::DlDilateImageFilter.

Definition at line 85 of file dl_image_filter.h.

85{ return nullptr; }

Referenced by flutter::testing::DisplayListStreamDispatcher::out(), flutter::ToSk(), and impeller::WrapInput().

◆ asErode()

virtual const DlErodeImageFilter * flutter::DlImageFilter::asErode ( ) const
inlinevirtual

Reimplemented in flutter::DlErodeImageFilter.

Definition at line 89 of file dl_image_filter.h.

89{ return nullptr; }

Referenced by flutter::testing::DisplayListStreamDispatcher::out(), flutter::ToSk(), and impeller::WrapInput().

◆ asLocalMatrix()

virtual const DlLocalMatrixImageFilter * flutter::DlImageFilter::asLocalMatrix ( ) const
inlinevirtual

Reimplemented in flutter::DlLocalMatrixImageFilter.

Definition at line 95 of file dl_image_filter.h.

95 {
96 return nullptr;
97 }

Referenced by flutter::testing::DisplayListStreamDispatcher::out(), flutter::ToSk(), and impeller::WrapInput().

◆ asMatrix()

virtual const DlMatrixImageFilter * flutter::DlImageFilter::asMatrix ( ) const
inlinevirtual

Reimplemented in flutter::DlMatrixImageFilter.

Definition at line 93 of file dl_image_filter.h.

93{ return nullptr; }

Referenced by flutter::testing::DisplayListStreamDispatcher::out(), flutter::ToSk(), and impeller::WrapInput().

◆ asRuntimeEffectFilter()

virtual const DlRuntimeEffectImageFilter * flutter::DlImageFilter::asRuntimeEffectFilter ( ) const
inlinevirtual

Reimplemented in flutter::DlRuntimeEffectImageFilter.

Definition at line 114 of file dl_image_filter.h.

114 {
115 return nullptr;
116 }

Referenced by flutter::testing::DisplayListStreamDispatcher::out(), and impeller::WrapInput().

◆ get_input_device_bounds()

◆ inset_device_bounds()

DlIRect * flutter::DlImageFilter::inset_device_bounds ( const DlIRect input_bounds,
DlScalar  radius_x,
DlScalar  radius_y,
const DlMatrix ctm,
DlIRect output_bounds 
)
staticprotected

Definition at line 84 of file dl_image_filter.cc.

88 {
89 if (ctm.IsFinite() && ctm.IsInvertible()) {
90 if (ctm.HasPerspective2D()) {
91 // Ideally this code would use Impeller classes to do the math, see:
92 // https://github.com/flutter/flutter/issues/159175
93 SkMatrix sk_ctm = ToSkMatrix(ctm);
94 FML_DCHECK(sk_ctm.hasPerspective());
95 SkIRect sk_input_bounds =
96 SkIRect::MakeLTRB(input_bounds.GetLeft(), input_bounds.GetTop(),
97 input_bounds.GetRight(), input_bounds.GetBottom());
98
99 SkMatrix inverse;
100 if (sk_ctm.invert(&inverse)) {
101 SkRect local_bounds = inverse.mapRect(SkRect::Make(sk_input_bounds));
102 local_bounds.inset(radius_x, radius_y);
103 output_bounds = ToDlIRect(sk_ctm.mapRect(local_bounds).roundOut());
104 return &output_bounds;
105 }
106 } else {
107 DlVector2 device_radius = map_vectors_affine(ctm, radius_x, radius_y);
108 output_bounds =
109 input_bounds.Expand(-floor(device_radius.x), -floor(device_radius.y));
110 return &output_bounds;
111 }
112 }
113 output_bounds = input_bounds;
114 return nullptr;
115}
static DlVector2 map_vectors_affine(const DlMatrix &ctm, DlScalar x, DlScalar y)
#define FML_DCHECK(condition)
Definition logging.h:122
SkMatrix ToSkMatrix(const DlMatrix &matrix)
const DlIRect & ToDlIRect(const SkIRect &rect)
impeller::Vector2 DlVector2

References impeller::TRect< T >::Expand(), FML_DCHECK, impeller::TRect< T >::GetBottom(), impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), impeller::Matrix::HasPerspective2D(), impeller::Matrix::IsFinite(), impeller::Matrix::IsInvertible(), map_vectors_affine(), flutter::ToDlIRect(), flutter::ToSkMatrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by flutter::DlDilateImageFilter::get_input_device_bounds(), and flutter::DlErodeImageFilter::map_device_bounds().

◆ MakeBlur()

std::shared_ptr< DlImageFilter > flutter::DlImageFilter::MakeBlur ( DlScalar  sigma_x,
DlScalar  sigma_y,
DlTileMode  tile_mode 
)
static

Definition at line 12 of file dl_image_filter.cc.

14 {
15 return DlBlurImageFilter::Make(sigma_x, sigma_y, tile_mode);
16}
static std::shared_ptr< DlImageFilter > Make(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)

References flutter::DlBlurImageFilter::Make().

Referenced by flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and flutter::testing::TEST_P().

◆ MakeColorFilter()

◆ MakeCompose()

std::shared_ptr< DlImageFilter > flutter::DlImageFilter::MakeCompose ( const std::shared_ptr< DlImageFilter > &  outer,
const std::shared_ptr< DlImageFilter > &  inner 
)
static

Definition at line 47 of file dl_image_filter.cc.

49 {
50 return DlComposeImageFilter::Make(outer, inner);
51}
static std::shared_ptr< DlImageFilter > Make(const std::shared_ptr< DlImageFilter > &outer, const std::shared_ptr< DlImageFilter > &inner)

References flutter::DlComposeImageFilter::Make().

Referenced by flutter::testing::TEST(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ MakeDilate()

std::shared_ptr< DlImageFilter > flutter::DlImageFilter::MakeDilate ( DlScalar  radius_x,
DlScalar  radius_y 
)
static

Definition at line 18 of file dl_image_filter.cc.

19 {
20 return DlDilateImageFilter::Make(radius_x, radius_y);
21}
static std::shared_ptr< DlImageFilter > Make(DlScalar radius_x, DlScalar radius_y)

References flutter::DlDilateImageFilter::Make().

Referenced by flutter::testing::TEST(), flutter::testing::TEST_F(), and impeller::testing::TEST_P().

◆ MakeErode()

std::shared_ptr< DlImageFilter > flutter::DlImageFilter::MakeErode ( DlScalar  radius_x,
DlScalar  radius_y 
)
static

Definition at line 23 of file dl_image_filter.cc.

24 {
25 return DlErodeImageFilter::Make(radius_x, radius_y);
26}
static std::shared_ptr< DlImageFilter > Make(DlScalar radius_x, DlScalar radius_y)

References flutter::DlErodeImageFilter::Make().

Referenced by flutter::testing::TEST_F(), and impeller::testing::TEST_P().

◆ MakeMatrix()

◆ MakeRuntimeEffect()

std::shared_ptr< DlImageFilter > flutter::DlImageFilter::MakeRuntimeEffect ( sk_sp< DlRuntimeEffect runtime_effect,
std::vector< std::shared_ptr< DlColorSource > >  samplers,
std::shared_ptr< std::vector< uint8_t > >  uniform_data 
)
static

Definition at line 34 of file dl_image_filter.cc.

37 {
39 std::move(runtime_effect), std::move(samplers), std::move(uniform_data));
40}
static std::shared_ptr< DlImageFilter > Make(sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)

References flutter::DlRuntimeEffectImageFilter::Make().

Referenced by flutter::FragmentProgram::MakeDlImageFilter(), flutter::testing::TEST(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ makeWithLocalMatrix()

std::shared_ptr< DlImageFilter > flutter::DlImageFilter::makeWithLocalMatrix ( const DlMatrix matrix) const
virtual

Definition at line 150 of file dl_image_filter.cc.

151 {
152 if (matrix.IsIdentity()) {
153 return shared();
154 }
155 // Matrix
156 switch (this->matrix_capability()) {
158 if (!matrix.IsTranslationOnly()) {
159 // Nothing we can do at this point
160 return nullptr;
161 }
162 break;
163 }
165 if (!matrix.IsTranslationScaleOnly()) {
166 // Nothing we can do at this point
167 return nullptr;
168 }
169 break;
170 }
171 default:
172 break;
173 }
174 return DlLocalMatrixImageFilter::Make(matrix, shared());
175}
virtual std::shared_ptr< DlImageFilter > shared() const=0
virtual MatrixCapability matrix_capability() const
static std::shared_ptr< DlImageFilter > Make(const DlMatrix &matrix, const std::shared_ptr< DlImageFilter > &filter)

References impeller::Matrix::IsIdentity(), impeller::Matrix::IsTranslationOnly(), impeller::Matrix::IsTranslationScaleOnly(), kScaleTranslate, kTranslate, flutter::DlLocalMatrixImageFilter::Make(), matrix_capability(), and flutter::DlAttribute< DlImageFilter, DlImageFilterType >::shared().

Referenced by flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), and flutter::testing::TEST().

◆ map_device_bounds()

◆ map_local_bounds()

◆ map_vectors_affine()

DlVector2 flutter::DlImageFilter::map_vectors_affine ( const DlMatrix ctm,
DlScalar  x,
DlScalar  y 
)
staticprotected

Definition at line 53 of file dl_image_filter.cc.

55 {
56 FML_DCHECK(std::isfinite(x) && x >= 0);
57 FML_DCHECK(std::isfinite(y) && y >= 0);
58 FML_DCHECK(ctm.IsFinite() && !ctm.HasPerspective2D());
59
60 // The x and y scalars would have been used to expand a local space
61 // rectangle which is then transformed by ctm. In order to do the
62 // expansion correctly, we should look at the relevant math. The
63 // 4 corners will be moved outward by the following vectors:
64 // (UL,UR,LR,LL) = ((-x, -y), (+x, -y), (+x, +y), (-x, +y))
65 // After applying the transform, each of these vectors could be
66 // pointing in any direction so we need to examine each transformed
67 // delta vector and how it affected the bounds.
68 // Looking at just the affine 2x3 entries of the CTM we can delta
69 // transform these corner offsets and get the following:
70 // UL = dCTM(-x, -y) = (- x*m00 - y*m01, - x*m10 - y*m11)
71 // UR = dCTM(+x, -y) = ( x*m00 - y*m01, x*m10 - y*m11)
72 // LR = dCTM(+x, +y) = ( x*m00 + y*m01, x*m10 + y*m11)
73 // LL = dCTM(-x, +y) = (- x*m00 + y*m01, - x*m10 + y*m11)
74 // The X vectors are all some variation of adding or subtracting
75 // the sum of x*m00 and y*m01 or their difference. Similarly the Y
76 // vectors are +/- the associated sum/difference of x*m10 and y*m11.
77 // The largest displacements, both left/right or up/down, will
78 // happen when the signs of the m00/m01/m10/m11 matrix entries
79 // coincide with the signs of the scalars, i.e. are all positive.
80 return {x * abs(ctm.m[0]) + y * abs(ctm.m[4]),
81 x * abs(ctm.m[1]) + y * abs(ctm.m[5])};
82}
int32_t x
double y

References FML_DCHECK, impeller::Matrix::HasPerspective2D(), impeller::Matrix::IsFinite(), impeller::Matrix::m, x, and y.

Referenced by inset_device_bounds(), and outset_device_bounds().

◆ matrix_capability()

virtual MatrixCapability flutter::DlImageFilter::matrix_capability ( ) const
inlinevirtual

Reimplemented in flutter::DlColorFilterImageFilter, and flutter::DlComposeImageFilter.

Definition at line 163 of file dl_image_filter.h.

163 {
165 }

References kScaleTranslate.

Referenced by makeWithLocalMatrix().

◆ modifies_transparent_black()

◆ outset_device_bounds()

DlIRect * flutter::DlImageFilter::outset_device_bounds ( const DlIRect input_bounds,
DlScalar  radius_x,
DlScalar  radius_y,
const DlMatrix ctm,
DlIRect output_bounds 
)
staticprotected

Definition at line 117 of file dl_image_filter.cc.

121 {
122 if (ctm.IsFinite() && ctm.IsInvertible()) {
123 if (ctm.HasPerspective2D()) {
124 // Ideally this code would use Impeller classes to do the math, see:
125 // https://github.com/flutter/flutter/issues/159175
126 SkMatrix sk_ctm = ToSkMatrix(ctm);
127 FML_DCHECK(sk_ctm.hasPerspective());
128 SkIRect sk_input_bounds =
129 SkIRect::MakeLTRB(input_bounds.GetLeft(), input_bounds.GetTop(),
130 input_bounds.GetRight(), input_bounds.GetBottom());
131
132 SkMatrix inverse;
133 if (sk_ctm.invert(&inverse)) {
134 SkRect local_bounds = inverse.mapRect(SkRect::Make(sk_input_bounds));
135 local_bounds.outset(radius_x, radius_y);
136 output_bounds = ToDlIRect(sk_ctm.mapRect(local_bounds).roundOut());
137 return &output_bounds;
138 }
139 } else {
140 DlVector2 device_radius = map_vectors_affine(ctm, radius_x, radius_y);
141 output_bounds =
142 input_bounds.Expand(ceil(device_radius.x), ceil(device_radius.y));
143 return &output_bounds;
144 }
145 }
146 output_bounds = input_bounds;
147 return nullptr;
148}

References impeller::TRect< T >::Expand(), FML_DCHECK, impeller::TRect< T >::GetBottom(), impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), impeller::Matrix::HasPerspective2D(), impeller::Matrix::IsFinite(), impeller::Matrix::IsInvertible(), map_vectors_affine(), flutter::ToDlIRect(), flutter::ToSkMatrix(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by flutter::DlErodeImageFilter::get_input_device_bounds(), flutter::DlBlurImageFilter::map_device_bounds(), and flutter::DlDilateImageFilter::map_device_bounds().


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