Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skif::LayerSpace< SkMatrix > Class Reference

#include <SkImageFilterTypes.h>

Public Member Functions

 LayerSpace ()=default
 
 LayerSpace (const SkMatrix &m)
 
 LayerSpace (SkMatrix &&m)
 
 operator const SkMatrix & () const
 
LayerSpace< SkRectmapRect (const LayerSpace< SkRect > &r) const
 
LayerSpace< SkIRectmapRect (const LayerSpace< SkIRect > &r) const
 
LayerSpace< SkPointmapPoint (const LayerSpace< SkPoint > &p) const
 
LayerSpace< VectormapVector (const LayerSpace< Vector > &v) const
 
LayerSpace< SkSizemapSize (const LayerSpace< SkSize > &s) const
 
LayerSpace< SkMatrix > & preConcat (const LayerSpace< SkMatrix > &m)
 
LayerSpace< SkMatrix > & postConcat (const LayerSpace< SkMatrix > &m)
 
bool invert (LayerSpace< SkMatrix > *inverse) const
 
bool inverseMapRect (const LayerSpace< SkRect > &r, LayerSpace< SkRect > *out) const
 
bool inverseMapRect (const LayerSpace< SkIRect > &r, LayerSpace< SkIRect > *out) const
 
float rc (int row, int col) const
 
float get (int i) const
 

Static Public Member Functions

static LayerSpace< SkMatrixRectToRect (const LayerSpace< SkRect > &from, const LayerSpace< SkRect > &to)
 

Detailed Description

Definition at line 490 of file SkImageFilterTypes.h.

Constructor & Destructor Documentation

◆ LayerSpace() [1/3]

skif::LayerSpace< SkMatrix >::LayerSpace ( )
default

◆ LayerSpace() [2/3]

skif::LayerSpace< SkMatrix >::LayerSpace ( const SkMatrix m)
inlineexplicit

Definition at line 493 of file SkImageFilterTypes.h.

◆ LayerSpace() [3/3]

skif::LayerSpace< SkMatrix >::LayerSpace ( SkMatrix &&  m)
inlineexplicit

Definition at line 494 of file SkImageFilterTypes.h.

494: fData(std::move(m)) {}

Member Function Documentation

◆ get()

float skif::LayerSpace< SkMatrix >::get ( int  i) const
inline

Definition at line 535 of file SkImageFilterTypes.h.

535{ return fData.get(i); }
SkScalar get(int index) const
Definition: SkMatrix.h:392

◆ inverseMapRect() [1/2]

bool skif::LayerSpace< SkMatrix >::inverseMapRect ( const LayerSpace< SkIRect > &  r,
LayerSpace< SkIRect > *  out 
) const

Definition at line 478 of file SkImageFilterTypes.cpp.

479 {
480 if (rect.isEmpty()) {
481 // An empty input always inverse maps to an empty rect "successfully"
483 return true;
484 } else if (fData.isScaleTranslate()) { // Specialized inverse of 1px-preserving map<SkIRect>
485 // A scale-translate matrix with a 0 scale factor is not invertible.
486 if (fData.getScaleX() == 0.f || fData.getScaleY() == 0.f) {
487 return false;
488 }
489 double l = (rect.left() - (double)fData.getTranslateX()) / (double)fData.getScaleX();
490 double r = (rect.right() - (double)fData.getTranslateX()) / (double)fData.getScaleX();
491 double t = (rect.top() - (double)fData.getTranslateY()) / (double)fData.getScaleY();
492 double b = (rect.bottom() - (double)fData.getTranslateY()) / (double)fData.getScaleY();
493
494 SkIRect mapped{sk_double_saturate2int(std::floor(std::min(l, r) + kRoundEpsilon)),
495 sk_double_saturate2int(std::floor(std::min(t, b) + kRoundEpsilon)),
496 sk_double_saturate2int(std::ceil(std::max(l, r) - kRoundEpsilon)),
497 sk_double_saturate2int(std::ceil(std::max(t, b) - kRoundEpsilon))};
498 *out = LayerSpace<SkIRect>(mapped);
499 return true;
500 } else {
501 SkRect mapped;
502 if (SkMatrixPriv::InverseMapRect(fData, &mapped, SkRect::Make(SkIRect(rect)))) {
503 *out = LayerSpace<SkRect>(mapped).roundOut();
504 return true;
505 }
506 }
507
508 return false;
509}
static constexpr int sk_double_saturate2int(double x)
static bool InverseMapRect(const SkMatrix &mx, SkRect *dst, const SkRect &src)
Definition: SkMatrixPriv.h:54
SkScalar getTranslateY() const
Definition: SkMatrix.h:452
SkScalar getScaleX() const
Definition: SkMatrix.h:415
SkScalar getScaleY() const
Definition: SkMatrix.h:422
bool isScaleTranslate() const
Definition: SkMatrix.h:236
SkScalar getTranslateX() const
Definition: SkMatrix.h:445
static bool b
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
SK_API sk_sp< SkShader > Empty()
SIN Vec< N, float > floor(const Vec< N, float > &x)
Definition: SkVx.h:703
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition: SkVx.h:702
Definition: SkRect.h:32
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ inverseMapRect() [2/2]

bool skif::LayerSpace< SkMatrix >::inverseMapRect ( const LayerSpace< SkRect > &  r,
LayerSpace< SkRect > *  out 
) const

Definition at line 463 of file SkImageFilterTypes.cpp.

464 {
465 SkRect mapped;
466 if (r.isEmpty()) {
467 // An empty input always inverse maps to an empty rect "successfully"
469 return true;
470 } else if (SkMatrixPriv::InverseMapRect(fData, &mapped, SkRect(r))) {
471 *out = LayerSpace<SkRect>(mapped);
472 return true;
473 } else {
474 return false;
475 }
476}

◆ invert()

bool skif::LayerSpace< SkMatrix >::invert ( LayerSpace< SkMatrix > *  inverse) const
inline

Definition at line 525 of file SkImageFilterTypes.h.

525 {
526 return fData.invert(&inverse->fData);
527 }
bool invert(SkMatrix *inverse) const
Definition: SkMatrix.h:1206

◆ mapPoint()

LayerSpace< SkPoint > skif::LayerSpace< SkMatrix >::mapPoint ( const LayerSpace< SkPoint > &  p) const

Definition at line 451 of file SkImageFilterTypes.cpp.

451 {
452 return LayerSpace<SkPoint>(Mapping::map(SkPoint(p), fData));
453}

◆ mapRect() [1/2]

LayerSpace< SkIRect > skif::LayerSpace< SkMatrix >::mapRect ( const LayerSpace< SkIRect > &  r) const

Definition at line 447 of file SkImageFilterTypes.cpp.

447 {
448 return LayerSpace<SkIRect>(Mapping::map(SkIRect(r), fData));
449}

◆ mapRect() [2/2]

LayerSpace< SkRect > skif::LayerSpace< SkMatrix >::mapRect ( const LayerSpace< SkRect > &  r) const

Definition at line 441 of file SkImageFilterTypes.cpp.

441 {
442 return LayerSpace<SkRect>(Mapping::map(SkRect(r), fData));
443}

◆ mapSize()

LayerSpace< SkSize > skif::LayerSpace< SkMatrix >::mapSize ( const LayerSpace< SkSize > &  s) const

Definition at line 459 of file SkImageFilterTypes.cpp.

459 {
460 return LayerSpace<SkSize>(Mapping::map(SkSize(s), fData));
461}
struct MyStruct s
Definition: SkSize.h:52

◆ mapVector()

LayerSpace< Vector > skif::LayerSpace< SkMatrix >::mapVector ( const LayerSpace< Vector > &  v) const

Definition at line 455 of file SkImageFilterTypes.cpp.

455 {
456 return LayerSpace<Vector>(Mapping::map(Vector(v), fData));
457}

◆ operator const SkMatrix &()

skif::LayerSpace< SkMatrix >::operator const SkMatrix & ( ) const
inlineexplicit

Definition at line 495 of file SkImageFilterTypes.h.

495{ return fData; }

◆ postConcat()

LayerSpace< SkMatrix > & skif::LayerSpace< SkMatrix >::postConcat ( const LayerSpace< SkMatrix > &  m)
inline

Definition at line 520 of file SkImageFilterTypes.h.

520 {
521 fData = SkMatrix::Concat(m.fData, fData);
522 return *this;
523 }
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition: SkMatrix.h:1775

◆ preConcat()

LayerSpace< SkMatrix > & skif::LayerSpace< SkMatrix >::preConcat ( const LayerSpace< SkMatrix > &  m)
inline

Definition at line 515 of file SkImageFilterTypes.h.

515 {
516 fData = SkMatrix::Concat(fData, m.fData);
517 return *this;
518 }

◆ rc()

float skif::LayerSpace< SkMatrix >::rc ( int  row,
int  col 
) const
inline

Definition at line 534 of file SkImageFilterTypes.h.

534{ return fData.rc(row, col); }
SkScalar rc(int r, int c) const
Definition: SkMatrix.h:404

◆ RectToRect()

static LayerSpace< SkMatrix > skif::LayerSpace< SkMatrix >::RectToRect ( const LayerSpace< SkRect > &  from,
const LayerSpace< SkRect > &  to 
)
inlinestatic

Definition at line 497 of file SkImageFilterTypes.h.

498 {
499 return LayerSpace<SkMatrix>(SkMatrix::RectToRect(SkRect(from), SkRect(to)));
500 }
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition: SkMatrix.h:157

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