Hi Kirill,

[EMAIL PROTECTED] wrote:
Dmitri,

I did not see any change (on unaccelerated pipeline) between these two ways to 
create an offscreen image:

[code]
BufferedImage image = new BufferedImage(width, height,
 BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = (Graphics2D) image.getGraphics().create();
graphics.setColor(new Color(0, 0, 0, 0));
graphics.setComposite(AlphaComposite.Src);
graphics.fillRect(0, 0, width, height);
graphics.dispose();
return image;
[/code]

and
[code]
GraphicsEnvironment e = GraphicsEnvironment
        .getLocalGraphicsEnvironment();
GraphicsDevice d = e.getDefaultScreenDevice();
GraphicsConfiguration c = d.getDefaultConfiguration();
BufferedImage compatibleImage = c.createCompatibleImage(width, height,
        Transparency.TRANSLUCENT);
return compatibleImage;
[/code]
Substance uses image caches to speed up the painting. So the two code
> examples above play a very central role in the Substance painting
> pipeline. Release 4.3 uses the first approach. Should i use the second
one, and if not, what is the correct way to create translucent volatile
> images that can be cached and rendered multiple times?

  In both cases above you create a BufferedImage, not a Volatile one.

  To create VolatileImage, you'd need to use
  GC.createCompatibleVolatileImage(). (you'd need to add some extra code
  to validate them before you use them though, but for testing
  purposes, just validate them once when you create)

  And even if you switch to VIs, for un-accelerated case (like on
  your Intel system) there will be no difference.

  Nimbus L&F uses VIs for caching, and they saw pretty good
  performance improvement from that with the d3d pipeline
  enabled.

  Caching makes sense if you don't change the contents of the cache
  much. Does your code update the cached images often?

  If you run your benchmark on hw-accel pipeline with
  -Dsun.java2d.trace=count, you'll see that out of
  about 500.000 calls more than half were rendered into
  a buffered image.

  One perf.-related suggestion: make sure you don't clear the
  background (fillRect) with antialiasing enabled (a common
  mistake). So if your components need to clear the bg first,
  unset the AA, clear, then set it back.

  Thanks,
    Dmitri



Thanks for looking into this.

Kirill
[Message sent by forum member 'kirillcool' (kirillcool)]

http://forums.java.net/jive/thread.jspa?messageID=270836

===========================================================================
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".

Reply via email to