Skip to main content

JDK6 update 10 - setXorMode and -Dsun.java2d.d3d=true

4 replies [Last post]
kiamur
Offline
Joined: 2006-11-10

Hi folks,

I've got an urgent performance problem with the "Graphics"-method "setXorMode" under JDK/JRE6 update 10 beta. I know it is only a beta version and therefore does not have to perform well, but maybe it is something from general interest and maybe (and hopefully) there is a solution for this problem to come.

We have a software which renders some quite complicated graphics. It just happens once per second and therefore it works quite well although these graphics could be more performant. The backbuffer pictures are of the typed "Image" (because it is a relative old library of our own) and because of this not hardware accelerated.

Recently, we added a new graphic to our software which should be rendered at 20Hz. This was impossible to do without hardware acceleration on our hardware (-> Pentium M 1.8GHz, 1GB RAM, ATI Mobility Radeon 9000 64MB, WinXP).
It took me some time to dig myself through all the performance possibilities and settings Java provides and ended up with VolatileImage, JRE6 update 10 beta and the switch -Dsun.java2d.d3d=true. With these settings, all works fine. The hardware renders the 20Hz graphic (which is proved by the massive decrease of CPU usage during rendering (100% -> 12-15%)), the (verbatim) old "Image"-graphics perform the same as ever.
Well, I have to say they perform ALMOST the same as ever . . . .
These old graphics have the possibility to let the user zoom into them. For the zooming, a rectangle is painted into the graphic so that the user can see what he already has marked with the mouse.
This rectangle is painted using the "setXorMode"-method of "Graphics". This is done (as you may guess) because the rectangle has to disappear in the current position each time the user moves the mouse a little farther. Now, this Xor-operation decreases the perfomance under JRE6 update 10 with -Dsun.java2d.d3d=true in a way that the zooming mode is nearly unusable. If I set the switch -Dsun.java2d.d3d to false, the Zooming works as normal but my 20Hz graphic is not hardware accelerated anymore (which I proved by asking the ImageCapabilities of the VolatileImage).

Now, what can I do to solve this problem?

Regards,
Maik

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Dmitri Trembovetski

Hi Maik,

this is a known problem described in
6635462: D3D: XOR rendering is extremly slow

Unfortunately there's no solution at this point.

I would suggest to avoid using xor mode. In your case
you can just draw the rectangle and then repaint the
affected area when it needs to be painted at new location.
There's no real need to use xor mode here.

Thanks,
Dmitri

java2d@JAVADESKTOP.ORG wrote:
> Hi folks,
>
> I've got an urgent performance problem with the "Graphics"-method "setXorMode" under JDK/JRE6 update 10 beta. I know it is only a beta version and therefore does not have to perform well, but maybe it is something from general interest and maybe (and hopefully) there is a solution for this problem to come.
>
> We have a software which renders some quite complicated graphics. It just happens once per second and therefore it works quite well although these graphics could be more performant. The backbuffer pictures are of the typed "Image" (because it is a relative old library of our own) and because of this not hardware accelerated.
>
> Recently, we added a new graphic to our software which should be rendered at 20Hz. This was impossible to do without hardware acceleration on our hardware (-> Pentium M 1.8GHz, 1GB RAM, ATI Mobility Radeon 9000 64MB, WinXP).
> It took me some time to dig myself through all the performance possibilities and settings Java provides and ended up with VolatileImage, JRE6 update 10 beta and the switch -Dsun.java2d.d3d=true. With these settings, all works fine. The hardware renders the 20Hz graphic (which is proved by the massive decrease of CPU usage during rendering (100% -> 12-15%)), the (verbatim) old "Image"-graphics perform the same as ever.
> Well, I have to say they perform ALMOST the same as ever . . . .
> These old graphics have the possibility to let the user zoom into them. For the zooming, a rectangle is painted into the graphic so that the user can see what he already has marked with the mouse.
> This rectangle is painted using the "setXorMode"-method of "Graphics". This is done (as you may guess) because the rectangle has to disappear in the current position each time the user moves the mouse a little farther. Now, this Xor-operation decreases the perfomance under JRE6 update 10 with -Dsun.java2d.d3d=true in a way that the zooming mode is nearly unusable. If I set the switch -Dsun.java2d.d3d to false, the Zooming works as normal but my 20Hz graphic is not hardware accelerated anymore (which I proved by asking the ImageCapabilities of the VolatileImage).
>
> Now, what can I do to solve this problem?
>
> Regards,
> Maik
> [Message sent by forum member 'kiamur' (kiamur)]
>
> http://forums.java.net/jive/thread.jspa?messageID=290320
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

kiamur
Offline
Joined: 2006-11-10

Hi Dmitri,

can you give me a hint how I redraw only the affected area in Java? I was looking for something like "invalidateRect" but I didn't found it.
Currently I circumvent my problem by re-rendering the whole image. This works better but is far from the performance with d3d=false and XOR rendering.

Thanks,
Maik

Dmitri Trembovetski

Hi Maik,

java2d@JAVADESKTOP.ORG wrote:
>
> can you give me a hint how I redraw only the affected area in Java? I was looking for something like "invalidateRect" but I didn't found it.

You can call repaint(x,y,w,h) for your component.
The area to repaint would be a union of the old
selected rectangle and the new one.

You can also limit the number of repaints by only
issuing repaints if the dimensions of the area changed by
certain number of pixels so that you don't have to
respond to a flood of mouse moved events.

> Currently I circumvent my problem by re-rendering the whole image. This works better but is far from the performance with d3d=false and XOR rendering.

There shouldn't be that much of a difference really, if all you
do is paint an image. If your re-painting operation is very
expensive, you might want to cache it in an image (at least for
the duration of the zoom selection) and do further updates by copying
from that image. Many applications do this trick - they'd
do an initial zoom by scaling an image first, and then repainting
at higher resolution (with higher scale factor) later.

Thanks,
Dmitri

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

kiamur
Offline
Joined: 2006-11-10

Hi Dmitri,

I will try that, tomorrow.

Thank you for your help!

Maik