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

D3D: Remarkable performance loss in update 10>

    XMLWordPrintable

Details

    • 2d
    • x86
    • windows_vista

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_12-ea"
      Java(TM) SE Runtime Environment (build 1.6.0_12-ea-b02)
      Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [versie 6.0.6001]
      (Dutch)

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      ATI Mobile video card

      A DESCRIPTION OF THE PROBLEM :
      I have found a performance loss since I upgraded to 1.6.0_10.

      I have written a user control to display a level from an old DOS game. As you might imagine this contains a lot of pixel art. Then I put this user control inside of a JScrollPane so the end user can easily browse through the level.

      However, scrolling speed has drastically decreased in 1.6.0_10 and later. (including 1.6.0_12 dev)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a new user control, extending JPanel and make it big
      2. Create a big array of BufferedImages
      3. Fill them with complicated pixel data, also containing transparency
      4. Override the paintComponent method of the user control
      5. Fill the user control with the generated images and transparency
      6. Place the control in a JScrollPane

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      In JRE 1.6.0_07 (and earlier 1.6.0 versions) scrolling is extremely smooth. I have also tried OpenJDK on a Linux box (I know I shouldn't compare...) which does not seem to have this problem.
      ACTUAL -
      Scrolling performance is bad (or perhaps I am spoiled), you can see the scrollbar skipping large parts of the user control as you pull it down.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.image.*;
      import java.util.*;

      // I just quickly threw this together, sorry if its a mess
      public class TestFrame extends JFrame {
      public TestFrame() {
      super("Test frame");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLayout(new BorderLayout());
      setSize(800,600);
      addWidgets();
      setVisible(true);
      }
      private void addWidgets() {
      CustomControl c = new CustomControl();
      add(new JScrollPane(c), BorderLayout.CENTER);
      }
      public static void main(String[] args) {
      new TestFrame();
      }
      }

      class CustomControl extends JPanel {
      private BufferedImage[] blocks;
      private int[][] map;
      private Random rand;
      // You might have to fiddle around with these to see the problem
      private final static int
      WIDTH = 250,
      HEIGHT = 200,
      BLOCK = 32,
      BLOCK_LENGTH = BLOCK * BLOCK,
      PIXEL_WIDTH = WIDTH * BLOCK,
      PIXEL_HEIGHT = HEIGHT * BLOCK;
      public CustomControl() {
      blocks = new BufferedImage[500];
      map = new int[WIDTH][HEIGHT];
      setSize(getPreferredSize());
      generateBlocks();
      }
      public void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.setColor(Color.WHITE);
      g.fillRect(0, 0, PIXEL_WIDTH, PIXEL_HEIGHT);
      for (int x = 0; x < WIDTH; x++)
      for (int y = 0; y < HEIGHT; y++)
      g.drawImage(blocks[map[x][y]], x * BLOCK, y * BLOCK, null);
      }
      public Dimension getPreferredSize() {
      return new Dimension(PIXEL_WIDTH, PIXEL_HEIGHT);
      }
      private void generateBlocks() {
      rand = new Random();
      IndexColorModel cm = createColorModel();
      for (int i = 0; i < 500; i++) {
      blocks[i] = new BufferedImage(BLOCK, BLOCK, BufferedImage.TYPE_BYTE_INDEXED, cm);
      int[] values = new int[BLOCK_LENGTH];
      if (rand.nextBoolean()) {
      for (int c = 0; c < BLOCK_LENGTH; c++)
      if (rand.nextBoolean())
      values[c] = 0;
      else
      values[c] = rand.nextInt();
      WritableRaster wr = blocks[i].getRaster();
      wr.setPixels(0, 0, 32, 32, values);
      }
      }
      for (int x = 0; x < WIDTH; x++)
      for (int y = 0; y < HEIGHT; y++)
      map[x][y] = rand.nextInt(500);
      }
      private IndexColorModel createColorModel() {
      byte[] r = new byte[256];
      byte[] g = new byte[256];
      byte[] b = new byte[256];
      for (int i = 1; i < 256; i++) {
      r[i] = (byte)rand.nextInt();
      g[i] = (byte)rand.nextInt();
      b[i] = (byte)rand.nextInt();
      }
      return new IndexColorModel(8, 256,r ,g , b, 0);
      }
      }

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

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: