[PATCH] [cairo] Use cairo_status() rather than open-coding cr->status.
Chris Wilson
chris at chris-wilson.co.uk
Fri Feb 22 10:34:51 PST 2008
Instead of using the cr->status as the guard, we use cairo_status()
which also prevents dereferencing a NULL pointer.
---
src/cairo.c | 237 +++++++++++++++++++++++++++++++---------------------------
1 files changed, 127 insertions(+), 110 deletions(-)
diff --git a/src/cairo.c b/src/cairo.c
index a0fbb49..98a5d4f 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -52,7 +52,7 @@ static const cairo_t _cairo_nil = {
{{ /* gstate_tail */
0
}},
- {{ /* path */
+ {{ /* path */
{ 0, 0 }, /* last_move_point */
{ 0, 0 }, /* current point */
FALSE, /* has_current_point */
@@ -292,8 +292,7 @@ void *
cairo_get_user_data (cairo_t *cr,
const cairo_user_data_key_t *key)
{
- return _cairo_user_data_array_get_data (&cr->user_data,
- key);
+ return _cairo_user_data_array_get_data (&cr->user_data, key);
}
/**
@@ -368,13 +367,12 @@ cairo_save (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_save (&cr->gstate);
- if (status) {
+ if (status)
_cairo_set_error (cr, status);
- }
}
slim_hidden_def(cairo_save);
@@ -391,13 +389,12 @@ cairo_restore (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_restore (&cr->gstate);
- if (status) {
+ if (status)
_cairo_set_error (cr, status);
- }
}
slim_hidden_def(cairo_restore);
@@ -478,7 +475,7 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content)
cairo_rectangle_int_t extents;
cairo_surface_t *parent_surface, *group_surface = NULL;
- if (cr->status)
+ if (cairo_status (cr))
return;
parent_surface = _cairo_gstate_get_target (cr->gstate);
@@ -486,6 +483,7 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content)
status = _cairo_surface_get_extents (parent_surface, &extents);
if (status)
goto bail;
+
status = _cairo_clip_intersect_to_rectangle (_cairo_gstate_get_clip (cr->gstate), &extents);
if (status)
goto bail;
@@ -549,7 +547,7 @@ cairo_pop_group (cairo_t *cr)
cairo_pattern_t *group_pattern = (cairo_pattern_t*) &_cairo_pattern_nil.base;
cairo_matrix_t group_matrix;
- if (cr->status)
+ if (cairo_status (cr))
return group_pattern;
/* Grab the active surfaces */
@@ -643,7 +641,7 @@ cairo_set_operator (cairo_t *cr, cairo_operator_t op)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_operator (cr->gstate, op);
@@ -672,7 +670,7 @@ cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue)
{
cairo_pattern_t *pattern;
- if (cr->status)
+ if (cairo_status (cr))
return;
/* push the current pattern to the freed lists */
@@ -706,7 +704,7 @@ cairo_set_source_rgba (cairo_t *cr,
{
cairo_pattern_t *pattern;
- if (cr->status)
+ if (cairo_status (cr))
return;
/* push the current pattern to the freed lists */
@@ -749,7 +747,7 @@ cairo_set_source_surface (cairo_t *cr,
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
- if (cr->status)
+ if (cairo_status (cr))
return;
/* push the current pattern to the freed lists */
@@ -789,7 +787,7 @@ cairo_set_source (cairo_t *cr, cairo_pattern_t *source)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (source == NULL) {
@@ -821,7 +819,7 @@ slim_hidden_def (cairo_set_source);
cairo_pattern_t *
cairo_get_source (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return (cairo_pattern_t*) &_cairo_pattern_nil.base;
return _cairo_gstate_get_source (cr->gstate);
@@ -845,7 +843,7 @@ cairo_set_tolerance (cairo_t *cr, double tolerance)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_restrict_value (&tolerance, CAIRO_TOLERANCE_MINIMUM, tolerance);
@@ -873,7 +871,7 @@ cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_antialias (cr->gstate, antialias);
@@ -897,7 +895,7 @@ cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_fill_rule (cr->gstate, fill_rule);
@@ -936,7 +934,7 @@ cairo_set_line_width (cairo_t *cr, double width)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_restrict_value (&width, 0.0, width);
@@ -965,7 +963,7 @@ cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_line_cap (cr->gstate, line_cap);
@@ -992,7 +990,7 @@ cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_line_join (cr->gstate, line_join);
@@ -1040,7 +1038,7 @@ cairo_set_dash (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_dash (cr->gstate,
@@ -1067,7 +1065,7 @@ cairo_get_dash_count (cairo_t *cr)
{
int num_dashes;
- if (cr->status)
+ if (cairo_status (cr))
return 0;
_cairo_gstate_get_dash (cr->gstate, NULL, &num_dashes, NULL);
@@ -1092,7 +1090,7 @@ cairo_get_dash (cairo_t *cr,
double *dashes,
double *offset)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_get_dash (cr->gstate, dashes, NULL, offset);
@@ -1122,7 +1120,7 @@ cairo_set_miter_limit (cairo_t *cr, double limit)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_miter_limit (cr->gstate, limit);
@@ -1147,7 +1145,7 @@ cairo_translate (cairo_t *cr, double tx, double ty)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_translate (cr->gstate, tx, ty);
@@ -1171,7 +1169,7 @@ cairo_scale (cairo_t *cr, double sx, double sy)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_scale (cr->gstate, sx, sy);
@@ -1197,7 +1195,7 @@ cairo_rotate (cairo_t *cr, double angle)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_rotate (cr->gstate, angle);
@@ -1220,7 +1218,7 @@ cairo_transform (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_transform (cr->gstate, matrix);
@@ -1242,7 +1240,7 @@ cairo_set_matrix (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_matrix (cr->gstate, matrix);
@@ -1262,7 +1260,7 @@ cairo_set_matrix (cairo_t *cr,
void
cairo_identity_matrix (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_identity_matrix (cr->gstate);
@@ -1281,7 +1279,7 @@ cairo_identity_matrix (cairo_t *cr)
void
cairo_user_to_device (cairo_t *cr, double *x, double *y)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_device (cr->gstate, x, y);
@@ -1301,7 +1299,7 @@ cairo_user_to_device (cairo_t *cr, double *x, double *y)
void
cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_device_distance (cr->gstate, dx, dy);
@@ -1320,7 +1318,7 @@ cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy)
void
cairo_device_to_user (cairo_t *cr, double *x, double *y)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_device_to_user (cr->gstate, x, y);
@@ -1340,7 +1338,7 @@ cairo_device_to_user (cairo_t *cr, double *x, double *y)
void
cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_device_to_user_distance (cr->gstate, dx, dy);
@@ -1356,7 +1354,7 @@ cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy)
void
cairo_new_path (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_path_fixed_fini (cr->path);
@@ -1378,7 +1376,7 @@ cairo_move_to (cairo_t *cr, double x, double y)
cairo_status_t status;
cairo_fixed_t x_fixed, y_fixed;
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_backend (cr->gstate, &x, &y);
@@ -1412,7 +1410,7 @@ slim_hidden_def(cairo_move_to);
void
cairo_new_sub_path (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_path_fixed_new_sub_path (cr->path);
@@ -1437,7 +1435,7 @@ cairo_line_to (cairo_t *cr, double x, double y)
cairo_status_t status;
cairo_fixed_t x_fixed, y_fixed;
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_backend (cr->gstate, &x, &y);
@@ -1480,7 +1478,7 @@ cairo_curve_to (cairo_t *cr,
cairo_fixed_t x2_fixed, y2_fixed;
cairo_fixed_t x3_fixed, y3_fixed;
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_backend (cr->gstate, &x1, &y1);
@@ -1558,7 +1556,7 @@ cairo_arc (cairo_t *cr,
double radius,
double angle1, double angle2)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
/* Do nothing, successfully, if radius is <= 0 */
@@ -1600,7 +1598,7 @@ cairo_arc_negative (cairo_t *cr,
double radius,
double angle1, double angle2)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
/* Do nothing, successfully, if radius is <= 0 */
@@ -1627,7 +1625,7 @@ cairo_arc_to (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_arc_to (cr->gstate,
@@ -1661,7 +1659,7 @@ 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)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);
@@ -1698,7 +1696,7 @@ 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)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);
@@ -1749,7 +1747,7 @@ cairo_rel_curve_to (cairo_t *cr,
cairo_fixed_t dx3_fixed, dy3_fixed;
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
_cairo_gstate_user_to_device_distance (cr->gstate, &dx1, &dy1);
@@ -1798,7 +1796,7 @@ cairo_rectangle (cairo_t *cr,
double x, double y,
double width, double height)
{
- if (cr->status)
+ if (cairo_status (cr))
return;
cairo_move_to (cr, x, y);
@@ -1814,7 +1812,7 @@ cairo_stroke_to_path (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_stroke_path (cr->gstate);
@@ -1854,7 +1852,7 @@ cairo_close_path (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_path_fixed_close_path (cr->path);
@@ -1900,7 +1898,7 @@ cairo_path_extents (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status) {
+ if (cairo_status (cr)) {
if (x1)
*x1 = 0.0;
if (y1)
@@ -1933,7 +1931,7 @@ cairo_paint (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_paint (cr->gstate);
@@ -1960,7 +1958,7 @@ cairo_paint_with_alpha (cairo_t *cr,
cairo_color_t color;
cairo_pattern_union_t pattern;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (CAIRO_ALPHA_IS_OPAQUE (alpha)) {
@@ -1998,7 +1996,7 @@ cairo_mask (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (pattern == NULL) {
@@ -2038,7 +2036,7 @@ cairo_mask_surface (cairo_t *cr,
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
- if (cr->status)
+ if (cairo_status (cr))
return;
pattern = cairo_pattern_create_for_surface (surface);
@@ -2109,7 +2107,7 @@ cairo_stroke_preserve (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_stroke (cr->gstate, cr->path);
@@ -2152,7 +2150,7 @@ cairo_fill_preserve (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_fill (cr->gstate, cr->path);
@@ -2178,7 +2176,7 @@ cairo_copy_page (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_copy_page (cr->gstate);
@@ -2201,7 +2199,7 @@ cairo_show_page (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_show_page (cr->gstate);
@@ -2233,8 +2231,8 @@ cairo_in_stroke (cairo_t *cr, double x, double y)
cairo_status_t status;
cairo_bool_t inside = FALSE;
- if (cr->status)
- return 0;
+ if (cairo_status (cr))
+ return FALSE;
status = _cairo_gstate_in_stroke (cr->gstate,
cr->path,
@@ -2267,8 +2265,8 @@ cairo_in_fill (cairo_t *cr, double x, double y)
cairo_status_t status;
cairo_bool_t inside = FALSE;
- if (cr->status)
- return 0;
+ if (cairo_status (cr))
+ return FALSE;
status = _cairo_gstate_in_fill (cr->gstate,
cr->path,
@@ -2309,7 +2307,7 @@ cairo_stroke_extents (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status) {
+ if (cairo_status (cr)) {
if (x1)
*x1 = 0.0;
if (y1)
@@ -2355,7 +2353,7 @@ cairo_fill_extents (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status) {
+ if (cairo_status (cr)) {
if (x1)
*x1 = 0.0;
if (y1)
@@ -2432,7 +2430,7 @@ cairo_clip_preserve (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_clip (cr->gstate, cr->path);
@@ -2462,7 +2460,7 @@ cairo_reset_clip (cairo_t *cr)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_reset_clip (cr->gstate);
@@ -2490,7 +2488,7 @@ cairo_clip_extents (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status) {
+ if (cairo_status (cr)) {
if (x1)
*x1 = 0.0;
if (y1)
@@ -2548,8 +2546,11 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status)
cairo_rectangle_list_t *
cairo_copy_clip_rectangle_list (cairo_t *cr)
{
- if (cr->status)
- return _cairo_rectangle_list_create_in_error (cr->status);
+ cairo_status_t status;
+
+ status = cairo_status (cr);
+ if (status)
+ return _cairo_rectangle_list_create_in_error (status);
return _cairo_gstate_copy_clip_rectangle_list (cr->gstate);
}
@@ -2577,7 +2578,7 @@ cairo_select_font_face (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_select_font_face (cr->gstate, family, slant, weight);
@@ -2605,7 +2606,7 @@ cairo_font_extents (cairo_t *cr,
extents->max_x_advance = 0.0;
extents->max_y_advance = 0.0;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_get_font_extents (cr->gstate, extents);
@@ -2628,7 +2629,7 @@ cairo_set_font_face (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_font_face (cr->gstate, font_face);
@@ -2660,7 +2661,7 @@ cairo_get_font_face (cairo_t *cr)
cairo_status_t status;
cairo_font_face_t *font_face;
- if (cr->status)
+ if (cairo_status (cr))
return (cairo_font_face_t*) &_cairo_font_face_nil;
status = _cairo_gstate_get_font_face (cr->gstate, &font_face);
@@ -2688,7 +2689,7 @@ cairo_set_font_size (cairo_t *cr, double size)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_font_size (cr->gstate, size);
@@ -2715,7 +2716,7 @@ cairo_set_font_matrix (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_set_font_matrix (cr->gstate, matrix);
@@ -2734,7 +2735,7 @@ cairo_set_font_matrix (cairo_t *cr,
void
cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix)
{
- if (cr->status) {
+ if (cairo_status (cr)) {
cairo_matrix_init_identity (matrix);
return;
}
@@ -2759,7 +2760,7 @@ cairo_set_font_options (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = cairo_font_options_status ((cairo_font_options_t *) options);
@@ -2790,7 +2791,7 @@ cairo_get_font_options (cairo_t *cr,
if (cairo_font_options_status (options))
return;
- if (cr->status) {
+ if (cairo_status (cr)) {
_cairo_font_options_init_default (options);
return;
}
@@ -2817,7 +2818,7 @@ cairo_set_scaled_font (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = scaled_font->status;
@@ -2866,8 +2867,9 @@ cairo_get_scaled_font (cairo_t *cr)
cairo_status_t status;
cairo_scaled_font_t *scaled_font;
- if (cr->status)
- return _cairo_scaled_font_create_in_error (cr->status);
+ status = cairo_status (cr);
+ if (status)
+ return _cairo_scaled_font_create_in_error (status);
status = _cairo_gstate_get_scaled_font (cr->gstate, &scaled_font);
if (status) {
@@ -2915,7 +2917,7 @@ cairo_text_extents (cairo_t *cr,
extents->x_advance = 0.0;
extents->y_advance = 0.0;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (utf8 == NULL)
@@ -2971,7 +2973,7 @@ cairo_glyph_extents (cairo_t *cr,
extents->x_advance = 0.0;
extents->y_advance = 0.0;
- if (cr->status)
+ if (cairo_status (cr))
return;
status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs,
@@ -3016,7 +3018,7 @@ cairo_show_text (cairo_t *cr, const char *utf8)
int num_glyphs;
double x, y;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (utf8 == NULL)
@@ -3071,7 +3073,7 @@ cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (num_glyphs == 0)
@@ -3115,7 +3117,7 @@ cairo_text_path (cairo_t *cr, const char *utf8)
int num_glyphs;
double x, y;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (utf8 == NULL)
@@ -3175,7 +3177,7 @@ cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs)
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (num_glyphs == 0)
@@ -3199,7 +3201,7 @@ cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs)
cairo_operator_t
cairo_get_operator (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return (cairo_operator_t) 0;
return _cairo_gstate_get_operator (cr->gstate);
@@ -3216,7 +3218,7 @@ cairo_get_operator (cairo_t *cr)
double
cairo_get_tolerance (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return 0.;
return _cairo_gstate_get_tolerance (cr->gstate);
@@ -3234,7 +3236,7 @@ slim_hidden_def (cairo_get_tolerance);
cairo_antialias_t
cairo_get_antialias (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return (cairo_antialias_t) 0;
return _cairo_gstate_get_antialias (cr->gstate);
@@ -3254,8 +3256,8 @@ cairo_get_antialias (cairo_t *cr)
cairo_bool_t
cairo_has_current_point (cairo_t *cr)
{
- if (cr->status)
- return FALSE;
+ if (cairo_status (cr))
+ return FALSE;
return cr->path->has_current_point;
}
@@ -3296,7 +3298,7 @@ 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 &&
+ if (cairo_status (cr) == CAIRO_STATUS_SUCCESS &&
_cairo_path_fixed_get_current_point (cr->path, &x_fixed, &y_fixed))
{
x = _cairo_fixed_to_double (x_fixed);
@@ -3327,7 +3329,7 @@ slim_hidden_def(cairo_get_current_point);
cairo_fill_rule_t
cairo_get_fill_rule (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return (cairo_fill_rule_t) 0;
return _cairo_gstate_get_fill_rule (cr->gstate);
@@ -3347,7 +3349,7 @@ cairo_get_fill_rule (cairo_t *cr)
double
cairo_get_line_width (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return 0.;
return _cairo_gstate_get_line_width (cr->gstate);
@@ -3364,7 +3366,7 @@ cairo_get_line_width (cairo_t *cr)
cairo_line_cap_t
cairo_get_line_cap (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return (cairo_line_cap_t) 0;
return _cairo_gstate_get_line_cap (cr->gstate);
@@ -3381,7 +3383,7 @@ cairo_get_line_cap (cairo_t *cr)
cairo_line_join_t
cairo_get_line_join (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return (cairo_line_join_t) 0;
return _cairo_gstate_get_line_join (cr->gstate);
@@ -3398,7 +3400,7 @@ cairo_get_line_join (cairo_t *cr)
double
cairo_get_miter_limit (cairo_t *cr)
{
- if (cr->status)
+ if (cairo_status (cr))
return 0.;
return _cairo_gstate_get_miter_limit (cr->gstate);
@@ -3414,7 +3416,7 @@ cairo_get_miter_limit (cairo_t *cr)
void
cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix)
{
- if (cr->status) {
+ if (cairo_status (cr)) {
cairo_matrix_init_identity (matrix);
return;
}
@@ -3442,8 +3444,11 @@ slim_hidden_def (cairo_get_matrix);
cairo_surface_t *
cairo_get_target (cairo_t *cr)
{
- if (cr->status)
- return _cairo_surface_create_in_error (cr->status);
+ cairo_status_t status;
+
+ status = cairo_status (cr);
+ if (status)
+ return _cairo_surface_create_in_error (status);
return _cairo_gstate_get_original_target (cr->gstate);
}
@@ -3471,8 +3476,11 @@ cairo_get_target (cairo_t *cr)
cairo_surface_t *
cairo_get_group_target (cairo_t *cr)
{
- if (cr->status)
- return _cairo_surface_create_in_error (cr->status);
+ cairo_status_t status;
+
+ status = cairo_status (cr);
+ if (status)
+ return _cairo_surface_create_in_error (status);
return _cairo_gstate_get_target (cr->gstate);
}
@@ -3510,8 +3518,11 @@ cairo_get_group_target (cairo_t *cr)
cairo_path_t *
cairo_copy_path (cairo_t *cr)
{
- if (cr->status)
- return _cairo_path_create_in_error (cr->status);
+ cairo_status_t status;
+
+ status = cairo_status (cr);
+ if (status)
+ return _cairo_path_create_in_error (status);
return _cairo_path_create (cr->path, cr->gstate);
}
@@ -3552,8 +3563,11 @@ cairo_copy_path (cairo_t *cr)
cairo_path_t *
cairo_copy_path_flat (cairo_t *cr)
{
- if (cr->status)
- return _cairo_path_create_in_error (cr->status);
+ cairo_status_t status;
+
+ status = cairo_status (cr);
+ if (status)
+ return _cairo_path_create_in_error (status);
return _cairo_path_create_flat (cr->path, cr->gstate);
}
@@ -3576,7 +3590,7 @@ cairo_append_path (cairo_t *cr,
{
cairo_status_t status;
- if (cr->status)
+ if (cairo_status (cr))
return;
if (path == NULL) {
@@ -3617,6 +3631,9 @@ cairo_append_path (cairo_t *cr,
cairo_status_t
cairo_status (cairo_t *cr)
{
+ if (cr == NULL)
+ return CAIRO_STATUS_NULL_POINTER;
+
return cr->status;
}
slim_hidden_def (cairo_status);
--
1.5.3.8
--=-BzpsUfdHqkE+TbB0ojYn
Content-Disposition: attachment; filename=0052-cairo-pattern-Use-cairo_pattern_status-in-prefer.patch
Content-Type: application/mbox; name=0052-cairo-pattern-Use-cairo_pattern_status-in-prefer.patch
Content-Transfer-Encoding: 7bit
More information about the cairo
mailing list