I added a switch per system property for globally disabling double
buffering for Swing. This might be useful for debugging and (ATM) can
only be achieved by actually calling
RepaintManager.setDoubleBufferedEnabled(false), which means you have to
modify your application code.
2006-11-14 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/RepaintManager.java
(RepaintManager): Fetch the default state for the double buffering
from a system property gnu.swing.doublebuffering.
/Roman
Index: javax/swing/RepaintManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/RepaintManager.java,v
retrieving revision 1.47
diff -u -1 -5 -r1.47 RepaintManager.java
--- javax/swing/RepaintManager.java 18 Oct 2006 10:01:30 -0000 1.47
+++ javax/swing/RepaintManager.java 14 Nov 2006 10:33:46 -0000
@@ -26,50 +26,53 @@
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing;
+import gnu.classpath.SystemProperties;
import gnu.java.awt.LowPriorityEvent;
import java.applet.Applet;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.InvocationEvent;
import java.awt.image.VolatileImage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.WeakHashMap;
+import javax.swing.text.JTextComponent;
+
/**
* <p>The repaint manager holds a set of dirty regions, invalid components,
* and a double buffer surface. The dirty regions and invalid components
* are used to coalesce multiple revalidate() and repaint() calls in the
* component tree into larger groups to be refreshed "all at once"; the
* double buffer surface is used by root components to paint
* themselves.</p>
*
* <p>See <a
* href="http://java.sun.com/products/jfc/tsc/articles/painting/index.html">this
* document</a> for more details.</p>
* document</a> for more details.</p>
*
* @author Roman Kennke ([EMAIL PROTECTED])
* @author Graydon Hoare ([EMAIL PROTECTED])
@@ -249,31 +252,33 @@
* @see #setDoubleBufferMaximumSize
*/
private Dimension doubleBufferMaximumSize;
/**
* Create a new RepaintManager object.
*/
public RepaintManager()
{
dirtyComponents = new HashMap();
dirtyComponentsWork = new HashMap();
invalidComponents = new ArrayList();
repaintWorker = new RepaintWorker();
doubleBufferMaximumSize = new Dimension(2000,2000);
- doubleBufferingEnabled = true;
+ doubleBufferingEnabled =
+ SystemProperties.getProperty("gnu.swing.doublebuffering", "true")
+ .equals("true");
offscreenBuffers = new WeakHashMap();
}
/**
* Returns the <code>RepaintManager</code> for the current thread's
* thread group. The default implementation ignores the
* <code>component</code> parameter and returns the same repaint manager
* for all components.
*
* @param component a component to look up the manager of
*
* @return the current repaint manager for the calling thread's thread group
* and the specified component
*
* @see #setCurrentManager
@@ -414,31 +419,30 @@
* @param y The top y coordinate of the new dirty region
* @param w The width of the new dirty region
* @param h The height of the new dirty region
*
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
public void addDirtyRegion(JComponent component, int x, int y,
int w, int h)
{
if (w <= 0 || h <= 0 || !component.isShowing())
return;
-
component.computeVisibleRect(rectCache);
SwingUtilities.computeIntersection(x, y, w, h, rectCache);
if (! rectCache.isEmpty())
{
synchronized (dirtyComponents)
{
Rectangle dirtyRect = (Rectangle)dirtyComponents.get(component);
if (dirtyRect != null)
{
SwingUtilities.computeUnion(rectCache.x, rectCache.y,
rectCache.width, rectCache.height,
dirtyRect);
}
else