In the RepaintManager we are using the Graphics.drawImage() method, that takes 11 parameters to paint a part of the buffer to a part of the screen. Looking at the native code this seems rather inefficient (there are 1-2 temporary images created there, a scaling is performed etc, which is all unnecessary). I replaced this by the simple 4-argument drawImage() call and let the clipping sort out the rest.
2006-03-27 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/RepaintManager.java
(commitBuffer): Use simple drawImage() method instead of the
scaling version.
/Roman
--
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/RepaintManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/RepaintManager.java,v
retrieving revision 1.28
diff -u -1 -0 -r1.28 RepaintManager.java
--- javax/swing/RepaintManager.java 3 Mar 2006 10:06:10 -0000 1.28
+++ javax/swing/RepaintManager.java 27 Mar 2006 14:54:08 -0000
@@ -36,21 +36,20 @@
exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
-import java.awt.Window;
import java.awt.image.VolatileImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
@@ -407,21 +406,20 @@
* @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())
{
if (dirtyComponents.containsKey(component))
{
SwingUtilities.computeUnion(rectCache.x, rectCache.y,
rectCache.width, rectCache.height,
(Rectangle) dirtyComponents.get(component));
@@ -656,22 +654,21 @@
// when a component is inside a JViewport, and the component has
// a size that would reach beyond the window size.
// 2. Graphics.drawImage() should not behave strange when trying
// to draw regions outside the image.
int bufferWidth = buffer.getWidth(root);
int bufferHeight = buffer.getHeight(root);
dx1 = Math.min(bufferWidth, dx1);
dy1 = Math.min(bufferHeight, dy1);
dx2 = Math.min(bufferWidth, dx2);
dy2 = Math.min(bufferHeight, dy2);
- g.drawImage(buffer, dx1, dy1, dx2, dy2,
- dx1, dy1, dx2, dy2, root);
+ g.drawImage(buffer, 0, 0, root);
g.dispose();
}
// Otherwise queue this request up, until all the RepaintManager work
// is done.
else
{
if (commitRequests.containsKey(root))
SwingUtilities.computeUnion(area.x, area.y, area.width,
area.height,
(Rectangle) commitRequests.get(root));
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
