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

X11 colormap is created for each accelerated 24-bit offscreen image

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2_04
    • solaris_8u6, 1.4.0
    • client-libs
    • 2d
    • 04
    • generic, sparc
    • solaris_8, solaris_9

        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

              tdv Dmitri Trembovetski (Inactive)
              tdv Dmitri Trembovetski (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: