mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-20 20:00:43 +02:00
Make _cairo_gstate_user_to_device (and friends) void.
This is just multiplication after all, so there's nothing that can fail. And we can get rid of a lot of useless error-checking code this way. The corrected functions are: _cairo_gstate_user_to_device _cairo_gstate_user_to_device_distance _cairo_gstate_device_to_user _cairo_gstate_device_to_user_distance
This commit is contained in:
parent
628ec8eb91
commit
9077da99ab
3 changed files with 26 additions and 60 deletions
|
|
@ -690,38 +690,30 @@ _cairo_gstate_identity_matrix (cairo_gstate_t *gstate)
|
|||
cairo_matrix_init_identity (&gstate->ctm_inverse);
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
void
|
||||
_cairo_gstate_user_to_device (cairo_gstate_t *gstate, double *x, double *y)
|
||||
{
|
||||
cairo_matrix_transform_point (&gstate->ctm, x, y);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
void
|
||||
_cairo_gstate_user_to_device_distance (cairo_gstate_t *gstate,
|
||||
double *dx, double *dy)
|
||||
{
|
||||
cairo_matrix_transform_distance (&gstate->ctm, dx, dy);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
void
|
||||
_cairo_gstate_device_to_user (cairo_gstate_t *gstate, double *x, double *y)
|
||||
{
|
||||
cairo_matrix_transform_point (&gstate->ctm_inverse, x, y);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
void
|
||||
_cairo_gstate_device_to_user_distance (cairo_gstate_t *gstate,
|
||||
double *dx, double *dy)
|
||||
{
|
||||
cairo_matrix_transform_distance (&gstate->ctm_inverse, dx, dy);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
62
src/cairo.c
62
src/cairo.c
|
|
@ -1280,14 +1280,10 @@ cairo_identity_matrix (cairo_t *cr)
|
|||
void
|
||||
cairo_user_to_device (cairo_t *cr, double *x, double *y)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
if (cr->status)
|
||||
return;
|
||||
|
||||
status = _cairo_gstate_user_to_device (cr->gstate, x, y);
|
||||
if (status)
|
||||
_cairo_set_error (cr, status);
|
||||
_cairo_gstate_user_to_device (cr->gstate, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1304,14 +1300,10 @@ cairo_user_to_device (cairo_t *cr, double *x, double *y)
|
|||
void
|
||||
cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
if (cr->status)
|
||||
return;
|
||||
|
||||
status = _cairo_gstate_user_to_device_distance (cr->gstate, dx, dy);
|
||||
if (status)
|
||||
_cairo_set_error (cr, status);
|
||||
_cairo_gstate_user_to_device_distance (cr->gstate, dx, dy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1327,14 +1319,10 @@ cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy)
|
|||
void
|
||||
cairo_device_to_user (cairo_t *cr, double *x, double *y)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
if (cr->status)
|
||||
return;
|
||||
|
||||
status = _cairo_gstate_device_to_user (cr->gstate, x, y);
|
||||
if (status)
|
||||
_cairo_set_error (cr, status);
|
||||
_cairo_gstate_device_to_user (cr->gstate, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1351,14 +1339,10 @@ cairo_device_to_user (cairo_t *cr, double *x, double *y)
|
|||
void
|
||||
cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
if (cr->status)
|
||||
return;
|
||||
|
||||
status = _cairo_gstate_device_to_user_distance (cr->gstate, dx, dy);
|
||||
if (status)
|
||||
_cairo_set_error (cr, status);
|
||||
_cairo_gstate_device_to_user_distance (cr->gstate, dx, dy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1678,13 +1662,12 @@ cairo_rel_move_to (cairo_t *cr, double dx, double dy)
|
|||
if (cr->status)
|
||||
return;
|
||||
|
||||
status = _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);
|
||||
if (status == CAIRO_STATUS_SUCCESS) {
|
||||
dx_fixed = _cairo_fixed_from_double (dx);
|
||||
dy_fixed = _cairo_fixed_from_double (dy);
|
||||
_cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);
|
||||
|
||||
status = _cairo_path_fixed_rel_move_to (cr->path, dx_fixed, dy_fixed);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
@ -1716,13 +1699,12 @@ cairo_rel_line_to (cairo_t *cr, double dx, double dy)
|
|||
if (cr->status)
|
||||
return;
|
||||
|
||||
status = _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);
|
||||
if (status == CAIRO_STATUS_SUCCESS) {
|
||||
dx_fixed = _cairo_fixed_from_double (dx);
|
||||
dy_fixed = _cairo_fixed_from_double (dy);
|
||||
_cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);
|
||||
|
||||
status = _cairo_path_fixed_rel_line_to (cr->path, dx_fixed, dy_fixed);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
@ -1768,15 +1750,9 @@ cairo_rel_curve_to (cairo_t *cr,
|
|||
if (cr->status)
|
||||
return;
|
||||
|
||||
status = _cairo_gstate_user_to_device_distance (cr->gstate, &dx1, &dy1);
|
||||
if (status)
|
||||
goto BAIL;
|
||||
status = _cairo_gstate_user_to_device_distance (cr->gstate, &dx2, &dy2);
|
||||
if (status)
|
||||
goto BAIL;
|
||||
status = _cairo_gstate_user_to_device_distance (cr->gstate, &dx3, &dy3);
|
||||
if (status)
|
||||
goto BAIL;
|
||||
_cairo_gstate_user_to_device_distance (cr->gstate, &dx1, &dy1);
|
||||
_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);
|
||||
|
|
@ -1791,10 +1767,8 @@ cairo_rel_curve_to (cairo_t *cr,
|
|||
dx1_fixed, dy1_fixed,
|
||||
dx2_fixed, dy2_fixed,
|
||||
dx3_fixed, dy3_fixed);
|
||||
if (status) {
|
||||
BAIL:
|
||||
if (status)
|
||||
_cairo_set_error (cr, status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1347,16 +1347,16 @@ _cairo_gstate_set_matrix (cairo_gstate_t *gstate,
|
|||
cairo_private void
|
||||
_cairo_gstate_identity_matrix (cairo_gstate_t *gstate);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
cairo_private void
|
||||
_cairo_gstate_user_to_device (cairo_gstate_t *gstate, double *x, double *y);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
cairo_private void
|
||||
_cairo_gstate_user_to_device_distance (cairo_gstate_t *gstate, double *dx, double *dy);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
cairo_private void
|
||||
_cairo_gstate_device_to_user (cairo_gstate_t *gstate, double *x, double *y);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
cairo_private void
|
||||
_cairo_gstate_device_to_user_distance (cairo_gstate_t *gstate, double *dx, double *dy);
|
||||
|
||||
cairo_private void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue