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

D3D: uncached Image scaling performance regression

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 6u10
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Image rendering in 1.6.0 update 10 has become about 10 times slower when compared to rendering speed in 1.6.0 update 07.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the included test code. Move the zoom slider back and forth until the average image paint time is printed in the console. In 1.6.0_10 this may take a while, in 1.6.0_07 it will be much faster (about 10 times faster when in full-screen).

      I could reproduce average paint times of about 100 millisec. for update 10 (both in initial frame size or full-screen frame) and between 2 millisec.(initial frame size) and 10 millisec. (full-screen) for update 07.

      (Remark: Running this test in 1.7.0-ea-b39 seems to be almost impossible)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JSlider;
      import javax.swing.event.ChangeEvent;
      import javax.swing.event.ChangeListener;
      import java.awt.BorderLayout;
      import java.awt.Color;
      import java.awt.Dimension;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.geom.AffineTransform;
      import java.awt.image.BufferedImage;

      /**
       *
       */
      public class ImageTest extends JFrame {
          AffineTransform Trns;
          BufferedImage Img;

          JSlider VwZmSlider;
          JPanel PaintPanel;

          protected void setZoom(double newZoom) {
              Trns.setToScale(newZoom, newZoom);
          }

          public ImageTest() {
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Trns = new AffineTransform();
              Img = new BufferedImage(6500, 2500, BufferedImage.TYPE_3BYTE_BGR);

              Graphics g = Img.getGraphics();
              try {
                  for (int i = 0; i < 6500; i += 50) {
                      g.setColor(Color.WHITE);
                      g.drawLine(0, i, 6500, i);
                      g.drawLine(i, 0, i, 2500);
                  }
              } finally {
                  g.dispose();
              }

              PaintPanel = new JPanel() {
                  private int paintCount;
                  private long paintTime;

                  protected void paintComponent(Graphics g) {
                      super.paintComponent(g);
                      Graphics2D g2d = (Graphics2D) g;

                      g2d.transform(Trns);
                      long time = -System.nanoTime();
                      g2d.drawImage(Img, 0, 0, this);
                      time += System.nanoTime();
                      paintTime += time;
                      paintCount++;

                      if (paintCount == 1) {
                          System.out.println("First paint time = " + (paintTime / paintCount) + " nanosec");
                      }
                      if ((paintCount % 100) == 0) {
                          System.out.println("Average image paint time on " + paintCount + " paints = " + (paintTime / paintCount) + " nanosec");
                      }
                  }
              };

              Dimension Size = new Dimension(500, 500);
              PaintPanel.setPreferredSize(Size);
              PaintPanel.setMinimumSize(Size);
              PaintPanel.setMaximumSize(Size);

              VwZmSlider = new JSlider(0, 100, 50);
              VwZmSlider.addChangeListener(new ChangeListener() {
                  public void stateChanged(ChangeEvent changeEvent) {
                      int val = VwZmSlider.getValue();
                      switch (val) {
                          case 0:
                              setZoom(0.1);
                              break;

                          case 15:
                              setZoom(0.5);
                              break;

                          case 30:
                              setZoom(0.75);
                              break;

                          case 50:
                              setZoom(1.0);
                              break;

                          case 70:
                              setZoom(1.5);
                              break;

                          case 85:
                              setZoom(2.0);
                              break;

                          case 100:
                              setZoom(3.0);
                              break;

                          default:
                              if (val > 0 && val < 15) {
                                  setZoom(((0.39 / 14.0) * (val - 1)) + 0.1);
                              } else if (val > 15 && val < 30) {
                                  setZoom(((0.24 / 14.0) * (val - 15)) + 0.5);
                              } else if (val > 30 && val < 50) {
                                  setZoom(((0.24 / 19.0) * (val - 30)) + 0.75);
                              } else if (val > 50 && val < 70) {
                                  setZoom(((0.49 / 19.0) * (val - 50)) + 1.0);
                              } else if (val > 70 && val < 85) {
                                  setZoom(((0.49 / 14.0) * (val - 70)) + 1.5);
                              } else {
                                  setZoom(((0.99 / 14.0) * (val - 85)) + 2.0);
                              }
                              break;
                      }
                      PaintPanel.repaint();
                  }
              });

              JPanel FillPanel = new JPanel();
              FillPanel.setLayout(new BorderLayout());

              FillPanel.add(PaintPanel, BorderLayout.CENTER);
              FillPanel.add(VwZmSlider, BorderLayout.SOUTH);

              getContentPane().add(FillPanel);
              pack();
              show();
          }

          public static void main(String[] args) {
              new ImageTest();
          }
      }

      ---------- END SOURCE ----------

      Release Regression From : 6u6
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tdv Dmitri Trembovetski (Inactive)
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: