Flutter Engine
The Flutter Engine
|
#include <SkShaderBase.h>
Public Member Functions | |
MatrixRec ()=default | |
MatrixRec (const SkMatrix &ctm) | |
MatrixRec | concat (const SkMatrix &m) const |
std::optional< MatrixRec > | apply (const SkStageRec &rec, const SkMatrix &postInv={}) const |
std::tuple< SkMatrix, bool > | applyForFragmentProcessor (const SkMatrix &postInv) const |
MatrixRec | applied () const |
void | markTotalMatrixInvalid () |
void | markCTMApplied () |
bool | totalMatrixIsValid () const |
SkMatrix | totalMatrix () const |
bool | totalInverse (SkMatrix *out) const |
bool | hasPendingMatrix () const |
bool | rasterPipelineCoordsAreSeeded () const |
This is used to accumulate matrices, starting with the CTM, when building up SkRasterPipeline or GrFragmentProcessor by walking the SkShader tree. It avoids adding a matrix multiply for each individual matrix. It also handles the reverse matrix concatenation order required by Android Framework, see b/256873449.
This also tracks the dubious concept of a "total matrix", in the legacy Context/shadeSpan system. That includes all the matrices encountered during traversal to the current shader, including ones that have already been applied. The total matrix represents the transformation from the current shader's coordinate space to device space. It is dubious because it doesn't account for SkShaders that manipulate the coordinates passed to their children, which may not even be representable by a matrix.
The total matrix is used for mipmap level selection and a filter downgrade optimizations in SkImageShader and sizing of the SkImage created by SkPictureShader. If we can remove usages of the "total matrix" and if Android Framework could be updated to not use backwards local matrix concatenation this could just be replaced by a simple SkMatrix or SkM44 passed down during traversal.
Definition at line 57 of file SkShaderBase.h.
|
default |
|
explicit |
Definition at line 22 of file SkShaderBase.cpp.
MatrixRec SkShaders::MatrixRec::applied | ( | ) | const |
A parent FP may need to create a FP for its child by calling SkShaderBase::asFragmentProcessor() and then pass the result to the apply() above. This comes up when the parent needs to ensure pending matrices are applied before the child because the parent is going to manipulate the coordinates after any pending matrix and pass the resulting coords to the child. This function gets a MatrixRec that reflects the state after this MatrixRec has bee applied but it does not apply it! Example: auto childFP = fChild->asFragmentProcessor(args, mrec.applied()); childFP = MakeAWrappingFPThatModifiesChildsCoords(std::move(childFP)); auto [success, parentFP] = mrec.apply(std::move(childFP));
Definition at line 54 of file SkShaderBase.cpp.
std::optional< MatrixRec > SkShaders::MatrixRec::apply | ( | const SkStageRec & | rec, |
const SkMatrix & | postInv = {} |
||
) | const |
Appends a mul by the inverse of the pending local matrix to the pipeline. 'postInv' is an additional matrix to post-apply to the inverted pending matrix. If the pending matrix is not invertible the std::optional result won't have a value and the pipeline will be unmodified.
Definition at line 24 of file SkShaderBase.cpp.
std::tuple< SkMatrix, bool > SkShaders::MatrixRec::applyForFragmentProcessor | ( | const SkMatrix & | postInv | ) | const |
FP matrices work differently than SkRasterPipeline. The starting coordinates provided to the root SkShader's FP are already in local space. So we never apply the inverse CTM. This returns the inverted pending local matrix with the provided postInv matrix applied after it. If the pending local matrix cannot be inverted, the boolean is false.
Definition at line 45 of file SkShaderBase.cpp.
Returns a new MatrixRec that represents the existing total and pending matrix pre-concat'ed with m.
Definition at line 64 of file SkShaderBase.cpp.
|
inline |
Is there a transform that has not yet been applied by a parent shader?
Definition at line 125 of file SkShaderBase.h.
|
inline |
Marks the CTM as already applied; can avoid re-seeding the shader unnecessarily.
Definition at line 104 of file SkShaderBase.h.
|
inline |
Call to indicate that the mapping from shader to device space is not known.
Definition at line 101 of file SkShaderBase.h.
|
inline |
When generating raster pipeline, have the device coordinates been seeded?
Definition at line 130 of file SkShaderBase.h.
|
inline |
Gets the inverse of totalMatrix(), if invertible.
Definition at line 120 of file SkShaderBase.h.
|
inline |
Gets the total transform from the current shader's space to device space. This may or may not be valid. Shaders should avoid making decisions based on this matrix if totalMatrixIsValid() is false.
Definition at line 117 of file SkShaderBase.h.
|
inline |
Indicates whether the total matrix of a MatrixRec passed to a SkShader actually represents the full transform between that shader's coordinate space and device space.
Definition at line 110 of file SkShaderBase.h.