Compute useful matrices for use with sizing in underlying libraries.
There are two kinds of text size, a 'requested/logical size' which is like asking for size '12' and a 'real' size which is the size after the matrix is applied. The matrices produced by this method are based on the 'real' size. This method effectively finds the total device matrix and decomposes it in various ways.
The most useful decomposition is into 'scale' and 'remaining'. The 'scale' is applied first and then the 'remaining' to fully apply the total matrix. This decomposition is useful when the text size ('scale') may have meaning apart from the total matrix. This is true when hinting, and sometimes true for other properties as well.
The second (optional) decomposition is of 'remaining' into a non-rotational part 'remainingWithoutRotation' and a rotational part 'remainingRotation'. The 'scale' is applied first, then 'remainingWithoutRotation', then 'remainingRotation' to fully apply the total matrix. This decomposition is helpful when only horizontal metrics can be trusted, so the 'scale' and 'remainingWithoutRotation' will be handled by the underlying library, but the final rotation 'remainingRotation' will be handled manually.
The 'total' matrix is also (optionally) available. This is useful in cases where the underlying library will not be used, often when working directly with font data.
The parameters 'scale' and 'remaining' are required, the other pointers may be nullptr.
- Parameters
-
preMatrixScale | the kind of scale to extract from the total matrix. |
scale | the scale extracted from the total matrix (both values positive). |
remaining | apply after scale to apply the total matrix. |
remainingWithoutRotation | apply after scale to apply the total matrix sans rotation. |
remainingRotation | apply after remainingWithoutRotation to apply the total matrix. |
total | the total matrix. |
- Returns
- false if the matrix was singular. The output will be valid but not invertible.
Definition at line 862 of file SkScalerContext.cpp.
864{
865
868
869
870 if (A_out) {
872 }
873
874
876 bool skewedOrFlipped =
A.getSkewX() ||
A.getSkewY() ||
A.getScaleX() < 0 ||
A.getScaleY() < 0;
877 if (skewedOrFlipped) {
878
879
882
883
886
889
890
891 if (G_inv) {
896 }
897 } else {
899 if (G_inv) {
900 G_inv->reset();
901 }
902 }
903
904
905
906
907
908
912 {
915 sA->setScale(0, 0);
916 if (GsA) {
917 GsA->setScale(0, 0);
918 }
919 if (G_inv) {
920 G_inv->reset();
921 }
922 return false;
923 }
924
925
926 switch (preMatrixScale) {
930 break;
935 break;
936 }
940 if (intYScale == 0) {
942 }
945 break;
946 }
947 }
948
949
950 if (!skewedOrFlipped && (
953 {
954
955
956 sA->reset();
958
959 sA->reset();
960 sA->setScaleX(
A.getScaleX() /
s->fY);
961 } else {
962
965 }
966
967
968 if (GsA) {
969 *GsA = GA;
970
972 }
973
974 return true;
975}
void SkComputeGivensRotation(const SkVector &h, SkMatrix *G)
#define SkScalarInvert(x)
#define SK_ScalarNearlyZero
#define SkScalarRoundToScalar(x)
static constexpr int kMScaleX
horizontal scale factor
static constexpr int kMTransY
vertical translation
static constexpr int kMPersp1
input y perspective factor
SkMatrix & setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar persp0, SkScalar persp1, SkScalar persp2)
SkMatrix & preConcat(const SkMatrix &other)
static constexpr int kMPersp0
input x perspective factor
static constexpr int kMPersp2
perspective bias
static constexpr int kMTransX
horizontal translation
static constexpr int kMSkewY
vertical skew factor
SkScalar get(int index) const
static constexpr int kMScaleY
vertical scale factor
static constexpr int kMSkewX
horizontal skew factor
SkMatrix & preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
static constexpr SkPoint Make(float x, float y)
void getSingleMatrix(SkMatrix *) const