[EMAIL PROTECTED] wrote:
Thanks for all of the advice. You provided enough hints for me to get a
workaround that performs just as well on both the opengl and d3d pipelines.
This is what works for me:
In a static method do something like this so I have a dummy graphics lying
about for future use:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc =
ge.getDefaultScreenDevice().getDefaultConfiguration();
dummyImage = gc.createCompatibleVolatileImage(1,1,Transparency.OPAQUE);
dummyImage.validate(gc);
dummyGraphics = dummyImage.getGraphics();
Then when loading the image (in a Thread that paintComponent kicks off if the
image is not 'loaded')
mapImage = this.read(new File(baseURL + fileName));
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc =
ge.getDefaultScreenDevice().getDefaultConfiguration();
for(int i = 0 ; i < 4 && !mapImage.getCapabilities(gc).isAccelerated(); i ++){
dummyGraphics.drawImage(mapImage,0,0,null);
}
This makes the image managed and gives acceptable performance for what I want
to do. There are still some delays with this approach that are noticeable to a
picky programmer like I. They might be caused by kicking off the thread from
paintComponent, or maybe the native code is doing some sort of caching of the
images the first time they are drawn (less likely), or maybe my code is messed
up (most likely).
It would be nice to get a method in Image that allows me to 'make this Image
object managed if possible' without this workaround.
As I asked in one of my previous email, what do you think about
using "acceleration priority" property for this? Say, if it's
1.0 then we try to cache the image on first try.
0.0 currently means that we won't attempt to accelerate it and release
the cached version.
Thanks,
Dmitri
Java2D Team
Regards,
Alistair
I heeded the warning on using Sun private code. I really want to avoid it if
possible. There is not other place in my app that uses it and this is they way
I will endevour to keep it.
A few really important points that I failed to take notice of before:
- You must validate the VolatileImage or it will not cause images drawn to it
to be accelerated.
- The VolatileImage must be Transparency.OPAQUE. I originally had it as
Transparency .TRANSLUCENT. On the d3d pipeline this does not get acclerated,
hence the image drawn to it will not be made accelerated.
[Message sent by forum member 'alnrelly' (alnrelly)]
http://forums.java.net/jive/thread.jspa?messageID=218289
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".