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

In Jdk1.2 (Java 2 platform), getGraphics() is dramatically slow.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • client-libs
    • 2d
    • beta
    • generic, x86
    • generic, windows_nt



      Name: vi73552 Date: 03/17/99


      I attach a simple Java test program used to test the speed of
      graphics. The program uses awt1.1 features only, ie, no java2D
      or swing.
      Running the program on jdk1.1.7 is very fast, no problem there.
      running the *same* program on jdk1.2 slows down by a factor of
      about 10.
      I have tried to compile it with jdk1.2, with -O flag on, no
      effect. The same slowdown was valid on an WindowsNT platform,
      as well as on Solaris.

      import java.awt.*;
      import java.awt.image.*;
      import java.util.*;
      //repeatedly draw a square to a canvas
      class Test2 extends Frame {

      public static void main(String[] args) {
      Test2 f = new Test2();
      f.resize (400, 400);
      f.show();
      f.draw();
      System.exit(1);
      }

      public void draw() {
      int k;
      x[0] = 30;
      x[1] = 60;
      x[2] = 60;
      x[3] = 30;
      x[4] = 30;

      y[0] = 30;
      y[1] = 30;
      y[2] = 60;
      y[3] = 60;
      y[4] = 30;
      Color c ;
      for (i = 0; i < 10; i++){
      c = Color.red;
      for (j = 0; j < 200; j++) {
      for (k = 0; k <= 4; k++ ) {
      x[k] = x[k] + 1;
      y[k] = y[k] + 1;
      MyRepaint(c);
      }
      }
      c = Color.blue;
      for (j = 0; j < 200; j++) {
      for (k = 0; k <= 4; k++ ) {
      x[k] = x[k] - 1;
      y[k] = y[k] - 1;
      MyRepaint(c);
      }
      }
      }
      }

      public void update (Graphics g) {
      paint (g);
      }

      public void MyRepaint(Color c) {
      Graphics Gr;
      Gr = this.getGraphics();
      Gr.setColor (c);
      paint (Gr);
      }


      public void paint (Graphics g) {
      g.fillPolygon(x, y, 5);
      }

      public int x[] = new int[5];
      public int y[] = new int[5];
      public int i = 0;
      public int j = 0;
      }
      (Review ID: 55469)
      ======================================================================

      Name: skT88420 Date: 05/07/99


      as I wrote You on 24.03.99, there is a perfomrance bug with
      JDK 1.2, even with the JIT-update 3.10.100 !!!
      We isolated it and found that it occurs, when drawing to an Image
      (via a Graphics-Object for offscreen-double-buffering).

      To grpOffScreen.fillRect( x, y, SIZEX, SIZEY) 1'000'000-times
      JDK 1.2 2800 ms
      JDK 1.1.6 640 ms
      MS JVM 5.00.3165 1700 ms

      This is very bad, because some JDK 1.1 software uses double-buffering
      for optimizing AWT-drawing !!!
      (Review ID: 57944)
      ======================================================================

            flar Jim Graham
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: