mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-09 06:08:02 +02:00
Simplify return value from cairo_path_fixed_get_current_point().
The only caller of cairo_path_fixed_get_current_point(), used the status return to determine whether or not the path had a current point (and did not propagate the error) - for which we had already removed the _cairo_error() markup. Now we reduce the boolean status return to a cairo_bool_t, with a net reduction in code.
This commit is contained in:
parent
4a2ab87e1a
commit
6fdb7f129c
3 changed files with 10 additions and 16 deletions
|
|
@ -340,21 +340,18 @@ _cairo_path_fixed_close_path (cairo_path_fixed_t *path)
|
||||||
return CAIRO_STATUS_SUCCESS;
|
return CAIRO_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_status_t
|
cairo_bool_t
|
||||||
_cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
|
_cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
|
||||||
cairo_fixed_t *x,
|
cairo_fixed_t *x,
|
||||||
cairo_fixed_t *y)
|
cairo_fixed_t *y)
|
||||||
{
|
{
|
||||||
if (! path->has_current_point) {
|
if (! path->has_current_point)
|
||||||
/* No need for _cairo_error() as the only caller,
|
return FALSE;
|
||||||
* cairo_get_current_point(), expects and handles NO_CURRENT_POINT */
|
|
||||||
return CAIRO_STATUS_NO_CURRENT_POINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
*x = path->current_point.x;
|
*x = path->current_point.x;
|
||||||
*y = path->current_point.y;
|
*y = path->current_point.y;
|
||||||
|
|
||||||
return CAIRO_STATUS_SUCCESS;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cairo_status_t
|
static cairo_status_t
|
||||||
|
|
|
||||||
13
src/cairo.c
13
src/cairo.c
|
|
@ -3166,20 +3166,17 @@ cairo_get_antialias (cairo_t *cr)
|
||||||
void
|
void
|
||||||
cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret)
|
cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret)
|
||||||
{
|
{
|
||||||
cairo_status_t status = CAIRO_STATUS_NO_CURRENT_POINT;
|
|
||||||
cairo_fixed_t x_fixed, y_fixed;
|
cairo_fixed_t x_fixed, y_fixed;
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
||||||
if (cr->status == CAIRO_STATUS_SUCCESS)
|
if (cr->status == CAIRO_STATUS_SUCCESS &&
|
||||||
status = _cairo_path_fixed_get_current_point (cr->path,
|
_cairo_path_fixed_get_current_point (cr->path, &x_fixed, &y_fixed)) {
|
||||||
&x_fixed, &y_fixed);
|
|
||||||
if (status == CAIRO_STATUS_NO_CURRENT_POINT) {
|
|
||||||
x = 0.0;
|
|
||||||
y = 0.0;
|
|
||||||
} else {
|
|
||||||
x = _cairo_fixed_to_double (x_fixed);
|
x = _cairo_fixed_to_double (x_fixed);
|
||||||
y = _cairo_fixed_to_double (y_fixed);
|
y = _cairo_fixed_to_double (y_fixed);
|
||||||
_cairo_gstate_backend_to_user (cr->gstate, &x, &y);
|
_cairo_gstate_backend_to_user (cr->gstate, &x, &y);
|
||||||
|
} else {
|
||||||
|
x = 0.0;
|
||||||
|
y = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x_ret)
|
if (x_ret)
|
||||||
|
|
|
||||||
|
|
@ -1479,7 +1479,7 @@ _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path,
|
||||||
cairo_private cairo_status_t
|
cairo_private cairo_status_t
|
||||||
_cairo_path_fixed_close_path (cairo_path_fixed_t *path);
|
_cairo_path_fixed_close_path (cairo_path_fixed_t *path);
|
||||||
|
|
||||||
cairo_private cairo_status_t
|
cairo_private cairo_bool_t
|
||||||
_cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
|
_cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
|
||||||
cairo_fixed_t *x,
|
cairo_fixed_t *x,
|
||||||
cairo_fixed_t *y);
|
cairo_fixed_t *y);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue