[cairo] [PATCH 6/6] DEBUGGING SUPPORT. NOT FOR TRUNK.

Bryce Harrington bryce at osg.samsung.com
Fri Nov 28 20:31:24 PST 2014


From: Bryce Harrington <b.harrington at samsung.com>

Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 src/cairo-default-context.c |   22 +++++++++-
 src/cairo-gstate.c          |    7 ++++
 src/cairo-matrix.c          |   96 ++++++++++++++++++++++++++++++++-----------
 src/cairo-pen.c             |    2 +-
 4 files changed, 99 insertions(+), 28 deletions(-)

diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c
index e4ceba4..8094e14 100644
--- a/src/cairo-default-context.c
+++ b/src/cairo-default-context.c
@@ -813,14 +813,32 @@ _cairo_default_context_rel_line_to (void *abstract_cr, double dx, double dy)
     double x, y;
 
     cairo_get_current_point ((cairo_t*)cr, &x, &y);
+
+    printf("_cairo_default_context_rel_line_to: %5.2f %5.2f -> ", x, y);
     x += dx;
     y += dy;
-    _cairo_gstate_user_to_backend (cr->gstate, &x, &y);
+    printf("%5.2f %5.2f -> ", x, y);
+
+    // This transforms the point to the gstate->ctm matrix
+    _cairo_gstate_user_to_device (cr->gstate, &x, &y);
+    printf("%5.2f %5.2f -> ", x, y);
 
     x_fixed = _cairo_fixed_from_double (x);
     y_fixed = _cairo_fixed_from_double (y);
-
+    printf("%d %d\n", x_fixed, y_fixed);
     return _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed);
+
+    /*
+    cairo_default_context_t *cr = abstract_cr;
+    cairo_fixed_t dx_fixed, dy_fixed;
+
+    _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);
+
+    dx_fixed = _cairo_fixed_from_double (dx);
+    dy_fixed = _cairo_fixed_from_double (dy);
+
+    return _cairo_path_fixed_line_to (cr->path, dx_fixed, dy_fixed);
+    */
 }
 
 
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index b4e988e..b8536dc 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -783,6 +783,13 @@ _cairo_gstate_identity_matrix (cairo_gstate_t *gstate)
 void
 _cairo_gstate_user_to_device (cairo_gstate_t *gstate, double *x, double *y)
 {
+    /*
+    printf("gstate->ctm: %f %f  %f %f  %f %f  %f %f\n",
+           gstate->ctm.xx, gstate->ctm.xy,
+           gstate->ctm.yx, gstate->ctm.yy,
+           gstate->ctm.x0, gstate->ctm.y0,
+           gstate->ctm.px, gstate->ctm.py);
+    */
     cairo_matrix_transform_point (&gstate->ctm, x, y);
 }
 
diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c
index 6d6e344..9662101 100644
--- a/src/cairo-matrix.c
+++ b/src/cairo-matrix.c
@@ -341,49 +341,85 @@ void
 cairo_matrix_multiply (cairo_matrix_t *result, const cairo_matrix_t *a, const cairo_matrix_t *b)
 {
     cairo_matrix_t r;
-    double p0;
-
-    r.xx = a->xx * b->xx + a->yx * b->xy + a->px * b->x0;
-    r.yx = a->xx * b->yx + a->yx * b->yy + a->px * b->y0;
-
-    r.xy = a->xy * b->xx + a->yy * b->xy + a->py * b->x0;
-    r.yy = a->xy * b->yx + a->yy * b->yy + a->py * b->y0;
-
-    r.x0 = a->x0 * b->xx + a->y0 * b->xy +     1 * b->x0;
-    r.y0 = a->x0 * b->yx + a->y0 * b->yy +     1 * b->y0;
-
-    r.px = a->xx * b->px + a->yx * b->py + a->px *     1;
-    r.py = a->xy * b->px + a->yy * b->py + a->py *     1;
-    p0   = a->x0 * b->px + a->y0 * b->py +     1 *     1;
-
-    printf("cairo_matrix_multiply: xx=%f yx=%f xy=%f yy=%f x0=%f y0=%f\n", r.xx, r.yx, r.xy, r.yy, r.x0, r.y0);
-
-    _cairo_matrix_scalar_multiply (&r, 1 / p0);
-
+    _cairo_matrix_multiply (&r, a, b);
     *result = r;
 }
 slim_hidden_def(cairo_matrix_multiply);
 
+/*
+ * _cairo_matrix_multiply:
+ *
+ * This multiplies two 3x3 matrices together.  Here is the mathematics
+ * for this operation:
+ *
+ *  r = A * B
+ *
+ *      { rxx rxy rx0 }   { Axx Axy Ax0 }   { Bxx Bxy Bx0 }
+ *  r = { ryx ryy ry0 } = { Ayx Ayy Ay0 } * { Byx Byy By0 }
+ *      { rpx rpy rp0 }   { Apx Apy 1   }   { Bpx Bpy 1   }
+ *
+ *        rxx = Axx*Bxx + Axy*Byx + Ax0*Bpx
+ *        rxy = Axx*Bxy + Axy*Byy + Ax0*Bpy
+ *        rx0 = Axx*Bx0 + Axy*By0 + Ax0*1
+ *
+ *        ryx = Ayx*Bxx + Ayy*Byx + Ay0*Bpx
+ *        ryy = Ayx*Bxy + Ayy*Byy + Ay0*Bpy
+ *        ry0 = Ayx*Bx0 + Ayy*By0 + Ay0*1
+ *
+ *        rpx = Apx*Bxx + Apy*Byx + 1  *Bpx
+ *        rpy = Apx*Bxy + Apy*Byy + 1  *Bpy
+ *        rp0 = Apx*Bx0 + Apy*By0 + 1  *1
+ */
 void
 _cairo_matrix_multiply (cairo_matrix_t *r,
 			const cairo_matrix_t *a,
 			const cairo_matrix_t *b)
 {
     double p0;
+/*  //Original non-projective case
+    r->xx = a->xx * b->xx + a->yx * b->xy;
+    r->yx = a->xx * b->yx + a->yx * b->yy;
 
-    r->xx = a->xx * b->xx + a->yx * b->xy + a->px * b->x0;
-    r->yx = a->xx * b->yx + a->yx * b->yy + a->px * b->y0;
+    r->xy = a->xy * b->xx + a->yy * b->xy;
+    r->yy = a->xy * b->yx + a->yy * b->yy;
 
+    r->x0 = a->x0 * b->xx + a->y0 * b->xy + b->x0;
+    r->y0 = a->x0 * b->yx + a->y0 * b->yy + b->y0;
+*/
+/*  // My calculation
+    r->xx = a->xx*b->xx + a->xy*b->yx + a->x0*b->px;
+    r->xy = a->xx*b->xy + a->xy*b->yy + a->x0*b->py;
+    r->x0 = a->xx*b->x0 + a->xy*b->y0 + a->x0*1;
+
+    r->yx = a->yx*b->xx + a->yy*b->yx + a->y0*b->px;
+    r->yy = a->yx*b->xy + a->yy*b->yy + a->y0*b->py;
+    r->y0 = a->yx*b->x0 + a->yy*b->y0 + a->y0*1;
+
+    r->px = a->px*b->xx + a->py*b->yx + 1  *b->px;
+    r->py = a->px*b->xy + a->py*b->yy + 1  *b->py;
+    p0    = a->px*b->x0 + a->py*b->y0 + 1  *1;
+*/
+  // Maarten's calculation
+    r->xx = a->xx * b->xx + a->yx * b->xy + a->px * b->x0;
     r->xy = a->xy * b->xx + a->yy * b->xy + a->py * b->x0;
-    r->yy = a->xy * b->yx + a->yy * b->yy + a->py * b->y0;
-
     r->x0 = a->x0 * b->xx + a->y0 * b->xy +     1 * b->x0;
+
+    r->yx = a->xx * b->yx + a->yx * b->yy + a->px * b->y0;
+    r->yy = a->xy * b->yx + a->yy * b->yy + a->py * b->y0;
     r->y0 = a->x0 * b->yx + a->y0 * b->yy +     1 * b->y0;
 
     r->px = a->xx * b->px + a->yx * b->py + a->px *     1;
     r->py = a->xy * b->px + a->yy * b->py + a->py *     1;
     p0    = a->x0 * b->px + a->y0 * b->py +     1 *     1;
 
+/*
+    printf("cairo_matrix_multiply: %f %f %f\n",
+	   r->xx, r->xy, r->x0);
+    printf("                       %f %f %f\n",
+	   r->yx, r->yy, r->y0);
+    printf("                       %f %f %f\n",
+	   r->px, r->py, p0);
+*/
     _cairo_matrix_scalar_multiply (r, 1 / p0);
 }
 
@@ -414,10 +450,10 @@ void
 cairo_matrix_transform_distance (const cairo_matrix_t *matrix, double *dx, double *dy)
 {
     double new_p;
-
     new_p = matrix->px * *dx + matrix->py * *dy + 1;
     *dx = (matrix->xx * *dx + matrix->xy * *dy) / new_p;
     *dy = (matrix->yx * *dx + matrix->yy * *dy) / new_p;
+    //printf("cairo_matrix_transform_distance: %f %f (%f)\n", *dx, *dy, new_p);
 }
 slim_hidden_def(cairo_matrix_transform_distance);
 
@@ -435,10 +471,14 @@ void
 cairo_matrix_transform_point (const cairo_matrix_t *matrix, double *x, double *y)
 {
     double new_p;
+    double old_x, old_y;
+    old_x = *x;
+    old_y = *y;
 
     new_p = matrix->px * *x + matrix->py * *y + 1;
     *x = (matrix->xx * *x + matrix->xy * *y + matrix->x0) / new_p;
     *y = (matrix->yx * *x + matrix->yy * *y + matrix->y0) / new_p;
+    //printf("cairo_matrix_transform_point %f %f -> %f %f (%f)\n", old_x, old_y, *x, *y, new_p);
 }
 slim_hidden_def(cairo_matrix_transform_point);
 
@@ -716,7 +756,7 @@ _cairo_matrix_compute_basis_scale_factors (const cairo_matrix_t *matrix,
 					   cairo_bool_t x_basis)
 {
     double det;
-
+    printf("_cairo_matrix_compute_basis_scale_factors");
     det = _cairo_matrix_compute_determinant (matrix);
 
     if (! ISFINITE (det))
@@ -1000,6 +1040,8 @@ _cairo_matrix_to_pixman_matrix (const cairo_matrix_t	*matrix,
     cairo_matrix_t inv;
     unsigned max_iterations;
 
+    printf("_cairo_matrix_to_pixman_matrix");
+
     pixman_transform->matrix[0][0] = _cairo_fixed_16_16_from_double (matrix->xx);
     pixman_transform->matrix[0][1] = _cairo_fixed_16_16_from_double (matrix->xy);
     pixman_transform->matrix[0][2] = _cairo_fixed_16_16_from_double (matrix->x0);
@@ -1116,6 +1158,8 @@ _cairo_matrix_is_pixman_translation (const cairo_matrix_t     *matrix,
 {
     double tx, ty;
 
+    printf("_cairo_matrix_is_pixman_translation");
+
     if (!_cairo_matrix_is_translation (matrix))
 	return FALSE;
 
@@ -1183,6 +1227,8 @@ _cairo_matrix_to_pixman_matrix_offset (const cairo_matrix_t	*matrix,
 {
     cairo_bool_t is_pixman_translation;
 
+    printf("_cairo_matrix_to_pixman_matrix_offset\n");
+
     is_pixman_translation = _cairo_matrix_is_pixman_translation (matrix,
 								 filter,
 								 x_offset,
diff --git a/src/cairo-pen.c b/src/cairo-pen.c
index 61be0e8..101625c 100644
--- a/src/cairo-pen.c
+++ b/src/cairo-pen.c
@@ -89,7 +89,7 @@ _cairo_pen_init (cairo_pen_t	*pen,
 	    theta = -theta;
 	dx = radius * cos (theta);
 	dy = radius * sin (theta);
-	cairo_matrix_transform_distance (ctm, &dx, &dy);
+	//cairo_matrix_transform_distance (ctm, &dx, &dy);
 	v->point.x = _cairo_fixed_from_double (dx);
 	v->point.y = _cairo_fixed_from_double (dy);
     }
-- 
1.7.9.5



More information about the cairo mailing list