JDK-4492472 : Remote X: Java2D runs slower on JDK 1.4 relative to JDK 1.3.1
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-08-15
  • Updated: 2001-08-15
  • Resolved: 2001-08-15
Related Reports
Duplicate :  
Description

Name: ddT132432			Date: 08/15/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)
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.3.1-FCS)
Java HotSpot(TM) Client VM (build Blackdown-1.3.1-FCS, mixed mode)
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)



Testing some simple Java 2D drawing operations on Solaris Sparc 2.6 and
RedHat7.1 with Java1.3 and the Java 1.4 beta, there is a 20 to 50 fold speed
increase in the time taken for paintComponent() method when using the 1.4 Beta.
The timer is built into the paintComponent method and prints to stderr. The 1.4
slowdown effect is clear and consistent in both Solaris and RedHat. The graphics
are being drawn across the network using an X server running on a Windows NT
box. Neither box has a significant load and the JVM only uses 3% of available
CPU when running the JDK 1.4 JVM. Java options -client -server have no effect.
Any JPEG image can replace the tramlines picture I was using.

I wrote the code below using a code example from an OReilly book.

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import java.util.Timer;
import java.util.TimerTask;

public class Burrito extends JComponent {
	private Image image;
	private int theta;
	private boolean clockwise;
	final static int ROTATION_ANGLE = 1; // 1 degree
	Timer timer = new Timer();

	public Burrito() {
		image =
  Toolkit.getDefaultToolkit().getImage("/home/parsons/public_html/photos/picture_pages/Heidelberg_2001/Abstract_Tramlines_and_Girl@Hotel_Denner.JPG");
		theta = 0;
		timer.schedule(animationTask, 0, 40);
		addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent me) {
				// System.err.println("DEBUG " + me);
				clockwise = ((me.getModifiers() & InputEvent.ALT_MASK) != 0);
				}
			});
		this.setDoubleBuffered(false);
		}

	TimerTask animationTask = new TimerTask() {
		public void run() {
			int change;
			change = clockwise ? ROTATION_ANGLE : (0 - ROTATION_ANGLE);
			theta = (theta + change) % 360;
			repaint();
			}
		};

	public void paintComponent(Graphics graph){
		Graphics2D graph2 = (Graphics2D)graph;
		long startTime = System.currentTimeMillis();
		
		graph2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

		int cx = getSize().width / 2;
		int cy = getSize().height / 2;

		graph2.translate(cx, cy);
		graph2.rotate(theta * Math.PI / 180);

		Shape oldClip = graph2.getClip();
		Shape ellipse = new Ellipse2D.Float(-cx, -cy, cx * 2, cy * 2);
		// graph2.clip(ellipse);

		Shape circle = new Ellipse2D.Float(-cx, -cy, cx * 3 / 4, cy * 2);
		graph2.setPaint(new GradientPaint(40, 40, Color.blue, 60, 50, Color.white,true));
		graph2.fill(circle);

		graph2.setPaint(Color.yellow);
		graph2.fillOval(cx / 4, 0, cx, cy);

		//graph2.setClip(oldClip);
		graph2.setFont(new Font("Times New Roman", Font.PLAIN, 64));
		graph2.setPaint(new GradientPaint(-cx, 0, Color.red, cx, 0, Color.black,false));
		graph2.drawString("Hello, 2D!", -cx *3 / 4, cy / 4);

		AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,(float).75);
		graph2.setComposite(ac);
		
		Shape rr = new RoundRectangle2D.Float(0, -cy * 3 / 4, cx * 3 / 4, cy * 3 / 4,20, 20);
		graph2.setStroke(new BasicStroke(4));
		graph2.setPaint(Color.magenta);
		graph2.fill(rr);
	
		graph2.drawImage(image,  -cx / 4, -cy / 4, this);
		System.err.println("DEBUG Time= " + (System.currentTimeMillis() - startTime));
		}

	public static void main (String[] args) {
		JFrame frame = new JFrame("Burrito");
		Container container = frame.getContentPane();
		container.setLayout(new BorderLayout());
		container.add(new Burrito(), BorderLayout.CENTER);
		frame.setSize(500,500);
		frame.setLocation(200, 200);
		frame.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent wevent){
				System.exit(0);
				}
			});
		frame.setVisible(true);
		}
}
(Review ID: 130079) 
======================================================================

Comments
EVALUATION This is a duplicate of 4488401 ColorChooser demo of swingset2 does not refresh well with remote display ###@###.### 2001-08-15
15-08-2001

WORK AROUND Turn off remote offscreen acceleration: -Dsun.java2d.pmoffscreen=false Note that this will improve 2D rendering (compositing, antialiasing), but will slow down opaque copies from the backbuffer to the screen. ###@###.### 2001-08-15
15-08-2001