diff --git a/gfx/cairo/cairo/src/cairo.c b/gfx/cairo/cairo/src/cairo.c index b9a62c335a8..21303debd05 100644 --- a/gfx/cairo/cairo/src/cairo.c +++ b/gfx/cairo/cairo/src/cairo.c @@ -44,7 +44,7 @@ #define CAIRO_TOLERANCE_MINIMUM 0.0002 /* We're limited by 16 bits of sub-pixel precision */ -static const cairo_t _cairo_nil = { +static const cairo_t cairo_nil = { CAIRO_REF_COUNT_INVALID, /* ref_count */ CAIRO_STATUS_NO_MEMORY, /* status */ { 0, 0, 0, NULL }, /* user_data */ @@ -89,9 +89,6 @@ _cairo_error (cairo_status_t status) { assert (status > CAIRO_STATUS_SUCCESS && status <= CAIRO_STATUS_LAST_STATUS); - - /* let's force a crash */ - *(int*)0 = 4; } /** @@ -192,28 +189,25 @@ cairo_t * cairo_create (cairo_surface_t *target) { cairo_t *cr; - cairo_status_t status; - - /* special case OOM in order to avoid another allocation */ - if (target && target->status == CAIRO_STATUS_NO_MEMORY) - return (cairo_t *) &_cairo_nil; cr = malloc (sizeof (cairo_t)); if (cr == NULL) - return (cairo_t *) &_cairo_nil; + return (cairo_t *) &cairo_nil; cr->ref_count = 1; cr->status = CAIRO_STATUS_SUCCESS; _cairo_user_data_array_init (&cr->user_data); - _cairo_path_fixed_init (cr->path); cr->gstate = cr->gstate_tail; - status = _cairo_gstate_init (cr->gstate, target); + _cairo_gstate_init (cr->gstate, target); - if (status) - _cairo_set_error (cr, status); + _cairo_path_fixed_init (cr->path); + + if (target == NULL) { + _cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER); + } return cr; } @@ -266,8 +260,10 @@ cairo_destroy (cairo_t *cr) return; while (cr->gstate != cr->gstate_tail) { - if (_cairo_gstate_restore (&cr->gstate)) - break; + cairo_gstate_t *tmp = cr->gstate; + cr->gstate = tmp->next; + + _cairo_gstate_destroy (tmp); } _cairo_gstate_fini (cr->gstate); @@ -372,15 +368,20 @@ cairo_get_reference_count (cairo_t *cr) void cairo_save (cairo_t *cr) { - cairo_status_t status; + cairo_gstate_t *top; if (cr->status) return; - status = _cairo_gstate_save (&cr->gstate); - if (status) { - _cairo_set_error (cr, status); + top = _cairo_gstate_clone (cr->gstate); + + if (top == NULL) { + _cairo_set_error (cr, CAIRO_STATUS_NO_MEMORY); + return; } + + top->next = cr->gstate; + cr->gstate = top; } slim_hidden_def(cairo_save); @@ -395,15 +396,20 @@ slim_hidden_def(cairo_save); void cairo_restore (cairo_t *cr) { - cairo_status_t status; + cairo_gstate_t *top; if (cr->status) return; - status = _cairo_gstate_restore (&cr->gstate); - if (status) { - _cairo_set_error (cr, status); + if (cr->gstate == cr->gstate_tail) { + _cairo_set_error (cr, CAIRO_STATUS_INVALID_RESTORE); + return; } + + top = cr->gstate; + cr->gstate = top->next; + + _cairo_gstate_destroy (top); } slim_hidden_def(cairo_restore); @@ -482,18 +488,12 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) { cairo_status_t status; cairo_rectangle_int16_t extents; - cairo_surface_t *parent_surface, *group_surface = NULL; + cairo_surface_t *group_surface = NULL; - if (cr->status) - return; - - parent_surface = _cairo_gstate_get_target (cr->gstate); /* Get the extents that we'll use in creating our new group surface */ - status = _cairo_surface_get_extents (parent_surface, &extents); - if (status) - goto bail; + _cairo_surface_get_extents (_cairo_gstate_get_target (cr->gstate), &extents); status = _cairo_clip_intersect_to_rectangle (_cairo_gstate_get_clip (cr->gstate), &extents); - if (status) + if (status != CAIRO_STATUS_SUCCESS) goto bail; group_surface = cairo_surface_create_similar (_cairo_gstate_get_target (cr->gstate), @@ -510,15 +510,15 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) * device offsets, so we want to set our own surface offsets from /that/, * and not from the device origin. */ cairo_surface_set_device_offset (group_surface, - parent_surface->device_transform.x0 - extents.x, - parent_surface->device_transform.y0 - extents.y); + cr->gstate->target->device_transform.x0 - extents.x, + cr->gstate->target->device_transform.y0 - extents.y); /* create a new gstate for the redirect */ cairo_save (cr); if (cr->status) goto bail; - status = _cairo_gstate_redirect_target (cr->gstate, group_surface); + _cairo_gstate_redirect_target (cr->gstate, group_surface); bail: cairo_surface_destroy (group_surface); @@ -555,9 +555,6 @@ cairo_pop_group (cairo_t *cr) cairo_pattern_t *group_pattern = NULL; cairo_matrix_t group_matrix; - if (cr->status) - return (cairo_pattern_t*) &_cairo_pattern_nil.base; - /* Grab the active surfaces */ group_surface = _cairo_gstate_get_target (cr->gstate); parent_target = _cairo_gstate_get_parent_target (cr->gstate); @@ -565,13 +562,13 @@ cairo_pop_group (cairo_t *cr) /* Verify that we are at the right nesting level */ if (parent_target == NULL) { _cairo_set_error (cr, CAIRO_STATUS_INVALID_POP_GROUP); - return (cairo_pattern_t*) &_cairo_pattern_nil.base; + return NULL; } /* We need to save group_surface before we restore; we don't need * to reference parent_target and original_target, since the * gstate will still hold refs to them once we restore. */ - group_surface = cairo_surface_reference (group_surface); + cairo_surface_reference (group_surface); cairo_restore (cr); @@ -579,8 +576,8 @@ cairo_pop_group (cairo_t *cr) goto done; group_pattern = cairo_pattern_create_for_surface (group_surface); - if (cairo_pattern_status (group_pattern)) { - _cairo_set_error (cr, cairo_pattern_status (group_pattern)); + if (!group_pattern) { + cr->status = CAIRO_STATUS_NO_MEMORY; goto done; } @@ -626,6 +623,9 @@ cairo_pop_group_to_source (cairo_t *cr) cairo_pattern_t *group_pattern; group_pattern = cairo_pop_group (cr); + if (!group_pattern) + return; + cairo_set_source (cr, group_pattern); cairo_pattern_destroy (group_pattern); } @@ -647,14 +647,12 @@ slim_hidden_def(cairo_pop_group_to_source); void cairo_set_operator (cairo_t *cr, cairo_operator_t op) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_operator (cr->gstate, op); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_operator (cr->gstate, op); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def (cairo_set_operator); @@ -681,9 +679,6 @@ cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue) if (cr->status) return; - /* push the current pattern to the freed lists */ - cairo_set_source (cr, (cairo_pattern_t *) &cairo_pattern_none); - pattern = cairo_pattern_create_rgb (red, green, blue); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); @@ -715,9 +710,6 @@ cairo_set_source_rgba (cairo_t *cr, if (cr->status) return; - /* push the current pattern to the freed lists */ - cairo_set_source (cr, (cairo_pattern_t *) &cairo_pattern_none); - pattern = cairo_pattern_create_rgba (red, green, blue, alpha); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); @@ -758,9 +750,6 @@ cairo_set_source_surface (cairo_t *cr, if (cr->status) return; - /* push the current pattern to the freed lists */ - cairo_set_source (cr, (cairo_pattern_t *) &cairo_pattern_none); - pattern = cairo_pattern_create_for_surface (surface); cairo_matrix_init_translate (&matrix, -x, -y); @@ -793,8 +782,6 @@ slim_hidden_def (cairo_set_source_surface); void cairo_set_source (cairo_t *cr, cairo_pattern_t *source) { - cairo_status_t status; - if (cr->status) return; @@ -808,9 +795,9 @@ cairo_set_source (cairo_t *cr, cairo_pattern_t *source) return; } - status = _cairo_gstate_set_source (cr->gstate, source); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_source (cr->gstate, source); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def (cairo_set_source); @@ -828,7 +815,7 @@ cairo_pattern_t * cairo_get_source (cairo_t *cr) { if (cr->status) - return (cairo_pattern_t*) &_cairo_pattern_nil.base; + return (cairo_pattern_t*) &cairo_pattern_nil.base; return _cairo_gstate_get_source (cr->gstate); } @@ -849,16 +836,14 @@ cairo_get_source (cairo_t *cr) void cairo_set_tolerance (cairo_t *cr, double tolerance) { - cairo_status_t status; - if (cr->status) return; _cairo_restrict_value (&tolerance, CAIRO_TOLERANCE_MINIMUM, tolerance); - status = _cairo_gstate_set_tolerance (cr->gstate, tolerance); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_tolerance (cr->gstate, tolerance); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -877,14 +862,12 @@ cairo_set_tolerance (cairo_t *cr, double tolerance) void cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_antialias (cr->gstate, antialias); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_antialias (cr->gstate, antialias); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -895,20 +878,18 @@ cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias) * Set the current fill rule within the cairo context. The fill rule * is used to determine which regions are inside or outside a complex * (potentially self-intersecting) path. The current fill rule affects - * both cairo_fill() and cairo_clip(). See #cairo_fill_rule_t for details + * both cairo_fill and cairo_clip. See #cairo_fill_rule_t for details * on the semantics of each available fill rule. **/ void cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_fill_rule (cr->gstate, fill_rule); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_fill_rule (cr->gstate, fill_rule); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -940,16 +921,14 @@ cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule) void cairo_set_line_width (cairo_t *cr, double width) { - cairo_status_t status; - if (cr->status) return; _cairo_restrict_value (&width, 0.0, width); - status = _cairo_gstate_set_line_width (cr->gstate, width); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_line_width (cr->gstate, width); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -969,14 +948,12 @@ cairo_set_line_width (cairo_t *cr, double width) void cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_line_cap (cr->gstate, line_cap); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_line_cap (cr->gstate, line_cap); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -996,14 +973,12 @@ cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap) void cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_line_join (cr->gstate, line_join); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_line_join (cr->gstate, line_join); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1044,15 +1019,13 @@ cairo_set_dash (cairo_t *cr, int num_dashes, double offset) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_dash (cr->gstate, - dashes, num_dashes, offset); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_dash (cr->gstate, + dashes, num_dashes, offset); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1071,11 +1044,7 @@ cairo_set_dash (cairo_t *cr, int cairo_get_dash_count (cairo_t *cr) { - int num_dashes; - - _cairo_gstate_get_dash (cr->gstate, NULL, &num_dashes, NULL); - - return num_dashes; + return cr->gstate->stroke_style.num_dashes; } /** @@ -1095,7 +1064,13 @@ cairo_get_dash (cairo_t *cr, double *dashes, double *offset) { - _cairo_gstate_get_dash (cr->gstate, dashes, NULL, offset); + if (dashes) + memcpy (dashes, + cr->gstate->stroke_style.dash, + sizeof (double) * cr->gstate->stroke_style.num_dashes); + + if (offset) + *offset = cr->gstate->stroke_style.dash_offset; } /** @@ -1120,14 +1095,12 @@ cairo_get_dash (cairo_t *cr, void cairo_set_miter_limit (cairo_t *cr, double limit) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_miter_limit (cr->gstate, limit); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_miter_limit (cr->gstate, limit); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1145,14 +1118,12 @@ cairo_set_miter_limit (cairo_t *cr, double limit) void cairo_translate (cairo_t *cr, double tx, double ty) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_translate (cr->gstate, tx, ty); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_translate (cr->gstate, tx, ty); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1169,14 +1140,12 @@ cairo_translate (cairo_t *cr, double tx, double ty) void cairo_scale (cairo_t *cr, double sx, double sy) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_scale (cr->gstate, sx, sy); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_scale (cr->gstate, sx, sy); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def (cairo_scale); @@ -1195,14 +1164,12 @@ slim_hidden_def (cairo_scale); void cairo_rotate (cairo_t *cr, double angle) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_rotate (cr->gstate, angle); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_rotate (cr->gstate, angle); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1218,14 +1185,12 @@ void cairo_transform (cairo_t *cr, const cairo_matrix_t *matrix) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_transform (cr->gstate, matrix); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_transform (cr->gstate, matrix); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1240,14 +1205,12 @@ void cairo_set_matrix (cairo_t *cr, const cairo_matrix_t *matrix) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_matrix (cr->gstate, matrix); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_matrix (cr->gstate, matrix); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1265,7 +1228,9 @@ cairo_identity_matrix (cairo_t *cr) if (cr->status) return; - _cairo_gstate_identity_matrix (cr->gstate); + cr->status = _cairo_gstate_identity_matrix (cr->gstate); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1284,7 +1249,9 @@ cairo_user_to_device (cairo_t *cr, double *x, double *y) if (cr->status) return; - _cairo_gstate_user_to_device (cr->gstate, x, y); + cr->status = _cairo_gstate_user_to_device (cr->gstate, x, y); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1304,7 +1271,9 @@ cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy) if (cr->status) return; - _cairo_gstate_user_to_device_distance (cr->gstate, dx, dy); + cr->status = _cairo_gstate_user_to_device_distance (cr->gstate, dx, dy); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1323,7 +1292,9 @@ cairo_device_to_user (cairo_t *cr, double *x, double *y) if (cr->status) return; - _cairo_gstate_device_to_user (cr->gstate, x, y); + cr->status = _cairo_gstate_device_to_user (cr->gstate, x, y); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1343,7 +1314,9 @@ cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy) if (cr->status) return; - _cairo_gstate_device_to_user_distance (cr->gstate, dx, dy); + cr->status = _cairo_gstate_device_to_user_distance (cr->gstate, dx, dy); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1375,7 +1348,6 @@ slim_hidden_def(cairo_new_path); void cairo_move_to (cairo_t *cr, double x, double y) { - cairo_status_t status; cairo_fixed_t x_fixed, y_fixed; if (cr->status) @@ -1385,9 +1357,9 @@ cairo_move_to (cairo_t *cr, double x, double 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); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_fixed_move_to (cr->path, x_fixed, y_fixed); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def(cairo_move_to); @@ -1434,7 +1406,6 @@ cairo_new_sub_path (cairo_t *cr) void cairo_line_to (cairo_t *cr, double x, double y) { - cairo_status_t status; cairo_fixed_t x_fixed, y_fixed; if (cr->status) @@ -1444,9 +1415,9 @@ cairo_line_to (cairo_t *cr, double x, double 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); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def (cairo_line_to); @@ -1475,7 +1446,6 @@ cairo_curve_to (cairo_t *cr, double x2, double y2, 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; @@ -1496,12 +1466,12 @@ cairo_curve_to (cairo_t *cr, 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); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_fixed_curve_to (cr->path, + x1_fixed, y1_fixed, + x2_fixed, y2_fixed, + x3_fixed, y3_fixed); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def (cairo_curve_to); @@ -1546,7 +1516,7 @@ slim_hidden_def (cairo_curve_to); * * cairo_save (cr); * cairo_translate (cr, x + width / 2., y + height / 2.); - * cairo_scale (cr, width / 2., height / 2.); + * cairo_scale (cr, 1. / (height / 2.), 1. / (width / 2.)); * cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI); * cairo_restore (cr); * @@ -1588,7 +1558,7 @@ cairo_arc (cairo_t *cr, * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in * the direction of decreasing angles to end at @angle2. If @angle2 is * greater than @angle1 it will be progressively decreased by 2*M_PI - * until it is less than @angle1. + * until it is greater than @angle1. * * See cairo_arc() for more details. This function differs only in the * direction of the arc between the two angles. @@ -1624,17 +1594,13 @@ cairo_arc_to (cairo_t *cr, double x2, double y2, double radius) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_arc_to (cr->gstate, - x1, y1, - x2, y2, - radius); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_arc_to (cr->gstate, + x1, y1, + x2, y2, + radius); } */ @@ -1658,19 +1624,17 @@ void cairo_rel_move_to (cairo_t *cr, double dx, double dy) { cairo_fixed_t dx_fixed, dy_fixed; - cairo_status_t status; if (cr->status) return; _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); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_fixed_rel_move_to (cr->path, dx_fixed, dy_fixed); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1695,19 +1659,17 @@ void cairo_rel_line_to (cairo_t *cr, double dx, double dy) { cairo_fixed_t dx_fixed, dy_fixed; - cairo_status_t status; if (cr->status) return; _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); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_fixed_rel_line_to (cr->path, dx_fixed, dy_fixed); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def(cairo_rel_line_to); @@ -1746,7 +1708,6 @@ cairo_rel_curve_to (cairo_t *cr, 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 (cr->status) return; @@ -1764,12 +1725,12 @@ cairo_rel_curve_to (cairo_t *cr, 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); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_fixed_rel_curve_to (cr->path, + dx1_fixed, dy1_fixed, + dx2_fixed, dy2_fixed, + dx3_fixed, dy3_fixed); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -1811,14 +1772,12 @@ cairo_rectangle (cairo_t *cr, void cairo_stroke_to_path (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_stroke_path (cr->gstate); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_stroke_path (cr->gstate); + if (cr->status) + _cairo_set_error (cr, cr->status); } */ @@ -1851,14 +1810,12 @@ cairo_stroke_to_path (cairo_t *cr) void cairo_close_path (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_path_fixed_close_path (cr->path); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_fixed_close_path (cr->path); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def(cairo_close_path); @@ -1872,14 +1829,12 @@ slim_hidden_def(cairo_close_path); void cairo_paint (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_paint (cr->gstate); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_paint (cr->gstate); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def (cairo_paint); @@ -1897,7 +1852,6 @@ void cairo_paint_with_alpha (cairo_t *cr, double alpha) { - cairo_status_t status; cairo_color_t color; cairo_pattern_union_t pattern; @@ -1914,11 +1868,11 @@ cairo_paint_with_alpha (cairo_t *cr, } _cairo_color_init_rgba (&color, 1., 1., 1., alpha); - _cairo_pattern_init_solid (&pattern.solid, &color, CAIRO_CONTENT_ALPHA); + _cairo_pattern_init_solid (&pattern.solid, &color); - status = _cairo_gstate_mask (cr->gstate, &pattern.base); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_mask (cr->gstate, &pattern.base); + if (cr->status) + _cairo_set_error (cr, cr->status); _cairo_pattern_fini (&pattern.base); } @@ -1937,8 +1891,6 @@ void cairo_mask (cairo_t *cr, cairo_pattern_t *pattern) { - cairo_status_t status; - if (cr->status) return; @@ -1952,9 +1904,9 @@ cairo_mask (cairo_t *cr, return; } - status = _cairo_gstate_mask (cr->gstate, pattern); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_mask (cr->gstate, pattern); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def (cairo_mask); @@ -2048,14 +2000,12 @@ cairo_stroke (cairo_t *cr) void cairo_stroke_preserve (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_stroke (cr->gstate, cr->path); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_stroke (cr->gstate, cr->path); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def(cairo_stroke_preserve); @@ -2091,14 +2041,12 @@ cairo_fill (cairo_t *cr) void cairo_fill_preserve (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_fill (cr->gstate, cr->path); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_fill (cr->gstate, cr->path); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def(cairo_fill_preserve); @@ -2114,14 +2062,12 @@ slim_hidden_def(cairo_fill_preserve); void cairo_copy_page (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_copy_page (cr->gstate); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_copy_page (cr->gstate); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2134,14 +2080,12 @@ cairo_copy_page (cairo_t *cr) void cairo_show_page (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_show_page (cr->gstate); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_show_page (cr->gstate); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2152,8 +2096,7 @@ cairo_show_page (cairo_t *cr) * * Tests whether the given point is inside the area that would be * affected by a cairo_stroke() operation given the current path and - * stroking parameters. Surface dimensions and clipping are not taken - * into account. + * stroking parameters. * * See cairo_stroke(), cairo_set_line_width(), cairo_set_line_join(), * cairo_set_line_cap(), cairo_set_dash(), and @@ -2165,17 +2108,16 @@ cairo_show_page (cairo_t *cr) cairo_bool_t cairo_in_stroke (cairo_t *cr, double x, double y) { - cairo_status_t status; - cairo_bool_t inside = FALSE; + cairo_bool_t inside; if (cr->status) return 0; - status = _cairo_gstate_in_stroke (cr->gstate, - cr->path, - x, y, &inside); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_in_stroke (cr->gstate, + cr->path, + x, y, &inside); + if (cr->status) + return 0; return inside; } @@ -2188,8 +2130,7 @@ cairo_in_stroke (cairo_t *cr, double x, double y) * * Tests whether the given point is inside the area that would be * affected by a cairo_fill() operation given the current path and - * filling parameters. Surface dimensions and clipping are not taken - * into account. + * filling parameters. * * See cairo_fill(), cairo_set_fill_rule() and cairo_fill_preserve(). * @@ -2199,17 +2140,18 @@ cairo_in_stroke (cairo_t *cr, double x, double y) cairo_bool_t cairo_in_fill (cairo_t *cr, double x, double y) { - cairo_status_t status; - cairo_bool_t inside = FALSE; + cairo_bool_t inside; if (cr->status) return 0; - status = _cairo_gstate_in_fill (cr->gstate, - cr->path, - x, y, &inside); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_in_fill (cr->gstate, + cr->path, + x, y, &inside); + if (cr->status) { + _cairo_set_error (cr, cr->status); + return 0; + } return inside; } @@ -2236,16 +2178,14 @@ void cairo_stroke_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_stroke_extents (cr->gstate, - cr->path, - x1, y1, x2, y2); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_stroke_extents (cr->gstate, + cr->path, + x1, y1, x2, y2); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2268,16 +2208,14 @@ void cairo_fill_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_fill_extents (cr->gstate, - cr->path, - x1, y1, x2, y2); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_fill_extents (cr->gstate, + cr->path, + x1, y1, x2, y2); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2335,14 +2273,12 @@ cairo_clip (cairo_t *cr) void cairo_clip_preserve (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_clip (cr->gstate, cr->path); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_clip (cr->gstate, cr->path); + if (cr->status) + _cairo_set_error (cr, cr->status); } slim_hidden_def(cairo_clip_preserve); @@ -2365,14 +2301,12 @@ slim_hidden_def(cairo_clip_preserve); void cairo_reset_clip (cairo_t *cr) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_reset_clip (cr->gstate); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_reset_clip (cr->gstate); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2393,14 +2327,12 @@ cairo_clip_extents (cairo_t *cr, double *x1, double *y1, double *x2, double *y2) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_clip_extents (cr->gstate, x1, y1, x2, y2); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_clip_extents (cr->gstate, x1, y1, x2, y2); + if (cr->status) + _cairo_set_error (cr, cr->status); } static cairo_rectangle_list_t * @@ -2408,9 +2340,6 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status) { cairo_rectangle_list_t *list; - if (status == CAIRO_STATUS_NO_MEMORY) - return (cairo_rectangle_list_t*) &_cairo_rectangles_nil; - list = malloc (sizeof (cairo_rectangle_list_t)); if (list == NULL) return (cairo_rectangle_list_t*) &_cairo_rectangles_nil; @@ -2469,14 +2398,12 @@ cairo_select_font_face (cairo_t *cr, cairo_font_slant_t slant, cairo_font_weight_t weight) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_select_font_face (cr->gstate, family, slant, weight); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_select_font_face (cr->gstate, family, slant, weight); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2491,14 +2418,12 @@ void cairo_font_extents (cairo_t *cr, cairo_font_extents_t *extents) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_get_font_extents (cr->gstate, extents); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_get_font_extents (cr->gstate, extents); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2514,14 +2439,12 @@ void cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_font_face (cr->gstate, font_face); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_font_face (cr->gstate, font_face); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2545,15 +2468,14 @@ cairo_set_font_face (cairo_t *cr, cairo_font_face_t * cairo_get_font_face (cairo_t *cr) { - cairo_status_t status; cairo_font_face_t *font_face; if (cr->status) return (cairo_font_face_t*) &_cairo_font_face_nil; - status = _cairo_gstate_get_font_face (cr->gstate, &font_face); - if (status) { - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_get_font_face (cr->gstate, &font_face); + if (cr->status) { + _cairo_set_error (cr, cr->status); return (cairo_font_face_t*) &_cairo_font_face_nil; } @@ -2574,14 +2496,12 @@ cairo_get_font_face (cairo_t *cr) void cairo_set_font_size (cairo_t *cr, double size) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_font_size (cr->gstate, size); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_font_size (cr->gstate, size); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2601,14 +2521,12 @@ void cairo_set_font_matrix (cairo_t *cr, const cairo_matrix_t *matrix) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_set_font_matrix (cr->gstate, matrix); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_set_font_matrix (cr->gstate, matrix); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2640,18 +2558,12 @@ void cairo_set_font_options (cairo_t *cr, const cairo_font_options_t *options) { - cairo_status_t status; - if (cr->status) return; - status = cairo_font_options_status ((cairo_font_options_t *) options); - if (status) { - _cairo_set_error (cr, status); - return; - } - - _cairo_gstate_set_font_options (cr->gstate, options); + cr->status = _cairo_gstate_set_font_options (cr->gstate, options); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2669,10 +2581,6 @@ void cairo_get_font_options (cairo_t *cr, cairo_font_options_t *options) { - /* check that we aren't trying to overwrite the nil object */ - if (cairo_font_options_status (options)) - return; - _cairo_gstate_get_font_options (cr->gstate, options); } @@ -2693,29 +2601,29 @@ void cairo_set_scaled_font (cairo_t *cr, const cairo_scaled_font_t *scaled_font) { - cairo_status_t status; - if (cr->status) return; - status = scaled_font->status; - if (status) + cr->status = scaled_font->status; + if (cr->status) goto BAIL; - status = _cairo_gstate_set_font_face (cr->gstate, scaled_font->font_face); - if (status) + cr->status = _cairo_gstate_set_font_face (cr->gstate, scaled_font->font_face); + if (cr->status) goto BAIL; - status = _cairo_gstate_set_font_matrix (cr->gstate, &scaled_font->font_matrix); - if (status) + cr->status = _cairo_gstate_set_font_matrix (cr->gstate, &scaled_font->font_matrix); + if (cr->status) goto BAIL; - _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options); + cr->status = _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options); + if (cr->status) + goto BAIL; return; BAIL: - _cairo_set_error (cr, status); + _cairo_set_error (cr, cr->status); } /** @@ -2741,15 +2649,14 @@ BAIL: cairo_scaled_font_t * cairo_get_scaled_font (cairo_t *cr) { - cairo_status_t status; cairo_scaled_font_t *scaled_font; if (cr->status) return (cairo_scaled_font_t *)&_cairo_scaled_font_nil; - status = _cairo_gstate_get_scaled_font (cr->gstate, &scaled_font); - if (status) { - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_get_scaled_font (cr->gstate, &scaled_font); + if (cr->status) { + _cairo_set_error (cr, cr->status); return (cairo_scaled_font_t *)&_cairo_scaled_font_nil; } @@ -2781,7 +2688,6 @@ cairo_text_extents (cairo_t *cr, const char *utf8, cairo_text_extents_t *extents) { - cairo_status_t status; cairo_glyph_t *glyphs = NULL; int num_glyphs; double x, y; @@ -2801,23 +2707,23 @@ cairo_text_extents (cairo_t *cr, cairo_get_current_point (cr, &x, &y); - status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, - x, y, - &glyphs, &num_glyphs); + cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, + x, y, + &glyphs, &num_glyphs); - if (status) { + if (cr->status) { if (glyphs) free (glyphs); - _cairo_set_error (cr, status); + _cairo_set_error (cr, cr->status); return; } - status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs, extents); + cr->status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs, extents); if (glyphs) free (glyphs); - if (status) - _cairo_set_error (cr, status); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2844,15 +2750,13 @@ cairo_glyph_extents (cairo_t *cr, int num_glyphs, cairo_text_extents_t *extents) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs, - extents); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs, + extents); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2886,7 +2790,6 @@ void cairo_show_text (cairo_t *cr, const char *utf8) { cairo_text_extents_t extents; - cairo_status_t status; cairo_glyph_t *glyphs = NULL, *last_glyph; int num_glyphs; double x, y; @@ -2899,24 +2802,24 @@ cairo_show_text (cairo_t *cr, const char *utf8) cairo_get_current_point (cr, &x, &y); - status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, + cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, x, y, &glyphs, &num_glyphs); - if (status) + if (cr->status) goto BAIL; if (num_glyphs == 0) return; - status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, num_glyphs); - if (status) + cr->status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, num_glyphs); + if (cr->status) goto BAIL; last_glyph = &glyphs[num_glyphs - 1]; - status = _cairo_gstate_glyph_extents (cr->gstate, - last_glyph, 1, - &extents); - if (status) + cr->status = _cairo_gstate_glyph_extents (cr->gstate, + last_glyph, 1, + &extents); + if (cr->status) goto BAIL; x = last_glyph->x + extents.x_advance; @@ -2927,8 +2830,8 @@ cairo_show_text (cairo_t *cr, const char *utf8) if (glyphs) free (glyphs); - if (status) - _cairo_set_error (cr, status); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2937,24 +2840,22 @@ cairo_show_text (cairo_t *cr, const char *utf8) * @glyphs: array of glyphs to show * @num_glyphs: number of glyphs to show * - * A drawing operator that generates the shape from an array of glyphs, + * A drawing operator that generates the shape from an array of glyphs, * rendered according to the current font_face, font_size * (font_matrix), and font_options. **/ void cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) { - cairo_status_t status; - if (cr->status) return; if (num_glyphs == 0) return; - status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, num_glyphs); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, num_glyphs); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -2984,7 +2885,6 @@ cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) void cairo_text_path (cairo_t *cr, const char *utf8) { - cairo_status_t status; cairo_text_extents_t extents; cairo_glyph_t *glyphs = NULL, *last_glyph; int num_glyphs; @@ -2995,29 +2895,29 @@ cairo_text_path (cairo_t *cr, const char *utf8) cairo_get_current_point (cr, &x, &y); - status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, - x, y, - &glyphs, &num_glyphs); + cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, + x, y, + &glyphs, &num_glyphs); - if (status) + if (cr->status) goto BAIL; if (num_glyphs == 0) return; - status = _cairo_gstate_glyph_path (cr->gstate, - glyphs, num_glyphs, - cr->path); + cr->status = _cairo_gstate_glyph_path (cr->gstate, + glyphs, num_glyphs, + cr->path); - if (status) + if (cr->status) goto BAIL; last_glyph = &glyphs[num_glyphs - 1]; - status = _cairo_gstate_glyph_extents (cr->gstate, - last_glyph, 1, - &extents); + cr->status = _cairo_gstate_glyph_extents (cr->gstate, + last_glyph, 1, + &extents); - if (status) + if (cr->status) goto BAIL; x = last_glyph->x + extents.x_advance; @@ -3028,8 +2928,8 @@ cairo_text_path (cairo_t *cr, const char *utf8) if (glyphs) free (glyphs); - if (status) - _cairo_set_error (cr, status); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -3045,16 +2945,14 @@ cairo_text_path (cairo_t *cr, const char *utf8) void cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs) { - cairo_status_t status; - if (cr->status) return; - status = _cairo_gstate_glyph_path (cr->gstate, - glyphs, num_glyphs, - cr->path); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_gstate_glyph_path (cr->gstate, + glyphs, num_glyphs, + cr->path); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** @@ -3115,19 +3013,11 @@ cairo_get_antialias (cairo_t *cr) * * Most path construction functions alter the current point. See the * following for details on how they affect the current point: - * cairo_new_path(), cairo_new_sub_path(), - * cairo_append_path(), cairo_close_path(), - * cairo_move_to(), cairo_line_to(), cairo_curve_to(), - * cairo_rel_move_to(), cairo_rel_line_to(), cairo_rel_curve_to(), - * cairo_arc(), cairo_arc_negative(), cairo_rectangle(), - * cairo_text_path(), cairo_glyph_path(), cairo_stroke_to_path() * - * Some functions use and alter the current point but do not otherwise - * change current path: - * cairo_show_text(), cairo_show_glyphs(). - * - * Some functions unset the current path and as a result, current point: - * cairo_fill(), cairo_stroke(). + * cairo_new_path(), cairo_move_to(), cairo_line_to(), + * cairo_curve_to(), cairo_arc(), cairo_rel_move_to(), + * cairo_rel_line_to(), cairo_rel_curve_to(), cairo_arc(), + * cairo_text_path(), cairo_stroke_to_path() **/ void cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret) @@ -3389,8 +3279,6 @@ void cairo_append_path (cairo_t *cr, const cairo_path_t *path) { - cairo_status_t status; - if (cr->status) return; @@ -3413,9 +3301,9 @@ cairo_append_path (cairo_t *cr, return; } - status = _cairo_path_append_to_context (path, cr); - if (status) - _cairo_set_error (cr, status); + cr->status = _cairo_path_append_to_context (path, cr); + if (cr->status) + _cairo_set_error (cr, cr->status); } /** diff --git a/gfx/cairo/libpixman/src/fbtrap.c b/gfx/cairo/libpixman/src/fbtrap.c index bd41cf7ebc4..4af6a8887b1 100644 --- a/gfx/cairo/libpixman/src/fbtrap.c +++ b/gfx/cairo/libpixman/src/fbtrap.c @@ -1,5 +1,5 @@ /* - * $Id: fbtrap.c,v 1.16 2007/06/11 00:01:31 vladimir%pobox.com Exp $ + * $Id: fbtrap.c,v 1.17 2007/06/11 04:39:03 gavin%gavinsharp.com Exp $ * * Copyright © 2004 Keith Packard * @@ -22,8 +22,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include "pixmanint.h" - #include "pixman-xserver-compat.h" #ifdef RENDER