Improve horizontal baseline detection.

The goal is to hint the baseline when hinting is possible, which is
to say when the glyphs are be aligned with the pixel grid. The
current code has three shortcomings.

1. correctly snaps when the horizontal baseline is on the x-axis but
not when on the y-axis. Instead it is snapping the horizontal
baseline when there is y-skew.

2. tests against the full device matrix instead of the relaxed
matrix used by the scaler context.

3. has range issues when relaxing the matrix.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1740163002

Review URL: https://codereview.chromium.org/1740163002
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index caef2d1..c67ca3e 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -827,13 +827,21 @@
     }
 }
 
-SkAxisAlignment SkComputeAxisAlignmentForHText(const SkMatrix& matrix) {
-    SkASSERT(!matrix.hasPerspective());
+SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText() {
+    // Why fPost2x2 can be used here.
+    // getSingleMatrix multiplies in getLocalMatrix, which consists of
+    // * fTextSize (a scale, which has no effect)
+    // * fPreScaleX (a scale in x, which has no effect)
+    // * fPreSkewX (has no effect, but would on vertical text alignment).
+    // In other words, making the text bigger, stretching it along the
+    // horizontal axis, or fake italicizing it does not move the baseline.
 
-    if (0 == matrix[SkMatrix::kMSkewY]) {
+    if (0 == fRec.fPost2x2[1][0]) {
+        // The x axis is mapped onto the x axis.
         return kX_SkAxisAlignment;
     }
-    if (0 == matrix[SkMatrix::kMSkewX]) {
+    if (0 == fRec.fPost2x2[0][0]) {
+        // The x axis is mapped onto the y axis.
         return kY_SkAxisAlignment;
     }
     return kNone_SkAxisAlignment;