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 854 of file SkScalerContext.cpp.
856{
857
860
861
862 if (A_out) {
864 }
865
866
868 bool skewedOrFlipped =
A.getSkewX() ||
A.getSkewY() ||
A.getScaleX() < 0 ||
A.getScaleY() < 0;
869 if (skewedOrFlipped) {
870
871
874
875
878
881
882
883 if (G_inv) {
888 }
889 } else {
891 if (G_inv) {
892 G_inv->reset();
893 }
894 }
895
896
897
898
899
900
904 {
907 sA->setScale(0, 0);
908 if (GsA) {
909 GsA->setScale(0, 0);
910 }
911 if (G_inv) {
912 G_inv->reset();
913 }
914 return false;
915 }
916
917
918 switch (preMatrixScale) {
922 break;
927 break;
928 }
932 if (intYScale == 0) {
934 }
937 break;
938 }
939 }
940
941
942 if (!skewedOrFlipped && (
945 {
946
947
948 sA->reset();
950
951 sA->reset();
952 sA->setScaleX(
A.getScaleX() /
s->fY);
953 } else {
954
957 }
958
959
960 if (GsA) {
961 *GsA = GA;
962
964 }
965
966 return true;
967}
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