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

Re: [XaraXtreme-dev] Cairo Port


Thanks a lot for your reply!

Carl Worth schrieb:
On Mon, 07 May 2007 22:08:14 +0200, Jonas Diemer wrote:
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!

Well, maybe some Xara folks can tell...

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.
Yeah, thanks for explaining. I did not know how it worked in Xara, so I figured I'd have to use a window-system specific surface. Using a cairo_image_surface_create_for_data seems much easier, I will look into that.

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? :-)

Well, from that point of view, I am on vacation already. But I will actually be travelling soon, so I won't be able to hack/email then :-)