src/share/classes/javax/swing/RepaintManager.java

Print this page

        

*** 117,126 **** --- 117,131 ---- private static final Object repaintManagerKey = RepaintManager.class; // Whether or not a VolatileImage should be used for double-buffered painting static boolean volatileImageBufferEnabled = true; /** + * Type of VolatileImage which should be used for double-buffered + * painting. + */ + private static final int doubleBufferType; + /** * Value of the system property awt.nativeDoubleBuffering. */ private static boolean nativeDoubleBuffering; // The maximum number of times Swing will attempt to use the VolatileImage
*** 202,211 **** --- 207,223 ---- getLocalGraphicsEnvironment(); if (ge instanceof SunGraphicsEnvironment) { ((SunGraphicsEnvironment)ge).addDisplayChangedListener( new DisplayChangedHandler()); } + Toolkit tk = Toolkit.getDefaultToolkit(); + if ((tk instanceof SunToolkit) + && ((SunToolkit) tk).isSwingBackbufferTranslucencySupported()) { + doubleBufferType = Transparency.TRANSLUCENT; + } else { + doubleBufferType = Transparency.OPAQUE; + } } /** * Return the RepaintManager for the calling thread given a Component. *
*** 987,997 **** if (image == null || image.getWidth() < width || image.getHeight() < height) { if (image != null) { image.flush(); } ! image = config.createCompatibleVolatileImage(width, height); volatileMap.put(config, image); } return image; } --- 999,1010 ---- if (image == null || image.getWidth() < width || image.getHeight() < height) { if (image != null) { image.flush(); } ! image = config.createCompatibleVolatileImage(width, height, ! doubleBufferType); volatileMap.put(config, image); } return image; }
*** 1481,1493 **** --- 1494,1521 ---- try { for(x = clipX, maxx = clipX+clipW; x < maxx ; x += bw ) { for(y=clipY, maxy = clipY + clipH; y < maxy ; y += bh) { osg.translate(-x, -y); osg.setClip(x,y,bw,bh); + if (doubleBufferType != Transparency.OPAQUE + && osg instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) osg.create(); + g2d.setBackground(c.getBackground()); + g2d.clearRect(x, y, bw, bh); + g2d.dispose(); + } c.paintToOffscreen(osg, x, y, bw, bh, maxx, maxy); g.setClip(x, y, bw, bh); + if (doubleBufferType != Transparency.OPAQUE + && osg instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setComposite(AlphaComposite.Src); + g2d.drawImage(image, x, y, c); + g2d.dispose(); + } else { g.drawImage(image, x, y, c); + } osg.translate(x, y); } } } finally { osg.dispose();