aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkMatrix22.h
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-15 15:52:07 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-15 15:52:07 +0000
commitd3fbd34099a530b5415c95b1f2f8149ac417b9b3 (patch)
tree378e0b3e153d4a3f252c6f766d575e54c9f704c7 /src/utils/SkMatrix22.h
parent73cb15351f33459e0c861a96135c634dec77ef9d (diff)
Fix size of rotated text with FreeType.
This generalizes and shares the solution found for a similar issue with GDI. The issue is that the text size is applied early, and the rest of the transformation late. This allows us to isolate and independently control the text size from the rest of the transformation. R=reed@google.com Review URL: https://codereview.chromium.org/213153006 git-svn-id: http://skia.googlecode.com/svn/trunk@14201 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/SkMatrix22.h')
-rw-r--r--src/utils/SkMatrix22.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/utils/SkMatrix22.h b/src/utils/SkMatrix22.h
new file mode 100644
index 0000000000..d0f4ed3155
--- /dev/null
+++ b/src/utils/SkMatrix22.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkPoint.h"
+
+class SkMatrix;
+
+/** Find the Givens matrix G, which is the rotational matrix
+ * that rotates the vector h to the positive hoizontal axis.
+ * G * h = [hypot(h), 0]
+ *
+ * This is equivalent to
+ *
+ * SkScalar r = h.length();
+ * SkScalar r_inv = r ? SkScalarInvert(r) : 0;
+ * h.scale(r_inv);
+ * G->setSinCos(-h.fY, h.fX);
+ *
+ * but has better numerical stability by using (partial) hypot,
+ * and saves a multiply by not computing r.
+ */
+void SkComputeGivensRotation(const SkVector& h, SkMatrix* G);