[cp-patches] FYI: CairoGraphics2D speedup

Mark Wielaard mark at klomp.org
Wed Jun 14 17:23:36 UTC 2006

Hi Roman,

On Wed, 2006-06-14 at 15:51 +0200, Roman Kennke wrote:
> Here comes a slight optimization for CairoGraphics2D efficiency wrt JNI
> calls. It adds special methods for 3 common graphics operations
> (drawLine, drawRect and fillRect), so that unnecessary JNI calls and
> object creations are avoided.

Nice, but unfortunately that doesn't work for ComponentGraphics which
manipulate the X state. In that case we need locking before drawing. We
used to get that for free since ComponentGraphics overrides draw(Shape)
and fill(Shape). So we need to override these three new public methods
so we do correct locking again.

2006-06-14  Mark Wielaard  <mark at klomp.org>

    * gnu/java/awt/peer/gtk/ComponentGraphics.java (drawLine): Lock and
    call super.
    (drawRect): Likewise.
    (fillRect): Likewise.

Unfortunately I am unable to say how much speed loss this gives because
without this patch the benchmark program kept crashing on me. With this
it runs reliable though.

We might want to think a bit more about how we do this locking since the
current way means we do three separate JNI calls and a little extra
bookkeeping in ComponentGraphics to account for the gdk lock not being
reentrant. It is probably much more efficient if we had some
needs_drawing_lock flag inside CairoGraphics itself that subclasses
could set if needed.

For now I committed this quick-fix though.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ComponentGraphics-locks.patch
Type: text/x-patch
Size: 1142 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20060614/372543d5/ComponentGraphics-locks.bin

More information about the Classpath-patches mailing list