diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-11-07 22:09:01 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-11-07 22:09:52 +0100 |
commit | 94e9f134070ad5c3d19942cf38e9572f215ca907 (patch) | |
tree | f45f76d2f0b30860df5079bdd3e37f180cfaa293 | |
parent | 54bddb0b17c297bc553e62477aee7709bf3e231a (diff) |
-rw-r--r-- | src/cairo-box-private.h | 14 | ||||
-rw-r--r-- | src/cairo-path-bounds.c | 20 | ||||
-rw-r--r-- | src/cairo-path-fixed-private.h | 12 | ||||
-rw-r--r-- | src/cairo-path-fixed.c | 174 | ||||
-rw-r--r-- | src/cairo-path.c | 20 | ||||
-rw-r--r-- | src/cairo-rectangle.c | 12 | ||||
-rw-r--r-- | src/cairo-spline.c | 20 | ||||
-rw-r--r-- | src/cairo-types-private.h | 5 | ||||
-rw-r--r-- | src/cairo.c | 63 | ||||
-rw-r--r-- | src/cairoint.h | 60 |
10 files changed, 176 insertions, 224 deletions
diff --git a/src/cairo-box-private.h b/src/cairo-box-private.h index 3bced9966..2856c3709 100644 --- a/src/cairo-box-private.h +++ b/src/cairo-box-private.h @@ -39,9 +39,9 @@ #include "cairo-compiler-private.h" static inline void -_cairo_box_set (cairo_box_t *box, - const cairo_point_t *p1, - const cairo_point_t *p2) +_cairo_box_set (cairo_box_double_t *box, + const cairo_point_double_t *p1, + const cairo_point_double_t *p2) { box->p1 = *p1; box->p2 = *p2; @@ -49,8 +49,8 @@ _cairo_box_set (cairo_box_t *box, /* assumes box->p1 is top-left, p2 bottom-right */ static inline void -_cairo_box_add_point (cairo_box_t *box, - const cairo_point_t *point) +_cairo_box_add_point (cairo_box_double_t *box, + const cairo_point_double_t *point) { if (point->x < box->p1.x) box->p1.x = point->x; @@ -65,8 +65,8 @@ _cairo_box_add_point (cairo_box_t *box, /* assumes box->p1 is top-left, p2 bottom-right */ static inline cairo_bool_t -_cairo_box_contains_point (cairo_box_t *box, - const cairo_point_t *point) +_cairo_box_contains_point (cairo_box_double_t *box, + const cairo_point_double_t *point) { return box->p1.x <= point->x && point->x <= box->p2.x && box->p1.y <= point->y && point->y <= box->p2.y; diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c index d17d9a207..f505fe137 100644 --- a/src/cairo-path-bounds.c +++ b/src/cairo-path-bounds.c @@ -41,14 +41,14 @@ typedef struct _cairo_path_bounder { - cairo_point_t current_point; + cairo_point_double_t current_point; cairo_bool_t has_extents; - cairo_box_t extents; + cairo_box_double_t extents; } cairo_path_bounder_t; static cairo_status_t _cairo_path_bounder_move_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cairo_path_bounder_t *bounder = closure; @@ -66,7 +66,7 @@ _cairo_path_bounder_move_to (void *closure, static cairo_status_t _cairo_path_bounder_line_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cairo_path_bounder_t *bounder = closure; @@ -78,9 +78,9 @@ _cairo_path_bounder_line_to (void *closure, static cairo_status_t _cairo_path_bounder_curve_to (void *closure, - const cairo_point_t *b, - const cairo_point_t *c, - const cairo_point_t *d) + const cairo_point_double_t *b, + const cairo_point_double_t *c, + const cairo_point_double_t *d) { cairo_path_bounder_t *bounder = closure; @@ -100,7 +100,7 @@ _cairo_path_bounder_close_path (void *closure) cairo_bool_t _cairo_path_bounder_extents (const cairo_path_fixed_t *path, - cairo_box_t *extents) + cairo_box_double_t *extents) { cairo_path_bounder_t bounder; cairo_status_t status; @@ -205,8 +205,8 @@ _cairo_path_fixed_stroke_extents (const cairo_path_fixed_t *path, cairo_bool_t _cairo_path_fixed_extents (const cairo_path_fixed_t *path, - cairo_box_t *box) + cairo_box_double_t *box) { - *box = path->extents; + /* TODO *box = path->extents; */ return path->has_extents; } diff --git a/src/cairo-path-fixed-private.h b/src/cairo-path-fixed-private.h index 9fcd5020b..181576690 100644 --- a/src/cairo-path-fixed-private.h +++ b/src/cairo-path-fixed-private.h @@ -55,9 +55,9 @@ enum cairo_path_op { /* we want to make sure a single byte is used for the enum */ typedef char cairo_path_op_t; -/* make _cairo_path_fixed fit into ~512 bytes -- about 50 items */ +/* make _cairo_path_fixed fit into ~512 bytes -- about 25 items */ #define CAIRO_PATH_BUF_SIZE ((512 - sizeof (cairo_path_buf_t)) \ - / (2 * sizeof (cairo_point_t) + sizeof (cairo_path_op_t))) + / (2 * sizeof (cairo_point_double_t) + sizeof (cairo_path_op_t))) typedef struct _cairo_path_buf { cairo_list_t link; @@ -67,14 +67,14 @@ typedef struct _cairo_path_buf { unsigned int size_points; cairo_path_op_t *op; - cairo_point_t *points; + cairo_point_double_t *points; } cairo_path_buf_t; typedef struct _cairo_path_buf_fixed { cairo_path_buf_t base; cairo_path_op_t op[CAIRO_PATH_BUF_SIZE]; - cairo_point_t points[2 * CAIRO_PATH_BUF_SIZE]; + cairo_point_double_t points[2 * CAIRO_PATH_BUF_SIZE]; } cairo_path_buf_fixed_t; /* @@ -85,8 +85,8 @@ typedef struct _cairo_path_buf_fixed { fill_maybe_region => fill_is_rectilinear */ struct _cairo_path_fixed { - cairo_point_t last_move_point; - cairo_point_t current_point; + cairo_point_double_t last_move_point; + cairo_point_double_t current_point; unsigned int has_current_point : 1; unsigned int needs_move_to : 1; unsigned int has_extents : 1; diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index 3093f2604..94205cc7c 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -44,10 +44,10 @@ #include "cairo-slope-private.h" static cairo_status_t -_cairo_path_fixed_add (cairo_path_fixed_t *path, - cairo_path_op_t op, - const cairo_point_t *points, - int num_points); +_cairo_path_fixed_add (cairo_path_fixed_t *path, + cairo_path_op_t op, + const cairo_point_double_t *points, + int num_points); static void _cairo_path_fixed_add_buf (cairo_path_fixed_t *path, @@ -64,9 +64,9 @@ _cairo_path_buf_add_op (cairo_path_buf_t *buf, cairo_path_op_t op); static void -_cairo_path_buf_add_points (cairo_path_buf_t *buf, - const cairo_point_t *points, - int num_points); +_cairo_path_buf_add_points (cairo_path_buf_t *buf, + const cairo_point_double_t *points, + int num_points); #define cairo_path_head(path__) (&(path__)->buf.base) #define cairo_path_tail(path__) cairo_path_buf_prev (cairo_path_head (path__)) @@ -232,7 +232,7 @@ _cairo_path_fixed_equal (const cairo_path_fixed_t *a, { const cairo_path_buf_t *buf_a, *buf_b; const cairo_path_op_t *ops_a, *ops_b; - const cairo_point_t *points_a, *points_b; + const cairo_point_double_t *points_a, *points_b; int num_points_a, num_ops_a; int num_points_b, num_ops_b; @@ -289,7 +289,7 @@ _cairo_path_fixed_equal (const cairo_path_fixed_t *a, if (memcmp (ops_a, ops_b, num_ops * sizeof (cairo_path_op_t))) return FALSE; - if (memcmp (points_a, points_b, num_points * sizeof (cairo_point_t))) + if (memcmp (points_a, points_b, num_points * sizeof (cairo_point_double_t))) return FALSE; num_ops_a -= num_ops; @@ -380,7 +380,7 @@ _cairo_path_fixed_last_op (cairo_path_fixed_t *path) return buf->op[buf->num_ops - 1]; } -static inline const cairo_point_t * +static inline const cairo_point_double_t * _cairo_path_fixed_penultimate_point (cairo_path_fixed_t *path) { cairo_path_buf_t *buf; @@ -410,8 +410,8 @@ _cairo_path_fixed_drop_line_to (cairo_path_fixed_t *path) cairo_status_t _cairo_path_fixed_move_to (cairo_path_fixed_t *path, - cairo_fixed_t x, - cairo_fixed_t y) + double x, + double y) { _cairo_path_fixed_new_sub_path (path); @@ -466,8 +466,8 @@ _cairo_path_fixed_new_sub_path (cairo_path_fixed_t *path) cairo_status_t _cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path, - cairo_fixed_t dx, - cairo_fixed_t dy) + double dx, + double dy) { if (unlikely (! path->has_current_point)) return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT); @@ -480,11 +480,11 @@ _cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path, cairo_status_t _cairo_path_fixed_line_to (cairo_path_fixed_t *path, - cairo_fixed_t x, - cairo_fixed_t y) + double x, + double y) { cairo_status_t status; - cairo_point_t point; + cairo_point_double_t point; point.x = x; point.y = y; @@ -515,7 +515,7 @@ _cairo_path_fixed_line_to (cairo_path_fixed_t *path, * then just change its end-point rather than adding a new op. */ if (_cairo_path_fixed_last_op (path) == CAIRO_PATH_OP_LINE_TO) { - const cairo_point_t *p; + const cairo_point_double_t *p; p = _cairo_path_fixed_penultimate_point (path); if (p->x == path->current_point.x && p->y == path->current_point.y) { @@ -564,8 +564,8 @@ _cairo_path_fixed_line_to (cairo_path_fixed_t *path, cairo_status_t _cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path, - cairo_fixed_t dx, - cairo_fixed_t dy) + double dx, + double dy) { if (unlikely (! path->has_current_point)) return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT); @@ -577,12 +577,12 @@ _cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path, cairo_status_t _cairo_path_fixed_curve_to (cairo_path_fixed_t *path, - cairo_fixed_t x0, cairo_fixed_t y0, - cairo_fixed_t x1, cairo_fixed_t y1, - cairo_fixed_t x2, cairo_fixed_t y2) + double x0, double y0, + double x1, double y1, + double x2, double y2) { cairo_status_t status; - cairo_point_t point[3]; + cairo_point_double_t point[3]; /* make sure subpaths are started properly */ if (! path->has_current_point) { @@ -596,7 +596,7 @@ _cairo_path_fixed_curve_to (cairo_path_fixed_t *path, /* If the previous op was a degenerate LINE_TO, drop it. */ if (_cairo_path_fixed_last_op (path) == CAIRO_PATH_OP_LINE_TO) { - const cairo_point_t *p; + const cairo_point_double_t *p; p = _cairo_path_fixed_penultimate_point (path); if (p->x == path->current_point.x && p->y == path->current_point.y) { @@ -624,9 +624,9 @@ _cairo_path_fixed_curve_to (cairo_path_fixed_t *path, cairo_status_t _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path, - cairo_fixed_t dx0, cairo_fixed_t dy0, - cairo_fixed_t dx1, cairo_fixed_t dy1, - cairo_fixed_t dx2, cairo_fixed_t dy2) + double dx0, double dy0, + double dx1, double dy1, + double dx2, double dy2) { if (unlikely (! path->has_current_point)) return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT); @@ -676,8 +676,8 @@ _cairo_path_fixed_close_path (cairo_path_fixed_t *path) cairo_bool_t _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path, - cairo_fixed_t *x, - cairo_fixed_t *y) + double *x, + double *y) { if (! path->has_current_point) return FALSE; @@ -689,10 +689,10 @@ _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path, } static cairo_status_t -_cairo_path_fixed_add (cairo_path_fixed_t *path, - cairo_path_op_t op, - const cairo_point_t *points, - int num_points) +_cairo_path_fixed_add (cairo_path_fixed_t *path, + cairo_path_op_t op, + const cairo_point_double_t *points, + int num_points) { cairo_path_buf_t *buf = cairo_path_tail (path); @@ -722,8 +722,7 @@ _cairo_path_fixed_add (cairo_path_fixed_t *path, if (i != 0) len += snprintf (buf + len, sizeof (buf), " "); len += snprintf (buf + len, sizeof (buf), "(%f, %f)", - _cairo_fixed_to_double (points[i].x), - _cairo_fixed_to_double (points[i].y)); + points[i].x, points[i].y); } len += snprintf (buf + len, sizeof (buf), "]"); @@ -764,7 +763,7 @@ _cairo_path_buf_create (int size_ops, int size_points) /* adjust size_ops to ensure that buf->points is naturally aligned */ size_ops += sizeof (double) - ((sizeof (cairo_path_buf_t) + size_ops) % sizeof (double)); - buf = _cairo_malloc_ab_plus_c (size_points, sizeof (cairo_point_t), size_ops + sizeof (cairo_path_buf_t)); + buf = _cairo_malloc_ab_plus_c (size_points, sizeof (cairo_point_double_t), size_ops + sizeof (cairo_path_buf_t)); if (buf) { buf->num_ops = 0; buf->num_points = 0; @@ -772,7 +771,7 @@ _cairo_path_buf_create (int size_ops, int size_points) buf->size_points = size_points; buf->op = (cairo_path_op_t *) (buf + 1); - buf->points = (cairo_point_t *) (buf->op + size_ops); + buf->points = (cairo_point_double_t *) (buf->op + size_ops); } return buf; @@ -792,9 +791,9 @@ _cairo_path_buf_add_op (cairo_path_buf_t *buf, } static void -_cairo_path_buf_add_points (cairo_path_buf_t *buf, - const cairo_point_t *points, - int num_points) +_cairo_path_buf_add_points (cairo_path_buf_t *buf, + const cairo_point_double_t *points, + int num_points) { memcpy (buf->points + buf->num_points, points, @@ -824,7 +823,7 @@ _cairo_path_fixed_interpret (const cairo_path_fixed_t *path, buf = first = forward ? cairo_path_head (path) : cairo_path_tail (path); do { - cairo_point_t *points; + cairo_point_double_t *points; int start, stop, i; if (forward) { @@ -871,13 +870,13 @@ _cairo_path_fixed_interpret (const cairo_path_fixed_t *path, } typedef struct _cairo_path_fixed_append_closure { - cairo_point_t offset; + cairo_point_double_t offset; cairo_path_fixed_t *path; } cairo_path_fixed_append_closure_t; static cairo_status_t -_append_move_to (void *abstract_closure, - const cairo_point_t *point) +_append_move_to (void *abstract_closure, + const cairo_point_double_t *point) { cairo_path_fixed_append_closure_t *closure = abstract_closure; @@ -887,8 +886,8 @@ _append_move_to (void *abstract_closure, } static cairo_status_t -_append_line_to (void *abstract_closure, - const cairo_point_t *point) +_append_line_to (void *abstract_closure, + const cairo_point_double_t *point) { cairo_path_fixed_append_closure_t *closure = abstract_closure; @@ -898,10 +897,10 @@ _append_line_to (void *abstract_closure, } static cairo_status_t -_append_curve_to (void *abstract_closure, - const cairo_point_t *p0, - const cairo_point_t *p1, - const cairo_point_t *p2) +_append_curve_to (void *abstract_closure, + const cairo_point_double_t *p0, + const cairo_point_double_t *p1, + const cairo_point_double_t *p2) { cairo_path_fixed_append_closure_t *closure = abstract_closure; @@ -926,8 +925,8 @@ cairo_status_t _cairo_path_fixed_append (cairo_path_fixed_t *path, const cairo_path_fixed_t *other, cairo_direction_t dir, - cairo_fixed_t tx, - cairo_fixed_t ty) + double tx, + double ty) { cairo_path_fixed_append_closure_t closure; @@ -945,10 +944,10 @@ _cairo_path_fixed_append (cairo_path_fixed_t *path, static void _cairo_path_fixed_offset_and_scale (cairo_path_fixed_t *path, - cairo_fixed_t offx, - cairo_fixed_t offy, - cairo_fixed_t scalex, - cairo_fixed_t scaley) + double offx, + double offy, + double scalex, + double scaley) { cairo_path_buf_t *buf; unsigned int i; @@ -992,8 +991,8 @@ _cairo_path_fixed_offset_and_scale (cairo_path_fixed_t *path, void _cairo_path_fixed_translate (cairo_path_fixed_t *path, - cairo_fixed_t offx, - cairo_fixed_t offy) + double offx, + double offy) { cairo_path_buf_t *buf; unsigned int i; @@ -1028,20 +1027,6 @@ _cairo_path_fixed_translate (cairo_path_fixed_t *path, path->extents.p2.y += offy; } - -static inline void -_cairo_path_fixed_transform_point (cairo_point_t *p, - const cairo_matrix_t *matrix) -{ - double dx, dy; - - dx = _cairo_fixed_to_double (p->x); - dy = _cairo_fixed_to_double (p->y); - cairo_matrix_transform_point (matrix, &dx, &dy); - p->x = _cairo_fixed_from_double (dx); - p->y = _cairo_fixed_from_double (dy); -} - /** * _cairo_path_fixed_transform: * @path: a #cairo_path_fixed_t to be transformed @@ -1056,22 +1041,25 @@ _cairo_path_fixed_transform (cairo_path_fixed_t *path, const cairo_matrix_t *matrix) { cairo_box_t extents; - cairo_point_t point; + cairo_point_double_t point; cairo_path_buf_t *buf; unsigned int i; if (matrix->yx == 0.0 && matrix->xy == 0.0) { /* Fast path for the common case of scale+transform */ _cairo_path_fixed_offset_and_scale (path, - _cairo_fixed_from_double (matrix->x0), - _cairo_fixed_from_double (matrix->y0), - _cairo_fixed_from_double (matrix->xx), - _cairo_fixed_from_double (matrix->yy)); + matrix->x0, matrix->y0, + matrix->xx, matrix->yy); return; } - _cairo_path_fixed_transform_point (&path->last_move_point, matrix); - _cairo_path_fixed_transform_point (&path->current_point, matrix); + cairo_matrix_transform_point (matrix, + &path->last_move_point.x, + &path->last_move_point.y); + + cairo_matrix_transform_point (matrix, + &path->current_point.x, + &path->current_point.y); buf = cairo_path_head (path); if (buf->num_points == 0) @@ -1079,12 +1067,12 @@ _cairo_path_fixed_transform (cairo_path_fixed_t *path, extents = path->extents; point = buf->points[0]; - _cairo_path_fixed_transform_point (&point, matrix); + cairo_matrix_transform_point (&point, &point.x, &point.y); _cairo_box_set (&path->extents, &point, &point); cairo_path_foreach_buf_start (buf, path) { for (i = 0; i < buf->num_points; i++) { - _cairo_path_fixed_transform_point (&buf->points[i], matrix); + cairo_matrix_transform_point (matrix, &buf->points[i].x, &buf->points[i].y); _cairo_box_add_point (&path->extents, &buf->points[i]); } } cairo_path_foreach_buf_end (buf, path); @@ -1112,7 +1100,7 @@ _cairo_path_fixed_transform (cairo_path_fixed_t *path, /* Closure for path flattening */ typedef struct cairo_path_flattener { double tolerance; - cairo_point_t current_point; + cairo_point_double_t current_point; cairo_path_fixed_move_to_func_t *move_to; cairo_path_fixed_line_to_func_t *line_to; cairo_path_fixed_close_path_func_t *close_path; @@ -1121,7 +1109,7 @@ typedef struct cairo_path_flattener { static cairo_status_t _cpf_move_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cpf_t *cpf = closure; @@ -1132,7 +1120,7 @@ _cpf_move_to (void *closure, static cairo_status_t _cpf_line_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cpf_t *cpf = closure; @@ -1142,15 +1130,15 @@ _cpf_line_to (void *closure, } static cairo_status_t -_cpf_curve_to (void *closure, - const cairo_point_t *p1, - const cairo_point_t *p2, - const cairo_point_t *p3) +_cpf_curve_to (void *closure, + const cairo_point_double_t *p1, + const cairo_point_double_t *p2, + const cairo_point_double_t *p3) { cpf_t *cpf = closure; cairo_spline_t spline; - cairo_point_t *p0 = &cpf->current_point; + cairo_point_double_t *p0 = &cpf->current_point; if (! _cairo_spline_init (&spline, cpf->line_to, @@ -1208,8 +1196,8 @@ _cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path, static inline void _canonical_box (cairo_box_t *box, - const cairo_point_t *p1, - const cairo_point_t *p2) + const cairo_point_double_t *p1, + const cairo_point_double_t *p2) { if (p1->x <= p2->x) { box->p1.x = p1->x; @@ -1353,7 +1341,7 @@ cairo_bool_t _cairo_path_fixed_iter_is_fill_box (cairo_path_fixed_iter_t *_iter, cairo_box_t *box) { - cairo_point_t points[5]; + cairo_point_double_t points[5]; cairo_path_fixed_iter_t iter; if (_iter->buf == NULL) diff --git a/src/cairo-path.c b/src/cairo-path.c index 88a730b39..ec8b51691 100644 --- a/src/cairo-path.c +++ b/src/cairo-path.c @@ -59,7 +59,7 @@ typedef struct cairo_path_count { static cairo_status_t _cpc_move_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cpc_t *cpc = closure; @@ -70,7 +70,7 @@ _cpc_move_to (void *closure, static cairo_status_t _cpc_line_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cpc_t *cpc = closure; @@ -81,9 +81,9 @@ _cpc_line_to (void *closure, static cairo_status_t _cpc_curve_to (void *closure, - const cairo_point_t *p1, - const cairo_point_t *p2, - const cairo_point_t *p3) + const cairo_point_double_t *p1, + const cairo_point_double_t *p2, + const cairo_point_double_t *p3) { cpc_t *cpc = closure; @@ -145,7 +145,7 @@ typedef struct cairo_path_populate { static cairo_status_t _cpp_move_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cpp_t *cpp = closure; cairo_path_data_t *data = cpp->data; @@ -170,7 +170,7 @@ _cpp_move_to (void *closure, static cairo_status_t _cpp_line_to (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { cpp_t *cpp = closure; cairo_path_data_t *data = cpp->data; @@ -195,9 +195,9 @@ _cpp_line_to (void *closure, static cairo_status_t _cpp_curve_to (void *closure, - const cairo_point_t *p1, - const cairo_point_t *p2, - const cairo_point_t *p3) + const cairo_point_double_t *p1, + const cairo_point_double_t *p2, + const cairo_point_double_t *p3) { cpp_t *cpp = closure; cairo_path_data_t *data = cpp->data; diff --git a/src/cairo-rectangle.c b/src/cairo-rectangle.c index 3a541eba4..71a16a846 100644 --- a/src/cairo-rectangle.c +++ b/src/cairo-rectangle.c @@ -265,7 +265,7 @@ _cairo_box_intersects_line_segment (cairo_box_t *box, cairo_line_t *line) static cairo_status_t _cairo_box_add_spline_point (void *closure, - const cairo_point_t *point) + const cairo_point_double_t *point) { _cairo_box_add_point (closure, point); @@ -274,11 +274,11 @@ _cairo_box_add_spline_point (void *closure, /* assumes a has been previously added */ void -_cairo_box_add_curve_to (cairo_box_t *extents, - const cairo_point_t *a, - const cairo_point_t *b, - const cairo_point_t *c, - const cairo_point_t *d) +_cairo_box_add_curve_to (cairo_box_double_t *extents, + const cairo_point_double_t *a, + const cairo_point_double_t *b, + const cairo_point_double_t *c, + const cairo_point_double_t *d) { _cairo_box_add_point (extents, d); if (!_cairo_box_contains_point (extents, b) || diff --git a/src/cairo-spline.c b/src/cairo-spline.c index 016eceed8..82bee7329 100644 --- a/src/cairo-spline.c +++ b/src/cairo-spline.c @@ -220,8 +220,8 @@ _cairo_spline_decompose (cairo_spline_t *spline, double tolerance) cairo_status_t _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func, void *closure, - const cairo_point_t *p0, const cairo_point_t *p1, - const cairo_point_t *p2, const cairo_point_t *p3) + const cairo_point_double_t *p0, const cairo_point_double_t *p1, + const cairo_point_double_t *p2, const cairo_point_double_t *p3) { double x0, x1, x2, x3; double y0, y1, y2, y3; @@ -230,14 +230,14 @@ _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func, int t_num = 0, i; cairo_status_t status; - x0 = _cairo_fixed_to_double (p0->x); - y0 = _cairo_fixed_to_double (p0->y); - x1 = _cairo_fixed_to_double (p1->x); - y1 = _cairo_fixed_to_double (p1->y); - x2 = _cairo_fixed_to_double (p2->x); - y2 = _cairo_fixed_to_double (p2->y); - x3 = _cairo_fixed_to_double (p3->x); - y3 = _cairo_fixed_to_double (p3->y); + x0 = p0->x; + y0 = p0->y; + x1 = p1->x; + y1 = p1->y; + x2 = p2->x; + y2 = p2->y; + x3 = p3->x; + y3 = p3->y; /* The spline can be written as a polynomial of the four points: * diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h index 93b035d7c..9222e3d0f 100644 --- a/src/cairo-types-private.h +++ b/src/cairo-types-private.h @@ -259,6 +259,11 @@ typedef struct _cairo_distance_double { double dy; } cairo_distance_double_t; +typedef struct _cairo_box_double { + cairo_point_double_t p1; + cairo_point_double_t p2; +} cairo_box_double_t; + typedef struct _cairo_line { cairo_point_t p1; cairo_point_t p2; diff --git a/src/cairo.c b/src/cairo.c index 562161099..117bd52d9 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -1669,16 +1669,13 @@ void cairo_move_to (cairo_t *cr, double x, double y) { cairo_status_t status; - cairo_fixed_t x_fixed, y_fixed; if (unlikely (cr->status)) return; _cairo_gstate_user_to_backend (cr->gstate, &x, &y); - x_fixed = _cairo_fixed_from_double (x); - y_fixed = _cairo_fixed_from_double (y); - status = _cairo_path_fixed_move_to (cr->path, x_fixed, y_fixed); + status = _cairo_path_fixed_move_to (cr->path, x, y); if (unlikely (status)) _cairo_set_error (cr, status); } @@ -1728,16 +1725,13 @@ void cairo_line_to (cairo_t *cr, double x, double y) { cairo_status_t status; - cairo_fixed_t x_fixed, y_fixed; if (unlikely (cr->status)) return; _cairo_gstate_user_to_backend (cr->gstate, &x, &y); - x_fixed = _cairo_fixed_from_double (x); - y_fixed = _cairo_fixed_from_double (y); - status = _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed); + status = _cairo_path_fixed_line_to (cr->path, x, y); if (unlikely (status)) _cairo_set_error (cr, status); } @@ -1769,9 +1763,6 @@ cairo_curve_to (cairo_t *cr, double x3, double y3) { cairo_status_t status; - cairo_fixed_t x1_fixed, y1_fixed; - cairo_fixed_t x2_fixed, y2_fixed; - cairo_fixed_t x3_fixed, y3_fixed; if (unlikely (cr->status)) return; @@ -1780,19 +1771,10 @@ cairo_curve_to (cairo_t *cr, _cairo_gstate_user_to_backend (cr->gstate, &x2, &y2); _cairo_gstate_user_to_backend (cr->gstate, &x3, &y3); - x1_fixed = _cairo_fixed_from_double (x1); - y1_fixed = _cairo_fixed_from_double (y1); - - x2_fixed = _cairo_fixed_from_double (x2); - y2_fixed = _cairo_fixed_from_double (y2); - - x3_fixed = _cairo_fixed_from_double (x3); - y3_fixed = _cairo_fixed_from_double (y3); - status = _cairo_path_fixed_curve_to (cr->path, - x1_fixed, y1_fixed, - x2_fixed, y2_fixed, - x3_fixed, y3_fixed); + x1, y1, + x2, y2, + x3, y3); if (unlikely (status)) _cairo_set_error (cr, status); } @@ -1954,7 +1936,6 @@ cairo_arc_to (cairo_t *cr, void cairo_rel_move_to (cairo_t *cr, double dx, double dy) { - cairo_fixed_t dx_fixed, dy_fixed; cairo_status_t status; if (unlikely (cr->status)) @@ -1962,10 +1943,7 @@ cairo_rel_move_to (cairo_t *cr, double dx, double dy) _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy); - dx_fixed = _cairo_fixed_from_double (dx); - dy_fixed = _cairo_fixed_from_double (dy); - - status = _cairo_path_fixed_rel_move_to (cr->path, dx_fixed, dy_fixed); + status = _cairo_path_fixed_rel_move_to (cr->path, dx, dy); if (unlikely (status)) _cairo_set_error (cr, status); } @@ -1991,7 +1969,6 @@ cairo_rel_move_to (cairo_t *cr, double dx, double dy) void cairo_rel_line_to (cairo_t *cr, double dx, double dy) { - cairo_fixed_t dx_fixed, dy_fixed; cairo_status_t status; if (unlikely (cr->status)) @@ -1999,10 +1976,7 @@ cairo_rel_line_to (cairo_t *cr, double dx, double dy) _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy); - dx_fixed = _cairo_fixed_from_double (dx); - dy_fixed = _cairo_fixed_from_double (dy); - - status = _cairo_path_fixed_rel_line_to (cr->path, dx_fixed, dy_fixed); + status = _cairo_path_fixed_rel_line_to (cr->path, dx, dy); if (unlikely (status)) _cairo_set_error (cr, status); } @@ -2039,9 +2013,6 @@ cairo_rel_curve_to (cairo_t *cr, double dx2, double dy2, double dx3, double dy3) { - cairo_fixed_t dx1_fixed, dy1_fixed; - cairo_fixed_t dx2_fixed, dy2_fixed; - cairo_fixed_t dx3_fixed, dy3_fixed; cairo_status_t status; if (unlikely (cr->status)) @@ -2051,19 +2022,10 @@ cairo_rel_curve_to (cairo_t *cr, _cairo_gstate_user_to_device_distance (cr->gstate, &dx2, &dy2); _cairo_gstate_user_to_device_distance (cr->gstate, &dx3, &dy3); - dx1_fixed = _cairo_fixed_from_double (dx1); - dy1_fixed = _cairo_fixed_from_double (dy1); - - dx2_fixed = _cairo_fixed_from_double (dx2); - dy2_fixed = _cairo_fixed_from_double (dy2); - - dx3_fixed = _cairo_fixed_from_double (dx3); - dy3_fixed = _cairo_fixed_from_double (dy3); - status = _cairo_path_fixed_rel_curve_to (cr->path, - dx1_fixed, dy1_fixed, - dx2_fixed, dy2_fixed, - dx3_fixed, dy3_fixed); + dx1, dy1, + dx2, dy2, + dx3, dy3); if (unlikely (status)) _cairo_set_error (cr, status); } @@ -3850,14 +3812,11 @@ cairo_has_current_point (cairo_t *cr) void cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret) { - cairo_fixed_t x_fixed, y_fixed; double x, y; if (cr->status == CAIRO_STATUS_SUCCESS && - _cairo_path_fixed_get_current_point (cr->path, &x_fixed, &y_fixed)) + _cairo_path_fixed_get_current_point (cr->path, &x, &y)) { - x = _cairo_fixed_to_double (x_fixed); - y = _cairo_fixed_to_double (y_fixed); _cairo_gstate_backend_to_user (cr->gstate, &x, &y); } else diff --git a/src/cairoint.h b/src/cairoint.h index 539d92ea5..a9584f1b1 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -263,11 +263,11 @@ _cairo_box_round_to_rectangle (const cairo_box_t *box, cairo_rectangle_int_t *rectangle); cairo_private void -_cairo_box_add_curve_to (cairo_box_t *extents, - const cairo_point_t *a, - const cairo_point_t *b, - const cairo_point_t *c, - const cairo_point_t *d); +_cairo_box_add_curve_to (cairo_box_double_t *extents, + const cairo_point_double_t *a, + const cairo_point_double_t *b, + const cairo_point_double_t *c, + const cairo_point_double_t *d); cairo_private void _cairo_boxes_get_extents (const cairo_box_t *boxes, @@ -1145,60 +1145,60 @@ _cairo_path_fixed_destroy (cairo_path_fixed_t *path); cairo_private cairo_status_t _cairo_path_fixed_move_to (cairo_path_fixed_t *path, - cairo_fixed_t x, - cairo_fixed_t y); + double x, + double y); cairo_private void _cairo_path_fixed_new_sub_path (cairo_path_fixed_t *path); cairo_private cairo_status_t _cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path, - cairo_fixed_t dx, - cairo_fixed_t dy); + double dx, + double dy); cairo_private cairo_status_t _cairo_path_fixed_line_to (cairo_path_fixed_t *path, - cairo_fixed_t x, - cairo_fixed_t y); + double x, + double y); cairo_private cairo_status_t _cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path, - cairo_fixed_t dx, - cairo_fixed_t dy); + double dx, + double dy); cairo_private cairo_status_t _cairo_path_fixed_curve_to (cairo_path_fixed_t *path, - cairo_fixed_t x0, cairo_fixed_t y0, - cairo_fixed_t x1, cairo_fixed_t y1, - cairo_fixed_t x2, cairo_fixed_t y2); + double x0, double y0, + double x1, double y1, + double x2, double y2); cairo_private cairo_status_t _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path, - cairo_fixed_t dx0, cairo_fixed_t dy0, - cairo_fixed_t dx1, cairo_fixed_t dy1, - cairo_fixed_t dx2, cairo_fixed_t dy2); + double dx0, double dy0, + double dx1, double dy1, + double dx2, double dy2); cairo_private cairo_status_t _cairo_path_fixed_close_path (cairo_path_fixed_t *path); cairo_private cairo_bool_t _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path, - cairo_fixed_t *x, - cairo_fixed_t *y); + double *x, + double *y); typedef cairo_status_t (cairo_path_fixed_move_to_func_t) (void *closure, - const cairo_point_t *point); + const cairo_point_double_t *point); typedef cairo_status_t (cairo_path_fixed_line_to_func_t) (void *closure, - const cairo_point_t *point); + const cairo_point_double_t *point); typedef cairo_status_t (cairo_path_fixed_curve_to_func_t) (void *closure, - const cairo_point_t *p0, - const cairo_point_t *p1, - const cairo_point_t *p2); + const cairo_point_double_t *p0, + const cairo_point_double_t *p1, + const cairo_point_double_t *p2); typedef cairo_status_t (cairo_path_fixed_close_path_func_t) (void *closure); @@ -1224,11 +1224,11 @@ _cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path, cairo_private cairo_bool_t _cairo_path_bounder_extents (const cairo_path_fixed_t *path, - cairo_box_t *box); + cairo_box_double_t *box); cairo_private cairo_bool_t _cairo_path_fixed_extents (const cairo_path_fixed_t *path, - cairo_box_t *box); + cairo_box_double_t *box); cairo_private void _cairo_path_fixed_approximate_clip_extents (const cairo_path_fixed_t *path, @@ -2055,8 +2055,8 @@ _cairo_spline_decompose (cairo_spline_t *spline, double tolerance); cairo_private cairo_status_t _cairo_spline_bound (cairo_spline_add_point_func_t add_point_func, void *closure, - const cairo_point_t *p0, const cairo_point_t *p1, - const cairo_point_t *p2, const cairo_point_t *p3); + const cairo_point_double_t *p0, const cairo_point_double_t *p1, + const cairo_point_double_t *p2, const cairo_point_double_t *p3); /* cairo-matrix.c */ cairo_private void |