Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
skif::Mapping Class Reference

#include <SkImageFilterTypes.h>

Public Member Functions

 Mapping ()=default
 
 Mapping (const SkMatrix &paramToLayer)
 
 Mapping (const SkMatrix &layerToDev, const SkMatrix &devToLayer, const SkMatrix &paramToLayer)
 
bool decomposeCTM (const SkMatrix &ctm, const SkImageFilter *filter, const skif::ParameterSpace< SkPoint > &representativePt)
 
bool decomposeCTM (const SkMatrix &ctm, MatrixCapability, const skif::ParameterSpace< SkPoint > &representativePt)
 
void concatLocal (const SkMatrix &local)
 
bool adjustLayerSpace (const SkMatrix &layer)
 
void applyOrigin (const LayerSpace< SkIPoint > &origin)
 
const SkMatrixlayerToDevice () const
 
const SkMatrixdeviceToLayer () const
 
const SkMatrixlayerMatrix () const
 
SkMatrix totalMatrix () const
 
template<typename T >
LayerSpace< TparamToLayer (const ParameterSpace< T > &paramGeometry) const
 
template<typename T >
LayerSpace< TdeviceToLayer (const DeviceSpace< T > &devGeometry) const
 
template<typename T >
DeviceSpace< TlayerToDevice (const LayerSpace< T > &layerGeometry) const
 

Friends

class LayerSpace< SkMatrix >
 
class FilterResult
 

Detailed Description

Definition at line 557 of file SkImageFilterTypes.h.

Constructor & Destructor Documentation

◆ Mapping() [1/3]

skif::Mapping::Mapping ( )
default

◆ Mapping() [2/3]

skif::Mapping::Mapping ( const SkMatrix paramToLayer)
inlineexplicit

Definition at line 562 of file SkImageFilterTypes.h.

563 : fLayerToDevMatrix(SkMatrix::I())
564 , fParamToLayerMatrix(paramToLayer)
565 , fDevToLayerMatrix(SkMatrix::I()) {}
static const SkMatrix & I()
LayerSpace< T > paramToLayer(const ParameterSpace< T > &paramGeometry) const

◆ Mapping() [3/3]

skif::Mapping::Mapping ( const SkMatrix layerToDev,
const SkMatrix devToLayer,
const SkMatrix paramToLayer 
)
inline

Definition at line 569 of file SkImageFilterTypes.h.

570 : fLayerToDevMatrix(layerToDev)
571 , fParamToLayerMatrix(paramToLayer)
572 , fDevToLayerMatrix(devToLayer) {}

Member Function Documentation

◆ adjustLayerSpace()

bool skif::Mapping::adjustLayerSpace ( const SkMatrix layer)

Definition at line 299 of file SkImageFilterTypes.cpp.

299 {
300 SkMatrix invLayer;
301 if (!layer.invert(&invLayer)) {
302 return false;
303 }
304 fParamToLayerMatrix.postConcat(layer);
305 fDevToLayerMatrix.postConcat(layer);
306 fLayerToDevMatrix.preConcat(invLayer);
307 return true;
308}
SkMatrix & postConcat(const SkMatrix &other)
Definition SkMatrix.cpp:683
bool invert(SkMatrix *inverse) const
Definition SkMatrix.h:1206
SkMatrix & preConcat(const SkMatrix &other)
Definition SkMatrix.cpp:674

◆ applyOrigin()

void skif::Mapping::applyOrigin ( const LayerSpace< SkIPoint > &  origin)
inline

Definition at line 600 of file SkImageFilterTypes.h.

600 {
601 SkAssertResult(this->adjustLayerSpace(SkMatrix::Translate(-origin.x(), -origin.y())));
602 }
#define SkAssertResult(cond)
Definition SkAssert.h:123
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition SkMatrix.h:91
bool adjustLayerSpace(const SkMatrix &layer)

◆ concatLocal()

void skif::Mapping::concatLocal ( const SkMatrix local)
inline

Definition at line 588 of file SkImageFilterTypes.h.

588{ fParamToLayerMatrix.preConcat(local); }

◆ decomposeCTM() [1/2]

bool skif::Mapping::decomposeCTM ( const SkMatrix ctm,
const SkImageFilter filter,
const skif::ParameterSpace< SkPoint > &  representativePt 
)

Definition at line 290 of file SkImageFilterTypes.cpp.

292 {
293 return this->decomposeCTM(
294 ctm,
295 filter ? as_IFB(filter)->getCTMCapability() : MatrixCapability::kComplex,
296 representativePt);
297}
static SkImageFilter_Base * as_IFB(SkImageFilter *filter)
bool decomposeCTM(const SkMatrix &ctm, const SkImageFilter *filter, const skif::ParameterSpace< SkPoint > &representativePt)

◆ decomposeCTM() [2/2]

bool skif::Mapping::decomposeCTM ( const SkMatrix ctm,
MatrixCapability  capability,
const skif::ParameterSpace< SkPoint > &  representativePt 
)

Definition at line 257 of file SkImageFilterTypes.cpp.

258 {
259 SkMatrix remainder, layer;
260 if (capability == MatrixCapability::kTranslate) {
261 // Apply the entire CTM post-filtering
262 remainder = ctm;
263 layer = SkMatrix::I();
264 } else if (ctm.isScaleTranslate() || capability == MatrixCapability::kComplex) {
265 // Either layer space can be anything (kComplex) - or - it can be scale+translate, and the
266 // ctm is. In both cases, the layer space can be equivalent to device space.
267 remainder = SkMatrix::I();
268 layer = ctm;
269 } else {
270 // This case implies some amount of sampling post-filtering, either due to skew or rotation
271 // in the original matrix. As such, keep the layer matrix as simple as possible.
272 decompose_transform(ctm, SkPoint(representativePt), &remainder, &layer);
273 }
274
275 SkMatrix invRemainder;
276 if (!remainder.invert(&invRemainder)) {
277 // Under floating point arithmetic, it's possible to decompose an invertible matrix into
278 // a scaling matrix and a remainder and have the remainder be non-invertible. Generally
279 // when this happens the scale factors are so large and the matrix so ill-conditioned that
280 // it's unlikely that any drawing would be reasonable, so failing to make a layer is okay.
281 return false;
282 } else {
283 fParamToLayerMatrix = layer;
284 fLayerToDevMatrix = remainder;
285 fDevToLayerMatrix = invRemainder;
286 return true;
287 }
288}
bool isScaleTranslate() const
Definition SkMatrix.h:236

◆ deviceToLayer() [1/2]

const SkMatrix & skif::Mapping::deviceToLayer ( ) const
inline

Definition at line 605 of file SkImageFilterTypes.h.

605{ return fDevToLayerMatrix; }

◆ deviceToLayer() [2/2]

template<typename T >
LayerSpace< T > skif::Mapping::deviceToLayer ( const DeviceSpace< T > &  devGeometry) const
inline

Definition at line 617 of file SkImageFilterTypes.h.

617 {
618 return LayerSpace<T>(map(static_cast<const T&>(devGeometry), fDevToLayerMatrix));
619 }
#define T

◆ layerMatrix()

const SkMatrix & skif::Mapping::layerMatrix ( ) const
inline

Definition at line 606 of file SkImageFilterTypes.h.

606{ return fParamToLayerMatrix; }

◆ layerToDevice() [1/2]

const SkMatrix & skif::Mapping::layerToDevice ( ) const
inline

Definition at line 604 of file SkImageFilterTypes.h.

604{ return fLayerToDevMatrix; }

◆ layerToDevice() [2/2]

template<typename T >
DeviceSpace< T > skif::Mapping::layerToDevice ( const LayerSpace< T > &  layerGeometry) const
inline

Definition at line 622 of file SkImageFilterTypes.h.

622 {
623 return DeviceSpace<T>(map(static_cast<const T&>(layerGeometry), fLayerToDevMatrix));
624 }

◆ paramToLayer()

template<typename T >
LayerSpace< T > skif::Mapping::paramToLayer ( const ParameterSpace< T > &  paramGeometry) const
inline

Definition at line 612 of file SkImageFilterTypes.h.

612 {
613 return LayerSpace<T>(map(static_cast<const T&>(paramGeometry), fParamToLayerMatrix));
614 }

◆ totalMatrix()

SkMatrix skif::Mapping::totalMatrix ( ) const
inline

Definition at line 607 of file SkImageFilterTypes.h.

607 {
608 return SkMatrix::Concat(fLayerToDevMatrix, fParamToLayerMatrix);
609 }
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.h:1775

Friends And Related Symbol Documentation

◆ FilterResult

friend class FilterResult
friend

Definition at line 628 of file SkImageFilterTypes.h.

◆ LayerSpace< SkMatrix >

friend class LayerSpace< SkMatrix >
friend

Definition at line 622 of file SkImageFilterTypes.h.


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