Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Protected Member Functions | List of all members
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

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 SkMatrix &matrix) const
 
virtual const DlComposeImageFilterasCompose () const
 
virtual const DlColorFilterImageFilterasColorFilter () const
 
virtual bool modifies_transparent_black () const =0
 
virtual SkRectmap_local_bounds (const SkRect &input_bounds, SkRect &output_bounds) const =0
 
virtual SkIRectmap_device_bounds (const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const =0
 
virtual SkIRectget_input_device_bounds (const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &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 Protected Member Functions

static SkVector map_vectors_affine (const SkMatrix &ctm, SkScalar x, SkScalar y)
 
static SkIRectinset_device_bounds (const SkIRect &input_bounds, SkScalar radius_x, SkScalar radius_y, const SkMatrix &ctm, SkIRect &output_bounds)
 
static SkIRectoutset_device_bounds (const SkIRect &input_bounds, SkScalar radius_x, SkScalar radius_y, const SkMatrix &ctm, SkIRect &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 47 of file dl_image_filter.h.

Member Enumeration Documentation

◆ MatrixCapability

Enumerator
kTranslate 
kScaleTranslate 
kComplex 

Definition at line 49 of file dl_image_filter.h.

Member Function Documentation

◆ asBlur()

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

Reimplemented in flutter::DlBlurImageFilter.

Definition at line 57 of file dl_image_filter.h.

57{ return nullptr; }

◆ asColorFilter()

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

Reimplemented in flutter::DlColorFilterImageFilter.

Definition at line 84 of file dl_image_filter.h.

84 {
85 return nullptr;
86 }

◆ asCompose()

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

Reimplemented in flutter::DlComposeImageFilter.

Definition at line 80 of file dl_image_filter.h.

80{ return nullptr; }

◆ asDilate()

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

Reimplemented in flutter::DlDilateImageFilter.

Definition at line 61 of file dl_image_filter.h.

61{ return nullptr; }

◆ asErode()

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

Reimplemented in flutter::DlErodeImageFilter.

Definition at line 65 of file dl_image_filter.h.

65{ return nullptr; }

◆ asLocalMatrix()

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

Reimplemented in flutter::DlLocalMatrixImageFilter.

Definition at line 71 of file dl_image_filter.h.

71 {
72 return nullptr;
73 }

◆ asMatrix()

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

Reimplemented in flutter::DlMatrixImageFilter.

Definition at line 69 of file dl_image_filter.h.

69{ return nullptr; }

◆ get_input_device_bounds()

virtual SkIRect * flutter::DlImageFilter::get_input_device_bounds ( const SkIRect output_bounds,
const SkMatrix ctm,
SkIRect input_bounds 
) const
pure virtual

◆ inset_device_bounds()

static SkIRect * flutter::DlImageFilter::inset_device_bounds ( const SkIRect input_bounds,
SkScalar  radius_x,
SkScalar  radius_y,
const SkMatrix ctm,
SkIRect output_bounds 
)
inlinestaticprotected

Definition at line 169 of file dl_image_filter.h.

173 {
174 if (ctm.isFinite()) {
175 if (ctm.hasPerspective()) {
176 SkMatrix inverse;
177 if (ctm.invert(&inverse)) {
178 SkRect local_bounds = inverse.mapRect(SkRect::Make(input_bounds));
179 local_bounds.inset(radius_x, radius_y);
180 output_bounds = ctm.mapRect(local_bounds).roundOut();
181 return &output_bounds;
182 }
183 } else {
184 SkVector device_radius = map_vectors_affine(ctm, radius_x, radius_y);
185 output_bounds = input_bounds.makeInset(floor(device_radius.fX), //
186 floor(device_radius.fY));
187 return &output_bounds;
188 }
189 }
190 output_bounds = input_bounds;
191 return nullptr;
192 }
bool invert(SkMatrix *inverse) const
Definition: SkMatrix.h:1206
bool hasPerspective() const
Definition: SkMatrix.h:312
bool isFinite() const
Definition: SkMatrix.h:1834
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
static SkVector map_vectors_affine(const SkMatrix &ctm, SkScalar x, SkScalar y)
SIN Vec< N, float > floor(const Vec< N, float > &x)
Definition: SkVx.h:703
SkIRect makeInset(int32_t dx, int32_t dy) const
Definition: SkRect.h:332
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
void inset(float dx, float dy)
Definition: SkRect.h:1060

◆ makeWithLocalMatrix()

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

Reimplemented in flutter::DlColorFilterImageFilter.

Definition at line 9 of file dl_image_filter.cc.

10 {
11 if (matrix.isIdentity()) {
12 return shared();
13 }
14 // Matrix
15 switch (this->matrix_capability()) {
17 if (!matrix.isTranslate()) {
18 // Nothing we can do at this point
19 return nullptr;
20 }
21 break;
22 }
24 if (!matrix.isScaleTranslate()) {
25 // Nothing we can do at this point
26 return nullptr;
27 }
28 break;
29 }
30 default:
31 break;
32 }
33 return std::make_shared<DlLocalMatrixImageFilter>(matrix, shared());
34}
bool isTranslate() const
Definition: SkMatrix.h:248
virtual std::shared_ptr< DlImageFilter > shared() const=0
virtual MatrixCapability matrix_capability() const
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ map_device_bounds()

virtual SkIRect * flutter::DlImageFilter::map_device_bounds ( const SkIRect input_bounds,
const SkMatrix ctm,
SkIRect output_bounds 
) const
pure virtual

◆ map_local_bounds()

virtual SkRect * flutter::DlImageFilter::map_local_bounds ( const SkRect input_bounds,
SkRect output_bounds 
) const
pure virtual

◆ map_vectors_affine()

static SkVector flutter::DlImageFilter::map_vectors_affine ( const SkMatrix ctm,
SkScalar  x,
SkScalar  y 
)
inlinestaticprotected

Definition at line 138 of file dl_image_filter.h.

140 {
141 FML_DCHECK(std::isfinite(x) && x >= 0);
142 FML_DCHECK(std::isfinite(y) && y >= 0);
143 FML_DCHECK(ctm.isFinite() && !ctm.hasPerspective());
144
145 // The x and y scalars would have been used to expand a local space
146 // rectangle which is then transformed by ctm. In order to do the
147 // expansion correctly, we should look at the relevant math. The
148 // 4 corners will be moved outward by the following vectors:
149 // (UL,UR,LR,LL) = ((-x, -y), (+x, -y), (+x, +y), (-x, +y))
150 // After applying the transform, each of these vectors could be
151 // pointing in any direction so we need to examine each transformed
152 // delta vector and how it affected the bounds.
153 // Looking at just the affine 2x3 entries of the CTM we can delta
154 // transform these corner offsets and get the following:
155 // UL = dCTM(-x, -y) = (- x*m00 - y*m01, - x*m10 - y*m11)
156 // UR = dCTM(+x, -y) = ( x*m00 - y*m01, x*m10 - y*m11)
157 // LR = dCTM(+x, +y) = ( x*m00 + y*m01, x*m10 + y*m11)
158 // LL = dCTM(-x, +y) = (- x*m00 + y*m01, - x*m10 + y*m11)
159 // The X vectors are all some variation of adding or subtracting
160 // the sum of x*m00 and y*m01 or their difference. Similarly the Y
161 // vectors are +/- the associated sum/difference of x*m10 and y*m11.
162 // The largest displacements, both left/right or up/down, will
163 // happen when the signs of the m00/m01/m10/m11 matrix entries
164 // coincide with the signs of the scalars, i.e. are all positive.
165 return {x * abs(ctm[0]) + y * abs(ctm[1]),
166 x * abs(ctm[3]) + y * abs(ctm[4])};
167 }
#define FML_DCHECK(condition)
Definition: logging.h:103
double y
double x
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition: SkVx.h:707

◆ matrix_capability()

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

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

Definition at line 133 of file dl_image_filter.h.

133 {
135 }

◆ modifies_transparent_black()

virtual bool flutter::DlImageFilter::modifies_transparent_black ( ) const
pure virtual

◆ outset_device_bounds()

static SkIRect * flutter::DlImageFilter::outset_device_bounds ( const SkIRect input_bounds,
SkScalar  radius_x,
SkScalar  radius_y,
const SkMatrix ctm,
SkIRect output_bounds 
)
inlinestaticprotected

Definition at line 194 of file dl_image_filter.h.

198 {
199 if (ctm.isFinite()) {
200 if (ctm.hasPerspective()) {
201 SkMatrix inverse;
202 if (ctm.invert(&inverse)) {
203 SkRect local_bounds = inverse.mapRect(SkRect::Make(input_bounds));
204 local_bounds.outset(radius_x, radius_y);
205 output_bounds = ctm.mapRect(local_bounds).roundOut();
206 return &output_bounds;
207 }
208 } else {
209 SkVector device_radius = map_vectors_affine(ctm, radius_x, radius_y);
210 output_bounds = input_bounds.makeOutset(ceil(device_radius.fX), //
211 ceil(device_radius.fY));
212 return &output_bounds;
213 }
214 }
215 output_bounds = input_bounds;
216 return nullptr;
217 }
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition: SkVx.h:702
SkIRect makeOutset(int32_t dx, int32_t dy) const
Definition: SkRect.h:350
void outset(float dx, float dy)
Definition: SkRect.h:1077

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