Hi, I'm checking this in on behalf of Ingo Prötel. Basically this makes Container.visitChild more safe by protecting the Graphics context from beeing irrevocably changed by the child component. This is similar to what we do in Swing's painting mechanism and it actually does matter a little even in Swing when the painting is triggered by the AWT, because then the painting first goes through the Container painting, before jumping into the Swing painting mechanism.
(I'll check in an optimization for GtkGraphics.create() soon which will dramatically reduce creation of Graphics objects while painting (from O(n^2) to O(n) with n beeing the depth of the component hierarchy), so the performance overhead for Graphics.create() gets minimized.) Cheers, Roman
Index: java/awt/Container.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/Container.java,v
retrieving revision 1.73
diff -u -r1.73 Container.java
--- java/awt/Container.java 6 Dec 2005 19:27:53 -0000 1.73
+++ java/awt/Container.java 14 Dec 2005 17:34:33 -0000
@@ -1634,30 +1634,19 @@
Component comp)
{
Rectangle bounds = comp.getBounds();
- Rectangle oldClip = gfx.getClipBounds();
- if (oldClip == null)
- oldClip = bounds;
- Rectangle clip = oldClip.intersection(bounds);
-
- if (clip.isEmpty()) return;
+ if(!gfx.hitClip(bounds.x,bounds.y, bounds.width, bounds.height))
+ return;
- boolean clipped = false;
- boolean translated = false;
+ Graphics g2 = gfx.create(bounds.x, bounds.y, bounds.width,
+ bounds.height);
try
{
- gfx.setClip(clip.x, clip.y, clip.width, clip.height);
- clipped = true;
- gfx.translate(bounds.x, bounds.y);
- translated = true;
- visitor.visit(comp, gfx);
+ visitor.visit(comp, g2);
}
finally
{
- if (translated)
- gfx.translate (-bounds.x, -bounds.y);
- if (clipped)
- gfx.setClip (oldClip.x, oldClip.y, oldClip.width, oldClip.height);
+ g2.dispose();
}
}
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ Classpath-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath-patches
