[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Cairo Port



On Mon, 07 May 2007 22:51:00 +0100, Alex Bligh wrote:
> > What is actually passed in the GCONTEXT struct? Esp., what's in the Data
> > field?
>
> It's an opaque data structure.

The point is that that this structure is private to the GDraw layer,
(the gdraw-cairo layer in this case). So you'll get to store whatever
data you need in that structure. I'm guessing it will first need just
a buffer of memory, a cairo_surface_t*, a cairo_t* . Later, you might
decide you need to add other stuff there for state that needs to be
tracked within GDraw but that doesn't map directly to state within a
cairo_t context.

There appears to be a goofy allocation scheme whereby GDraw doesn't
provide an allocation function, but instead just provides a
GDraw_ContextLength function and the layer above performs
allocation. I'm not sure what the precise semantics of that function
are, (is it just sizeof(private_struct) ? or does it also include a
dynamic component based on the size of the image buffer?).

Also, the code above must certainly be able to get at the image buffer
contents somehow in order to be able to actually display them. But I'm
not sure how that happens.

> > Should Valid actually be set toC90FDAA2 as it says in gconsts.h:238?
>
> I suspect that's an internal Magic number GDraw uses.

Yeah, that looks like a little guard field so that GDraw can
(hopefully) distinguish between a valid pointer to an initialized
context vs. a wild pointer or a not-yet-initialized context.

I imagine it would be totally up to you whether you wanted to
implement similar functionality or not. I would guess that the
higher-level code never looks at it.

-Carl

Attachment: pgp526sNQGMYh.pgp
Description: PGP signature