Active rendering under Mac OS X

Did anyone check if the poor performance of active rendering under Mac OS X is a consequence of not creating screen compatible images? Examples of screen compatible images appear below.

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();

// Create an image that does not support transparency
bimage = gc.createCompatibleImage(width, height, Transparency.OPAQUE);

// Create an image that supports transparent pixels
bimage = gc.createCompatibleImage(width, height, Transparency.BITMASK);

// Create an image that supports arbitrary levels of transparency
bimage = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);

    Graphics2D g2d = (Graphics2D)g;
    int width = 100;
    int height = 100;

    // Create an image that does not support transparency
    BufferedImage bimage = g2d.getDeviceConfiguration().createCompatibleImage(
        width, height, Transparency.OPAQUE);

    // Create an image that supports transparent pixels
    bimage = g2d.getDeviceConfiguration().createCompatibleImage(
        width, height, Transparency.BITMASK);

    // Create an image that supports arbitrary levels of transparency
    bimage = g2d.getDeviceConfiguration().createCompatibleImage(
        width, height, Transparency.TRANSLUCENT);
BufferedImage bimage = (BufferedImage)component.createImage(width, height);
if (bimage == null) {
    // The component is not visible on the screen
}

Generally 24 bit RGB and 32 bit ARGB_PRE bitmaps work ok and use less code than create_compatible_bitmap. Avoid non-premultiplied ARGB.

OSX tends to antialias by default, while windows does not, so OSX can be slower resizing images.

Text rendering was very slow on Java 1.4.2 and Java 5 on OSX, so consider caching any text that is drawn every frame. Part of my problem was I was rendering text on to an image where I was already writing to the raster. See next point. I think the situation is better if you do everything in Java2D on the GPU. Can’t say for Java 6 as I don’t have it.

Try to avoid a mix of Java2D and direct raster manipulation on a bitmap. On Java 1.4.2 it kept swapping the bitmap between the GPU and CPU memory, converting formats. Often it failed to do this correctly. Java 5 appeared to have improved this a bit with regards to errors, but still slow.

My current experience is that my powerbook A4 (PPC) is 4 to 5 times slower than my windows 7 Core Duo. The latest desktop macs seem to be faster and I got closer to parity performance on a borrowed machine.

[quote=“Alan_W,post:2,topic:36294”]
I don’t know about the desktops, but my very new laptop works terribly on pretty much every applet. I’m pretty convinced it’s some kind of bug rather than anything else, but I basically get 2 FPS on 90% of the 4k games.

Some months ago I spent a lot of hours to find the reason. Some simple things (I don’t remember exacty which ones) in awt like drawImage/setColor took 100 times longer than on other operating systems.

-Dapple.awt.graphics.UseQuartz=false

fixed it in 1.5, not sure about Java 6 (IIRC).
With webstart there were no problems. Stupid that you can’t pass args in the applet tag on OS X

[quote=“Eli Delventhal,post:3,topic:36294”]

Doing better than me - I think mine’s the only one that even starts on my Ubuntu box. I’m beginning to suspect that pack200 is broken in the version of Java I have installed.