[cairo] 1.6: cairo_xlib_surface_get_xrender_format

Behdad Esfahbod behdad at behdad.org
Mon Jan 28 13:50:06 PST 2008


On Sun, 2008-01-27 at 22:34 -0800, Carl Worth wrote:
> +/**
> + * cairo_xlib_surface_get_xrender_format
> + * @surface: an xlib surface created by
> + * cairo_xlib_surface_create_with_render_format
> + *
> + * Return value: the XRenderPictFormat* with which the surface was
> + * originally created, (or NULL if the surface is not an xlib surface
> + * or if the Render extension is not available).
> + */

Sounds good.  I'd replace "Render extension" by "X Render extension".


> +XRenderPictFormat *
> +cairo_xlib_surface_get_xrender_format (cairo_surface_t *surface)
> +{
> +    cairo_xlib_surface_t *xlib_surface = (cairo_xlib_surface_t *)
> surface;
> +
> +    /* Throw an error for a non-xlib surface */
> +    if (! _cairo_surface_is_xlib (surface)) {
> +       _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
> +       return NULL;
> +    }
> +
> +    /* And also for an xlib surface that is not an xlib-xrender
> surface */
> +    if (xlib_surface->xrender_format == NULL)
> +       _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);

I don't think an error should be thrown in this case.

> +    return xlib_surface->xrender_format;
> +}
>  #endif

You can also test the no-xrender case in your test case by calling
cairo_boilerplate_xlib_surface_disable_render().


-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list