Is this hardware accelerated?

I’m creating an application that zooms a few shapes in and out. (The shapes are lines, circles, polygons and other simple shapes, no pictures are involved). I zoom by moving the points, a line ((2,2)-(4,5)) becomes a new line, ((4,4)-(8,10)) with 2x zoom so I simply have an image that I draw to all the time.

I’m creating an accelerated image like this:

BufferedImage image;
Graphics2D gImage;

gc = getGraphicsConfiguration();
image = gc.createCompatibleImage(w, h);
gImage = ((Graphics2D)image.getGraphics());

The problem is that I’m worried that the image won’t stay accelerated because I draw new shapes to it all the time. From the point of the user, no new shapes are drawn, the shapes that was there when the application started are still there, none are added, none are removed. But in fact, I redraw the shapes as the user changes the zoom factor.

Am I right about the image, that it won’t stay accelerated? If I am right, is there anything else I could do? Use a VolatileImage? BufferStrategy? Zoom without redrawing the shapes?

Thanks!

I’m assuming you’re not creating images on every frame.

If the pattern is something like this:
In a loop
render to the image
copy it to the screen
then managed image won’t be accelerated, as it’ll be marked as dirty on every time.

Try using volatile image as your back-buffer.

Also, if you decide to render stuff to a VolatileImage and then copy it scaled to the screen (or another volatile image), note that the scaling operation won’t be accelerated unless you have sun.java2d.ddscale property set to true.

So you have two options: either set the scaling transform and render stuff to a volatile image (or buffer strategy back buffer) and then copy it to the screen, or render it w/o scaling, and then scale the image when copying to the screen (or back-buffer).

In general, the first approach is preferable because of the quality issues with scaling images (you’'ll get pixelization with big scale levels).

But you can experiement with combining the two approaches: do a quick and dirty scaling of the images for the intermediate steps, and then render the final image in full quality.