summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-02-27 15:30:19 -0800
committerBryce Harrington <bryce@osg.samsung.com>2014-11-27 12:07:07 -0800
commit4d966220f0c64ad91ceef00474fc126021ea1028 (patch)
tree42a08649a045dfdb1aac4839fa16f45105786a2e
parentcd5540951a4b3a58e27f5e86d3e44547b1458dea (diff)
matrix: Refactor out two temporary variables
This makes the similarities and differences between cairo_matrix_transform_distance and cairo_matrix_transform_point easier to spot. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
-rw-r--r--src/cairo-matrix.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c
index 21c717e04..6d6e3446e 100644
--- a/src/cairo-matrix.c
+++ b/src/cairo-matrix.c
@@ -399,8 +399,8 @@ _cairo_matrix_multiply (cairo_matrix_t *r,
* the returned vector is as follows:
*
* <programlisting>
- * dx2 = dx1 * a + dy1 * c;
- * dy2 = dx1 * b + dy1 * d;
+ * dx2 = (dx1 * a + dy1 * c) / (dx1 * e + dy1 * f);
+ * dy2 = (dx1 * b + dy1 * d) / (dx1 * e + dy1 * f);
* </programlisting>
*
* Affine transformations are position invariant, so the same vector
@@ -413,16 +413,11 @@ _cairo_matrix_multiply (cairo_matrix_t *r,
void
cairo_matrix_transform_distance (const cairo_matrix_t *matrix, double *dx, double *dy)
{
- double new_x, new_y, new_p;
+ double new_p;
- new_x = (matrix->xx * *dx + matrix->xy * *dy);
- new_y = (matrix->yx * *dx + matrix->yy * *dy);
new_p = matrix->px * *dx + matrix->py * *dy + 1;
- new_x = new_x / new_p;
- new_y = new_y / new_p;
-
- *dx = new_x;
- *dy = new_y;
+ *dx = (matrix->xx * *dx + matrix->xy * *dy) / new_p;
+ *dy = (matrix->yx * *dx + matrix->yy * *dy) / new_p;
}
slim_hidden_def(cairo_matrix_transform_distance);