> This is surprising, it should behave exactly the
> same for
> both pipelines.
That is what I thought. Unfortunately it is not the case. I have tried the
strategy of rendering to a 'dummy' VolatileImage. Using the opengl pipeline it
takes 2 drawImage calls before isAccelerated returns true. Using the d3d
pipeline I can not get isAccelerated to return true by rendering to a
VolatileImage. In both cases if I render my image to a Graphics2D in a JPanel
it only takes one call to its drawImage method for the image to return true to
isAccelerated.
Except for using -Dsun.java2d.accthreshold=0 the best performance I can get is
by getting into the Sun classes using:
mapImage = this.read(new File(baseURL + fileName));
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc =
ge.getDefaultScreenDevice().getDefaultConfiguration();
((CachingSurfaceManager)(SurfaceManager.getManager(mapImage))).validate(gc);
System.out.println("after" + mapImage.getCapabilities(gc).isAccelerated());
This sort of works for both the opengl and d3d pipeline (that is - it seems to
work equally with both).
To put this in context the image is read based on a paintComponent() call to a
JPanel. The idea is that I have heaps of images to display (like tiles of a
map, but not quite). If the images satisfy some criteria then I will display
them. I have too many to maintain them all in memory so I have a mechanism in
paintComponent to load up each image, if it is needed to be displayed, in a
separate Thread. Subsequent calls to paintComponent will then display the image
if it has been loaded. If the image is no longer needed to be displayed then I
release all of the resources associated with it and let the Garbage Collector
do its job.
I want the first time I display the image to be as fast as possible, hence the
need for this discussion topic. Even by using the workaround above I see a
noticeable, but slight, delay in drawing the image the first time around. The
delay is not due to the read from file, nor the validate work I do above. It
happens the first time I draw the image. I know this as the result of extensive
testing. So even though the ImageCapabilities says that it is accelerated,
drawImage does something to it so that it actually is...? Further it seems that
only a call to drawImage of a Graphics object passed in paintComponent wil do
this.
I think what might be going on is that the GraphicsConfiguration that validate
needs to use to make an image accelerated when drawing to a Graphics object
that paintComponent gives you is different to the one that
getDefaultConfiguration() returns. NO! that is not it. I just tested it. So
what is going on?
> As mentioned in my other email, you should render
> them
> to an opaque VolatileImage.
> I wonder if we could provide a mechanism for
> specifying
> this behavior. Like, if the acceleration priority
> of an
> image is 1.0, then we could try to cache it right
> away
> without waiting for the threshold.
I like that idea. Maybe even nicer would be a method call to the Image to try
to make it managed when rendering to the default device.
[Message sent by forum member 'alnrelly' (alnrelly)]
http://forums.java.net/jive/thread.jspa?messageID=218093
===========================================================================
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".