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

Re: [XaraXtreme-dev] Cairo Port



On Mon, 07 May 2007 22:08:14 +0200, Jonas Diemer wrote:
> I have been looking at Carl Worth's "lame attempt at fixing up the
> xaralx code to use cairo instead of a proprietary CDraw.a" for the past
> few hours.

Fantastic! I've always hoped that that trivial little thing I did
might help spur someone on to get something going.

> I have no experience with neither Xara nor Cairo, so I have a
> few questions:

I can't help with Xara experience, but I do know a thing or two about
cairo...

> 1. Carl created stubs for function calls to CDraw functions, which are
> to be replaced by Cairo functions. Wouldn't it be easier to derive a new
> GDrawContext instead? This has been done originally with GDrawAsm as a
> C++ wrapper for the assemblerfunctions in GDRAW.DLL. I think this would
> at least save passing around contexts, and would be more object
> oriented, too.

I have no idea on this point, (see above where I confess to zero
experience with Xara). I just made the cut at at exactly the point
where the code switched from GPL to non-GPL. If you've got a better
place in the code to make the cut, go for it!

> 2. I am so far struggling with the very basic: I need to set up a cairo
> context. To do this, I need a "drawable", i.e. some canvas I can draw
> to. I have found examples on how to do this from GTK/GDK, and I guess
> wxWidget is using a GTK backend...

No, I don't think you actually want a window system "drawable".

What the current CDraw library does is render things to a buffer of
memory. The equivalent notion in cairo is cairo's image backend which
you can get at with the cairo_image_surface_create_for_data function.

One thing to figure out right away is whether the image format that
Xara is using is compatible with any existing cairo image format.

So after using cairo instead of CDraw to render content, the existing
code within Xara that takes the content from the image buffer and
pushed it out through wxWidget stuff should work just fine. And that's
the right way to start, I think.

Yes, cairo does have other window-system-specific ways of drawing,
such as cairo_xlib_surface_create and cairo_win32_surface_create.
Moving to use those instead of cairo's image backend would be a fair
amount of work, and would be more disruptive to the Xara code I
think. So let's not so that as a first step.

> I hope someone can help me with this, so I can get started. I don't
> really have a whole lot of time for this, but maybe we can get the cairo
> backend into a reasonable state together.

I'm certainly here to answer any questions you've got. Good luck, and
have fun!

-Carl

> PS: I will be on vacation starting May 7, so my mail responses may be slow.

What's better to do on vacation than some fun hacking like this? :-)

Attachment: pgpRU0BOpN1Ov.pgp
Description: PGP signature