[cairo] group/pattern API

Vladimir Vukicevic vladimirv at gmail.com
Mon Dec 5 18:44:58 PST 2005


On 12/5/05, Carl Worth <cworth at cworth.org> wrote:
> On Mon, 5 Dec 2005 17:23:32 -0800, Vladimir Vukicevic wrote:
> > Does it make sense to set a surface device offset while in the group,
> > and then right before returning the cairo_pattern_t* to set the
> > offsets back to 0,0, and instead set an appropriate matrix on the
> > pattern?
>
> I don't think we can use the pattern matrix here, since the user can
> modify that which would lead to surprising results, (see the examples I
> gave above).

Ok, makes sense.

> > > I don't like this. So far, we've been talking about creating a new
> > > kind of magic pattern named a "group", (which happens to have its
> > > create function split into begin/end_group rather than "group_create",
> > > but that's the best we've come up with).
> >
> > Ah, I missed that discussion.  I'd suggest not splitting create, and
> > instead having:
>
> I meant the discussion that you and I have been having about
> begin/end_group or push/pop_group. I see that API as being a split
> create function for a pattern that has some unique properties.

Sorry, I misunderstood the context.  A split function would work, but
it would involve introducing a new intermediate object for the
incomplete group pattern, no?  That might not be a bad thing, but I'm
not sure it's necessary.

> > How's that sound?  I think that we can do the group pattern creation
> > stuff in a separate patch from the context group API, though.
>
> I agree with the desire to keep the two patches separate. But I still
> don't see much of anything in this group pattern creation stuff that
> couldn't be implemented just fine within the existing
> cairo_surface_create_similar, cairo_pattern_create, and cairo_create.

The issue is that doing create_similar/etc. doesn't maintain the
current cairo_t state, and so creating a temporary surface would
require doing a lot of state copying manually.  It would also probably
require creating a full-size surface instead of being able to use the
current clip extents, though that can be worked around with a
cairo_fill_extents() call to use to test.  Preserving the current
state is the main thing that the group API brings.

    - Vlad


More information about the cairo mailing list