Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4394782

Merlin on Win32: Performance degradation when using 24bit display

XMLWordPrintable

    • 2d
    • beta
    • x86
    • windows_98, windows_nt
    • Verified


      ingrid.yao@Eng 2000-12-04
      -----------------------------

      J2SE Version (please include all output from java -version flag):

      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b42)
      Java HotSpot(TM) Client VM (build B42, mixed mode)


      Does this problem occur on J2SE 1.3? No



      Operating System Configuration Information (be specific):
      Windows NT 4 Workstation, SP6


      Hardware Configuration Information (be specific):
      Pentium 166MHz, 96 MB RAM, S3 generic graphic adapter
      set 24-bit display


      Bug Description:
      6x decrease in performance of painting GeneralPath.

      Test results:
      ================
          8-bit 16-bit 24-bit 32-bit
        -----------------------------------------------
           1.3.0 ~114fps ~87fps ~68fps ~53fps
           1.3.1 ~80fps ~69fps ~47fps ~47fps
           1.4 ~83fps ~83fps ~25fps ~82fps
                                        |
      V
      Very Bad

      Test program:
      ==========================
      import java.awt.*;
      import java.awt.geom.*;
      import javax.swing.*;
      import java.awt.event.*;

      /**
       * There is big difference in frame rate between JDK1.3 and Merlin b42:
       * JDK1.3 : 40 fps
       * Merlin b42: 5 fps
       *
       * running with Xprof showhs bottleneck in two methods:
       * - sun.dc.pr.PathStroker.endPath (86%)
       * - javax.swing.RepaintManager.addDirtyRegion (21%)
       *
       * Testing machine:
       * Windows NT 4.0, Pentium 166MHz, 96 MB RAM
       *
       * @author ###@###.###
       */
      public class SlowPath2D extends JComponent {
          int POINTS = 1000;
          float AM = 100f;
          int currentPos = 0;
          GeneralPath path;
          static Object lock = new Integer(0);
          long lastTime;
          int frames = 0;
          String fps = "";
          
          ComponentListener myListener = new ComponentAdapter() {
              public void componentResized(ComponentEvent e) {
                  path = createPath();
              }
          };
          
          GeneralPath createPath() {
              GeneralPath p = new GeneralPath();
              float dx = getWidth() / (float) POINTS;
              p.moveTo(0f, 0);
              for(float x=0; x<getWidth(); x+=dx) {
                  p.lineTo(x, (float)( AM*Math.sin(6*Math.PI*x/getWidth())));
              }
              return p;
          }
          
          public void paintComponent(Graphics g) {
              super.paintComponent(g);
              if(path == null) return;
              double t = (System.currentTimeMillis() - lastTime) / 1000.0;
              if( t > 3 ) {
                  lastTime = System.currentTimeMillis();
                  frames = 1;
              } else {
                  frames++;
                  if( t > 1) fps = String.valueOf((int)(frames / t)) + " fps";
              }
              g.setColor(Color.black);
              g.drawString(fps,10,20);
              
              synchronized(lock) {
                  g.translate(0,currentPos);
                  ((Graphics2D)g).draw(path);
                  g.translate(0,-currentPos);
             }
          }
          
          public Dimension getPreferredSize() {
              return new Dimension(400, 400);
          }
          SlowPath2D() {
              addComponentListener(myListener);
          }
          void cycle() {
              int t = 0;
              while(1>0) {
                  synchronized(lock) {
                      currentPos = t % getHeight();
                  }
                  repaint();
                  try {
                      Thread.sleep(2);
                  } catch (Exception ex) {}
                  t += 5;
              }
          }
          
          public static void main(String args[]) {
              JFrame f = new JFrame();
              SlowPath2D p = new SlowPath2D();
              f.getContentPane().add(p);
              f.pack();
              f.setVisible(true);
              p.cycle();
          }
      }


      ingrid.yao@Eng 2000-12-05
      --------------------------

      more customer's test results:

      Pentium 166MHz, S3Trio 2MB
                           8bpp 16bpp 24bpp
      -----------------------------------------------------------
      1.3.0 ~19fps ~40fps ~22fps
      Merlin b42 ~80fps ~6fps ~4fps

      Pentium 750MHz, ATI 8MB
                           8bpp 16bpp 24bpp 32bpp
      ----------------------------------------------------------------------
      1.3.0 ~89fps ~100fps ~90fps ~90fps
      Merlin b42 ~250fps ~240fps ~27fps ~150fps

            chaasesunw Chet Haase (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: