[cairo] implement clone_similar fallback

Carl Worth cworth at cworth.org
Mon Aug 20 17:03:15 PDT 2007

On Mon, 06 Aug 2007 22:38:59 -0700, Vladimir Vukicevic wrote:
> Here's a patch that implements fallback for clone_similar; it uses
> create_similar_scratch and then calls composite with OPERATOR_SOURCE.

Thanks. This looks quite reasonable. Two minor comments below. Feel
free to address these as you see fit and then push the change.

> +    new_surface = _cairo_surface_create_similar_scratch (surface,
> +							  cairo_surface_get_content (src),
> +							  width, height);
> +    if (status == CAIRO_STATUS_SUCCESS)
> +	 *clone_out = new_surface;
> +    else if (new_surface)
> +	 cairo_surface_destroy (new_surface);

Part of the "never return NULL" approach means never having to test
for NULL. So you can legitimately drop the "if (new_surface)"
here. It's guaranteed to never be NULL, (this holds internally as well
as across the public interface). Similarly, you should probably set
*clone_out on failure as well as success. Those two points together
mean you probably don't need the cairo_surface_destroy code at all,
(since _create_similar_scratch should only be returning a nil surface
on error). So I think I'd just replace these last four lines of code
with simply:

	/* If any error occurred, then return the nil surface we received. */
	*clone_out = new_surface;

Finally, isn't there a comment in _cairo_surface_clone_similar that
should be removed along with this patch?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20070820/8737bd66/attachment.pgp 

More information about the cairo mailing list