[cairo] [PATCH 01/41] core: some helper macros for easier access to box dimensions

Uli Schlachter psychon at znc.in
Fri Dec 11 08:43:35 PST 2015


Am 10.12.2015 um 23:16 schrieb Enrico Weigelt, metux IT consult:
> Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
> ---
>  src/cairo-box-inline.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/cairo-box-inline.h b/src/cairo-box-inline.h
> index d6b9941..0bb8df8 100644
> --- a/src/cairo-box-inline.h
> +++ b/src/cairo-box-inline.h
> @@ -118,4 +118,7 @@ _cairo_box_is_pixel_aligned (const cairo_box_t *box)
>  #endif
>  }
>  
> +#define _CAIRO_BOX_WIDTH(box)	(abs(box.p2.x-box.p1.x))
> +#define _CAIRO_BOX_HEIGHT(box)	(abs(box.p2.y-box.p1.y))
> +
>  #endif /* CAIRO_BOX_H */

Hm. I don't really like this for two reasons:

The patch as-is just introduces unused definitions. I'd squash this into the
patch that uses this.

This evaluates the macro argument twice and doesn't even protect the
evaluations. Could you add least replace box with (box)?

Uli
-- 
"Are you preparing for another war, Plutarch?" I ask.
"Oh, not now. Now we're in that sweet period where everyone agrees that our
recent horrors should never be repeated," he says. "But collective thinking is
usually short-lived. We're fickle, stupid beings with poor memories and a great
gift for self-destruction.


More information about the cairo mailing list