United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4933804 : X11 colormap is created for each accelerated 24-bit offscreen image

Details
Type:
Bug
Submit Date:
2003-10-07
Status:
Resolved
Updated Date:
2004-01-15
Project Name:
JDK
Resolved Date:
2003-10-27
Component:
client-libs
OS:
solaris_9,solaris_8
Sub-Component:
2d
CPU:
sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
solaris_8u6,1.4.0
Fixed Versions:
1.4.2_04 (04)

Related Reports
Backport:

Sub Tasks

Description
We're supposed to create a X11 colormap per graphics config (which means,
per visual), but we create them on each X11PixmapSurfaceData 
creation if the associated visual is a non-default 24-bit visual.
My testing configuration: SB2000 + XVR-600.

This could cause problems for certain applications which create
tons of images, because we never free the colormaps.

One can use the following command to observe the creation of 
color maps:
truss -t\!all -ulibX11::XCreateColormap,XFreeColormap java Test

The test creates accelerated offscreen images on each repaint, 
and new colormaps will be allocated for each of those images.

Here's the test case:
------- Test.java --------
import java.awt.*;

public class Test {
    static int x = 100, y = 10;
    public Test() {
	GraphicsEnvironment ge = 
	    GraphicsEnvironment.getLocalGraphicsEnvironment();
	GraphicsConfiguration gc[] = 
	    ge.getDefaultScreenDevice().getConfigurations();
	for (int i = 0; i < gc.length; i++) {
	    System.err.println("gc["+i+"]="+gc[i]);
	    if (gc[i].getColorModel().getPixelSize() == 24) {
		Frame f = new Frame(gc[i].toString(), gc[i]) {
		    public void paint(Graphics g) {
			Image im;
			System.err.println("Creating images with gc=" + 
					   getGraphicsConfiguration());
			for (int j = 0; j < 5; j++) {
			    im = createImage(100,100);
			    Graphics gim = im.getGraphics();
			    gim.setColor(Color.red);
			    gim.fillRect(0,0, im.getWidth(null), 
					 im.getHeight(null));
			    g.drawImage(im, 0,0, null);
			}
			Toolkit.getDefaultToolkit().sync();
			System.err.println("Done creating images");
		    }
		};
		f.pack();
		f.setBackground(Color.green);
		f.setLocation(x, y);
		f.setSize(300,100);
		x += f.getWidth();
		if (x + f.getWidth() > 1280) {
		    x = 100;
		    y += f.getHeight();
		}
		f.setVisible(true);
	    }
	}
    }

    public static void main(String argv[]) {
	System.setProperty("sun.java2d.pmoffscreen", "true");
	new Test();
    }
}

------- Test.java --------

###@###.### 2003-10-06

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
1.4.2_04
generic
tiger-beta

FIXED IN:
1.4.2_04
tiger-beta

INTEGRATED IN:
1.4.2_04
tiger-b26
tiger-beta


                                     
2004-06-14
SUGGESTED FIX

http://javaweb.sfbay/jcg/1.5.0-tiger/2D/4933804

###@###.### 2003-10-15
                                     
2003-10-15
EVALUATION

We should call awtJNI_CreateColorData in Java_sun_awt_X11SurfaceData_initSurface
only for if awt_cmap is not initialized. It should be initialized in 
awtJNI_CreateColorData for 8-bit visuals.

###@###.### 2003-10-14
                                     
2003-10-14
WORK AROUND

Disable pixmaps:
  -Dsun.java2d.pmoffscreen=false

###@###.### 2003-10-07
                                     
2003-10-07



Hardware and Software, Engineered to Work Together