This fixes two issues with the Swing painting:
1. As reported in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27185, an
optimization in JComponent.paintChildrenOptimized() didn't work quite
right. Looking at it, it seems that this optimization doesn't gain much
anyway, possibly the overhead of calculating away things eats up all the
optimization. I removed this bit as it seemed to cause problems.
2. In JComponent.paintChildrenWithOverlap() we need to propagate the
dirty rectangles to the next child component, when the component was not
opaque, so that the next child gets painted correctly.

2006-04-18  Roman Kennke  <[EMAIL PROTECTED]>

        PR 27185
        * javax/swing/JComponent.java
        (paintChildrenWithOverlap): When one child is not opaque,
propagate
        the dirty rectangles to the next child.
        (paintChildrenOptimized): Removed unnecessary 'optimization'.
        This actually didn't work right and probably gained nothing.

/Roman

-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.114
diff -u -1 -0 -r1.114 JComponent.java
--- javax/swing/JComponent.java	6 Apr 2006 10:15:34 -0000	1.114
+++ javax/swing/JComponent.java	18 Apr 2006 09:10:48 -0000
@@ -1929,20 +1929,26 @@
                     x = compBounds.x + compBounds.width;
                     y = r.y;
                     w = r.width - (compBounds.x - r.x) - compBounds.width;
                     h = r.height;
                     rect.setBounds(x, y, w, h);
                     if (! rect.isEmpty())
                       {
                         newPaintRects.add(rect);
                       }
                   }
+                else
+                  {
+                    // Not opaque, need to reuse the current paint rectangles
+                    // for the next component.
+                    newPaintRects.add(r);
+                  }
                 
               }
             else
               {
                 newPaintRects.add(r);
               }
           }
 
         // Replace the paintRectangles with the new split up
         // paintRectangles.
@@ -2017,48 +2023,24 @@
    *
    * @param g the graphics context to use
    */
   private void paintChildrenOptimized(Graphics g)
   {
     Shape originalClip = g.getClip();
     Rectangle inner = SwingUtilities.calculateInnerArea(this, rectCache);
     g.clipRect(inner.x, inner.y, inner.width, inner.height);
     Component[] children = getComponents();
 
-    // Find the bottommost component that needs to be painted. This is the
-    // component that - together with the rectangles of the components that
-    // are painted above it - covers the whole clip area.
-    Rectangle rect = new Rectangle();
-    int startIndex = children.length - 1;
-    for (int i = 0; i < children.length; i++)
-      {
-        Rectangle b = children[i].getBounds();
-        if (children[i].isOpaque() && children[i].isVisible()
-            && g.hitClip(b.x, b.y, b.width, b.height))
-          {
-            if (rect.isEmpty())
-              rect.setBounds(b);
-            else
-              SwingUtilities.computeUnion(b.x, b.y, b.width, b.height, rect);
-
-            if (SwingUtilities.isRectangleContainingRectangle(rect, inner))
-              {
-                startIndex = i;
-                break;
-              }
-          }
-      }
-
     // paintingTile becomes true just before we start painting the component's
     // children.
     paintingTile = true;
-    for (int i = startIndex; i >= 0; i--) //children.length; i++)
+    for (int i = children.length - 1; i >= 0; i--) //children.length; i++)
       {
         // paintingTile must be set to false before we begin to start painting
         // the last tile.
         if (i == children.length - 1)
           paintingTile = false;
 
         if (!children[i].isVisible())
           continue;
 
         Rectangle bounds = children[i].getBounds(rectCache);

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to