Dienstag, 9. Dezember 2008

Java-level protocol generation

The last few days I was experimenting with xcb's new socket-handoff mechanism. It allows mixing self-generated protocol (java2d) with protocol generated by xcb/xlib (all the awt/motif stuff) - with a callback notifying the native side when it should give away control over the socket to the native libraries again.
I had quite a hard time with JNI, not knowing that local object references are only valid during the JNI interaction they were created for - but once that was fixed everything worked out quite fine.

The main advantages are no per-primitive JNI overhead and almost pure java - simplyfing maintainance and better portability as well as better performance.
Of course there are also disadvantages like dependency on a very recent version of libxcb (not in OpenSolaris for now) and maybe a higher protocol generation overhead due to java's managed nature.

For now only rectangles are supported, in the screenshot below the red rect was rendered by the "traditional" Java->C->libX11 call, and all other rects were directly generated in java:


rkennke hat gesagt…

Wow cool. This renders Escher useless? ;-)

Linuxhippy hat gesagt…

In the long term I hope all the X-related AWT/Java2D functionality can be de-natified, having all the acceleration logic in java is a first step.
So once other parts are ready, it shouldn't be too hard switching to Escher :)