[java-gnome-hackers] Annoucing Cairo coverage
Brought to you by:
afcowie
From: Andrew C. <an...@op...> - 2008-03-23 23:19:46
|
Hey, Cairo support is a feature I've been working on for about 6 months now, and I'm very pleased to be able to bring it into java-gnome. Behdad Esfahbod was really critical in explaining some basic Cairo concepts to me started when we were working together at the GNOME Summit back in October in Boston, and last week at the GTK hackfest in Berlin Carl Worth was able to help us debug some use cases. The focus of the work was two fold. Mostly I wanted to put the Plumbing in place appropriate to make a Cairo binding work. This was straight forward but non-trivial because Cairo doesn't use GLib as it's foundation. So type mapping, creating instances, etc took a bit of figuring out. The other part, of course, was putting enough coverage in place to ensure that things were working. Cairo has lots of convenience functions and tons of obscure uses; no surprise (and no apology) that there's still lots that will need doing. As ever, I have insisted that people exposing functionality have a reason to be using it so they can a) understand why they need it, and b) do a good job of explaining how to use it. I'm the "people" in this case :) and I must admit that I didn't have much of a use case driving my work on this. I am therefore pleased to hear that Carl Worth and his brother Kevin Worth will be using our Cairo bindings for a family oriented game that they are working on - that's a real use case that will allow people who really know Cairo to flesh things out. Implementation observations: - if using Cairo to draw for a Widget, you do this in an EXPOSE_EVENT handler. See the [new] documentation for that signal as a starting point. There's also an example, Example - The Java bias is what you'd expect. Constructors instead of factory functions, etc. In the case of Widget drawing, you use you use the Context(Drawable) constructor instead of [whatever] gdk_cairo_create() [would map to]. - error handling is done automatically. C programmers familiar with Cairo will be used to doing a bunch of stuff and then checking cairo_status(). We are calling that compulsively on each call. [Right now that's in the bindings layer; I expect to move it into the JNI layer once I touch up a few things in the generator]. If the status check fails a Java exception is thrown. One final point: - after discussing things with Carl, I've decided that there is (at present) no reason to expose the text rending APIs in Cairo. If you need to draw text, please implement the necessary functionality in Pango - which of course uses Cairo, but knows what it's doing. :) Preliminary Cairo support was one of the two dominoes I wanted to fall before releasing 4.0.7, so I'm pretty pleased. AfC Toronto -- Andrew Frederick Cowie Operational Dynamics is an operations and engineering consultancy focusing on IT strategy, organizational architecture, systems review, and effective procedures for change management. We actively carry out research and development in these areas on behalf of our clients, and enable successful use of open source in their mission critical enterprises, worldwide. http://www.operationaldynamics.com/ Sydney New York Toronto London |