> even if the animated panel is placed on an opaque panel

  This doesn't matter. If the window is made non-opaque,
  then every component inside that window will have to
  "pay the price".

  I don't believe this is a bug. This is a performance limitation of
  non-opaque windows on Windows platform - there's nothing we can
  do about it. Non-opaque windows were not originally intended for
  windows with high update rate. Every update means that we have
  to update whole window using GDI, which is not hw accelerated
  (in this case anyway).

  There's no magic here, the pixels need to get from system
  memory to vram. The faster the bus (like pcix), the better
  the performance. Older systems with PCI or AGP buses
  will have performance penalty.

  Thanks,
    Dmitri

[EMAIL PROTECTED] wrote:
To let the user decide to enable such an option is OK.

However I think possibly there still exists a performance bug. The test case 
below causes an avererage of 5% CPU utilization for opaque window and 50% CPU 
utilization for non-opaque windows even if the animated panel is placed on an 
opaque panel (tested on the older machine).

[code]
public class NonOpaqueWindowPerformanceTest extends JFrame
{
  public NonOpaqueWindowPerformanceTest()
  {
super(); setLayout(new BorderLayout());

    JPanel p = new JPanel();
    p.setBorder(new LineBorder(Color.GREEN));
    p.setBackground(Color.RED);
    p.setOpaque(true);

    final JPanel p2 = new JPanel();
    p2.setOpaque(true);
    p2.setBorder(new LineBorder(Color.blue));
p2.setPreferredSize(new Dimension(300,300)); p.add(p2); add(p);
    //remarking the following line means 90% less CPU-utilization on Windows XP
    setWindowNonOpaque(this);
setTitle(getClass().getSimpleName());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800, 600); setLocationRelativeTo(null);
    setVisible(true);
new Thread(){
      public void run()
      {
        while (true)
{ try
          {
            Thread.sleep(50);
          }
          catch (InterruptedException e)
          {
            e.printStackTrace();
          }

          EventQueue.invokeLater(new Runnable()
          {
            public void run()
            {
              Color color = new Color(new Random().nextInt(0xFFFFFF));
              p2.setBackground(color);
} });
        }
} }.start();
  }
private void setWindowNonOpaque(Window w)
  {
try {
      Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
      Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
      m.invoke(null, w, false);
} catch (Exception e) {
      e.printStackTrace();
} }

  public static void main(String[] args) throws Exception
  {
    EventQueue.invokeLater(new Runnable(){
      public void run()
      {
        JFrame.setDefaultLookAndFeelDecorated(true);
        new NonOpaqueWindowPerformanceTest();
} }); } }
[/code]
[Message sent by forum member 'wzberger' (wzberger)]

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

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