[cairo] [PATCH 15/72] image: typecasting helpers

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 29 06:52:20 PST 2015


On Tue, Dec 29, 2015 at 10:16:53AM +0100, Enrico Weigelt, metux IT consult wrote:
> Introduce helpers for typecasting from abstract surface to the
> actual image surface type.
> 
> This patch is also going to be needed by other backends utilizing
> the image surface internally.
> 
> Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
> ---
>  src/cairo-image-surface-private.h |  7 +++++++
>  src/cairo-image-surface.c         | 43 +++++++++++++++++++--------------------
>  2 files changed, 28 insertions(+), 22 deletions(-)
> 
> diff --git a/src/cairo-image-surface-private.h b/src/cairo-image-surface-private.h
> index 8ca694c..3af7f82 100644
> --- a/src/cairo-image-surface-private.h
> +++ b/src/cairo-image-surface-private.h
> @@ -88,6 +88,13 @@ typedef struct _cairo_image_source {
>      unsigned is_opaque_solid : 1;
>  } cairo_image_source_t;
>  
> +static cairo_always_inline cairo_image_surface_t *
> +_cairo_surface_cast_image ( cairo_surface_t *surface )
> +{
> +    assert (surface != NULL);

The assert here is pretty pointless. *NULL are easy enough to spot, all
incoming surfaces are defined (either real or error surfaces, and we
have said that anything else is undefined), so that leaves the internal
surface passing for which we sometimes use a temporary NULL for
unsupported.

I would rather see an attribute((nonnull)) annotations rather than
assert (the attribute would need to be propagated back through the
function pointers etc).
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list