JDK-4464553 : Image zooming of INT_ARGB_PRE images slower on JDK1.4beta than JDK1.3
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-05-31
  • Updated: 2013-11-01
  • Resolved: 2005-03-23
Related Reports
Duplicate :  
Description

Name: bsC130419			Date: 05/31/2001


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


I did a new standalone test of image scaling with the new JDK1.4beta and was
sad to see it slower than JDK1.3.  The program that generates the following
numbers is below.  It uses a BufferedImage.TYPE_INT_ARGB_PRE (the fastest one I
found).  I also tried it on TYPE_INT_ARGB.  I'm running on an IBM T21 ThinkPad
with Windows 2000.  The bottom line is that JDK1.3 is about 30% faster for
ARGB_PRE and about 10% faster for ARGB.

This is a crucial problem since my entire project revolves around animated
zooming of images and other graphics.  See the Open Source Jazz toolkit to
understand why it is important at
http://www.cs.umd.edu/hcil/jazz

Timing results:

JDK1.3 - TYPE_INT_ARGB
----------------------
$ java ZoomImage
total time = 2854, 142 ms/frame, 7 fps
total time = 2694, 134 ms/frame, 7 fps
total time = 2663, 133 ms/frame, 7 fps
total time = 2654, 132 ms/frame, 7 fps
total time = 2633, 131 ms/frame, 7 fps
total time = 2644, 132 ms/frame, 7 fps

JDK1.4beta - TYPE_INT_ARGB
--------------------------
$ /jdk1.4b/bin/java ZoomImage
total time = 3104, 155 ms/frame, 6 fps
total time = 2954, 147 ms/frame, 6 fps
total time = 2924, 146 ms/frame, 6 fps
total time = 2914, 145 ms/frame, 6 fps
total time = 2894, 144 ms/frame, 6 fps
total time = 2895, 144 ms/frame, 6 fps

JDK1.3 - TYPE_INT_ARGB_PRE
--------------------------
$ java ZoomImage
total time = 2844, 142 ms/frame, 7 fps
total time = 2674, 133 ms/frame, 7 fps
total time = 2633, 131 ms/frame, 7 fps
total time = 2624, 131 ms/frame, 7 fps
total time = 2614, 130 ms/frame, 7 fps

JDK1.4beta - TYPE_INT_ARGB_PRE
------------------------------
$ /jdk1.4b/bin/java ZoomImage
total time = 4176, 208 ms/frame, 4 fps
total time = 3945, 197 ms/frame, 5 fps
total time = 3906, 195 ms/frame, 5 fps
total time = 3895, 194 ms/frame, 5 fps
total time = 3896, 194 ms/frame, 5 fps

Test program
===============

import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;

public class ZoomImage extends JFrame {
    int width = 800;
    int height = 800;

    public ZoomImage() {
	setBounds(100, 100, width, height);
	setVisible(true);
	Component comp = new ZoomImageComponent();
	comp.setBounds(0, 0, width, height);
	getContentPane().add(comp);

	addWindowListener(new WindowAdapter() {
	    public void windowClosing(WindowEvent e) {
		System.exit(0);
	    }
	});
    }

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

class ZoomImageComponent extends JComponent {
    float mag = 1.0f;
    float magStep = 1.01f;
    int i = 0;
    int iw = 800;
    int ih = 800;
    BufferedImage image = null;
    int imageType = BufferedImage.TYPE_INT_ARGB_PRE;

    public ZoomImageComponent() {
	createImage();

	addMouseListener(new MouseAdapter() {
	    public void mousePressed(MouseEvent e) {
		if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) ==
MouseEvent.BUTTON1_MASK) {   // Left button only
		    magStep = 1.02f;
		} else {
		    magStep = 0.98f;
		}

		long startTime = System.currentTimeMillis();
		int frames = 20;
		for (i=0; i<frames; i++) {
		    mag *= magStep;
		    repaint();
		    RepaintManager.currentManager
(ZoomImageComponent.this).paintDirtyRegions();
		}
		long endTime = System.currentTimeMillis();
		long dt = (endTime - startTime);
		System.out.println("total time = " + dt + ", " + dt / frames
+ " ms/frame, " + (frames * 1000 / dt)  + " fps");
	    }
	});
    }

    public void paintComponent(Graphics g) {
	Graphics2D g2 = (Graphics2D)g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
	g2.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_SPEED);
	AffineTransform at1 = AffineTransform.getTranslateInstance(0.0f, 0.0f);
	AffineTransform at2 = AffineTransform.getScaleInstance(mag, mag);
	g2.setTransform(at1);
	g2.transform(at2);

	g2.drawImage(image, 0, 0, this);
    }

    void createImage() {
        image = new BufferedImage(iw, ih, imageType);

        for (int i = 2; i < iw; i +=3) {
            for (int j = 2; j < ih; j +=3) {
                image.setRGB(i, j, java.awt.Color.red.getRGB());
                image.setRGB(i-1, j, java.awt.Color.blue.getRGB());
                image.setRGB(i+1, j, java.awt.Color.green.getRGB());
                image.setRGB(i, j-1, java.awt.Color.yellow.getRGB());
                image.setRGB(i, j+1, java.awt.Color.black.getRGB());
                image.setRGB(i-1, j+1, java.awt.Color.white.getRGB());
                image.setRGB(i+1, j+1, java.awt.Color.white.getRGB());
                image.setRGB(i-1, j-1, java.awt.Color.white.getRGB());
                image.setRGB(i+1, j-1, java.awt.Color.white.getRGB());
            }
        }
    }
}
(Review ID: 125171) 
======================================================================


ingrid.yao@Eng 2001-06-14

It is even worse on JDK1.3.1 for both TYPE_INT_ARG and TYPE_INT_ARG_PRE

E:\CAP\bug\umd>c:\jdk1.3.1\bin\java ZoomImagePRE
total time = 4347, 217 ms/frame, 4 fps
total time = 4116, 205 ms/frame, 4 fps
total time = 4086, 204 ms/frame, 4 fps
total time = 4076, 203 ms/frame, 4 fps
total time = 4056, 202 ms/frame, 4 fps
total time = 4045, 202 ms/frame, 4 fps
total time = 4056, 202 ms/frame, 4 fps


E:\CAP\bug\umd>c:\jdk1.3.1\bin\java ZoomImage
total time = 4246, 212 ms/frame, 4 fps
total time = 4086, 204 ms/frame, 4 fps
total time = 4056, 202 ms/frame, 4 fps
total time = 4026, 201 ms/frame, 4 fps
total time = 4156, 207 ms/frame, 4 fps
total time = 4026, 201 ms/frame, 4 fps
total time = 4026, 201 ms/frame, 4 fps

Comments
EVALUATION A preliminary investigation shows that we are missing type-specific compositing loops for ARGB_PRE sources onto most kinds of destination surface types. If the test is modified to use INT_ARGB instead then the test does run faster on 1.4 than 1.3 on Windows. Also, I should point out that we have not yet addressed the "intermediate buffer" performance issue for scaled images in 1.4. We have rearchitected the framework to provide a place to solve that problem, but that task remains on our "TODO" list at this time. jim.graham@Eng 2001-05-31 With the new image transformation code in 1.6 the test case is now more than 4x as fast as any previous release for INT_ARGB_PRE images and 2.5 to 3x as fast as any previous release for INT_ARGB images. I will be closing this bug as a dup of the bug under which the faster image transformation pipeline was developed. ###@###.### 2005-03-23 08:45:24 GMT
23-03-2005

WORK AROUND Name: bsC130419 Date: 05/31/2001 use JDK1.3 ======================================================================
11-06-2004