[cairo] [PATCH 03/72] core: allow NULL parameter for _cairo_path_fixed_is_box() and _cairo_path_fixed_is_stroke_box()

Bill Spitzak spitzak at gmail.com
Wed Dec 30 22:13:53 PST 2015


It would be better to make 2 functions rather than have this test.

Since the function is internal I think you could rename it, use the 
current name for the one returning true/false, and a new name for the 
converter to box.


On 12/29/2015 01:16 AM, Enrico Weigelt, metux IT consult wrote:
> Allow these functions to be called with NULL parameter for the
> return buffer, so we can use it for only checking whether
> a path is a box, w/o actually returning the box dimensions.
>
> This feature will be used in subsequent patches.
>
> Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
> ---
>   src/cairo-path-fixed.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
> index ac44bb7..3d49596 100644
> --- a/src/cairo-path-fixed.c
> +++ b/src/cairo-path-fixed.c
> @@ -1295,7 +1295,8 @@ _cairo_path_fixed_is_box (const cairo_path_fixed_t *path,
>
>       buf = cairo_path_head (path);
>       if (_points_form_rect (buf->points)) {
> -	_canonical_box (box, &buf->points[0], &buf->points[2]);
> +	if (box != NULL)
> +	    _canonical_box (box, &buf->points[0], &buf->points[2]);
>   	return TRUE;
>       }
>
> @@ -1413,7 +1414,8 @@ _cairo_path_fixed_is_stroke_box (const cairo_path_fixed_t *path,
>   	buf->points[2].y == buf->points[3].y &&
>   	buf->points[3].x == buf->points[0].x)
>       {
> -	_canonical_box (box, &buf->points[0], &buf->points[2]);
> +	if (box != NULL)
> +	    _canonical_box (box, &buf->points[0], &buf->points[2]);
>   	return TRUE;
>       }
>
> @@ -1422,7 +1424,8 @@ _cairo_path_fixed_is_stroke_box (const cairo_path_fixed_t *path,
>   	buf->points[2].x == buf->points[3].x &&
>   	buf->points[3].y == buf->points[0].y)
>       {
> -	_canonical_box (box, &buf->points[0], &buf->points[2]);
> +	if (box != NULL)
> +	    _canonical_box (box, &buf->points[0], &buf->points[2]);
>   	return TRUE;
>       }
>
>



More information about the cairo mailing list