This fixes a couple of issues in the X peers. See below.

2007-07-13  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/awt/java2d/AbstractGraphics2D.java
        (clip(Shape)): Call setClip when the clip changes.
        (drawImage): Add translation.
        (drawLine): Add translation.
        * gnu/java/awt/peer/x/PixmapVolatileImage.java
        (getPixmap): New method.
        * gnu/java/awt/peer/x/XEventPump.java
        (XEventPump): Name thread. Start as daemon thread.
        * gnu/java/awt/peer/x/XGraphics2D.java
        (rawDrawImage): Special handling for PixmapVolatileImage.
        (rawDrawLine): Don't add translation here. This is done in
        the superclass.
        (rawFillRect): Don't add translation here. This is done in
        the superclass.
        (renderScanline): Added null check.

/Roman
-- 
Dipl.-Inform. (FH) Roman Kennke, Software Engineer, http://kennke.org
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: gnu/java/awt/java2d/AbstractGraphics2D.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,v
retrieving revision 1.18
diff -u -1 -0 -r1.18 AbstractGraphics2D.java
--- gnu/java/awt/java2d/AbstractGraphics2D.java	24 May 2007 20:28:43 -0000	1.18
+++ gnu/java/awt/java2d/AbstractGraphics2D.java	16 Jul 2007 15:04:24 -0000
@@ -907,22 +907,22 @@
 
   /**
    * Intersects the clip of this graphics object with the specified clip.
    *
    * @param s the clip with which the current clip should be intersected
    */
   public void clip(Shape s)
   {
     // Initialize clip if not already present.
     if (clip == null)
-      clip = s;
-    
+      setClip(s);
+
     // This is so common, let's optimize this. 
     else if (clip instanceof Rectangle && s instanceof Rectangle)
       {
         Rectangle clipRect = (Rectangle) clip;
         Rectangle r = (Rectangle) s;
         computeIntersection(r.x, r.y, r.width, r.height, clipRect);
         // Call setClip so that subclasses get notified.
         setClip(clipRect);
       }
    else
@@ -1150,21 +1150,23 @@
   /**
    * Draws a line from (x1, y1) to (x2, y2).
    *
    * This implementation transforms the coordinates and forwards the call to
    * [EMAIL PROTECTED] #rawDrawLine}.
    */
   public void drawLine(int x1, int y1, int x2, int y2)
   {
     if (isOptimized)
       {
-        rawDrawLine(x1, y1, x2, y2);
+        int tx = (int) transform.getTranslateX();
+        int ty = (int) transform.getTranslateY();
+        rawDrawLine(x1 + tx, y1 + ty, x2 + tx, y2 + ty);
       }
     else
       {
         ShapeCache sc = getShapeCache();
         if (sc.line == null)
           sc.line = new Line2D.Float();
         sc.line.setLine(x1, y1, x2, y2);
         draw(sc.line);
       }
   }
@@ -1190,21 +1192,22 @@
    *
    * @param x the upper left corner, X coordinate
    * @param y the upper left corner, Y coordinate
    * @param width the width of the rectangle
    * @param height the height of the rectangle
    */
   public void fillRect(int x, int y, int width, int height)
   {
     if (isOptimized)
       {
-        rawFillRect(x, y, width, height);
+        rawFillRect(x + (int) transform.getTranslateX(),
+                    y + (int) transform.getTranslateY(), width, height);
       }
     else
       {
         ShapeCache sc = getShapeCache();
         if (sc.rect == null)
           sc.rect = new Rectangle();
         sc.rect.setBounds(x, y, width, height);
         fill(sc.rect);
       }
   }
@@ -1383,21 +1386,24 @@
    *
    * @param image the image to render
    * @param x the x location to render to
    * @param y the y location to render to
    * @param observer the image observer to receive notification
    */
   public boolean drawImage(Image image, int x, int y, ImageObserver observer)
   {
     boolean ret;
     if (isOptimized)
-      ret = rawDrawImage(image, x, y, observer);
+      {
+        ret = rawDrawImage(image, x + (int) transform.getTranslateX(),
+                           y + (int) transform.getTranslateY(), observer);
+      }
     else
       {
         AffineTransform t = new AffineTransform();
         t.translate(x, y);
         ret = drawImage(image, t, observer);
       }
     return ret;
   }
 
   /**
Index: gnu/java/awt/peer/x/PixmapVolatileImage.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/PixmapVolatileImage.java,v
retrieving revision 1.1
diff -u -1 -0 -r1.1 PixmapVolatileImage.java
--- gnu/java/awt/peer/x/PixmapVolatileImage.java	13 Jul 2007 19:43:44 -0000	1.1
+++ gnu/java/awt/peer/x/PixmapVolatileImage.java	16 Jul 2007 15:04:24 -0000
@@ -166,11 +166,20 @@
   {
     return null;
   }
 
   @Override
   public int getWidth(ImageObserver observer)
   {
     return getWidth();
   }
 
+  /**
+   * Returns the underlying X pixmap. This is used for the graphics code.
+   *
+   * @return the underlying X pixmap
+   */
+  Pixmap getPixmap()
+  {
+    return pixmap;
+  }
 }
Index: gnu/java/awt/peer/x/XEventPump.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XEventPump.java,v
retrieving revision 1.6
diff -u -1 -0 -r1.6 XEventPump.java
--- gnu/java/awt/peer/x/XEventPump.java	22 May 2007 22:25:14 -0000	1.6
+++ gnu/java/awt/peer/x/XEventPump.java	16 Jul 2007 15:04:24 -0000
@@ -90,22 +90,23 @@
   /**
    * Creates a new XEventPump for the specified X Display.
    *
    * @param d the X Display
    */
   XEventPump(Display d)
   {
     display = d;
     windows = new HashMap();
     drag = -1;
-    Thread t = new Thread(this);
-    t.start();
+    Thread thread = new Thread(this, "X Event Pump");
+    thread.setDaemon(true);
+    thread.start();
   }
 
   /**
    * The main event pump loop. This basically fetches events from the
    * X Display and pumps them into the system event queue.
    */
   public void run()
   {
     while (display.connected)
       {
Index: gnu/java/awt/peer/x/XGraphics2D.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XGraphics2D.java,v
retrieving revision 1.5
diff -u -1 -0 -r1.5 XGraphics2D.java
--- gnu/java/awt/peer/x/XGraphics2D.java	25 May 2007 11:11:14 -0000	1.5
+++ gnu/java/awt/peer/x/XGraphics2D.java	16 Jul 2007 15:04:24 -0000
@@ -87,29 +87,26 @@
     super();
     xdrawable = d;
     xgc = new GC(d);
     init();
     disposed = false;
     //setClip(new Rectangle(0, 0, xdrawable.width, xdrawable.height));
   }
 
   protected void rawDrawLine(int x0, int y0, int x1, int y1)
   {
-    int tx = (int) transform.getTranslateX();
-    int ty = (int) transform.getTranslateY();
-    xdrawable.segment(xgc, x0 + tx, y0 + ty, x1 + tx, y1 + ty);
+    xdrawable.segment(xgc, x0, y0, x1, y1);
   }
 
   protected void rawFillRect(int x, int y, int w, int h)
   {
-    xdrawable.rectangle(xgc, x + (int) transform.getTranslateX(),
-                             y + (int) transform.getTranslateY(), w, h, true);
+    xdrawable.rectangle(xgc, x, y, w, h, true);
   }
 
   /**
    * Returns the color model of this Graphics object.
    *
    * @return the color model of this Graphics object
    */
   protected ColorModel getColorModel()
   {
     return Toolkit.getDefaultToolkit().getColorModel();
@@ -245,21 +242,22 @@
                 red = 255 - (int) ((255 - red) * alpha);
                 green = 255 - (int) ((255 - green) * alpha);
                 blue = 255 - (int) ((255 - blue) * alpha);
               }
             xgc.set_foreground(red << 16 | green << 8 | blue);
             int x0 = range.getXPos();
             int l = range.getLength();
             xdrawable.fill_rectangle(xgc, x0, y, l, 1);
           }
       }
-    xgc.set_foreground(old.getRGB());
+    if (old != null)
+      xgc.set_foreground(old.getRGB());
   }
 
   protected void fillScanline(int x0, int x1, int y)
   {
     xdrawable.segment(xgc, x0, y, x1, y);
   }
 
   protected void fillScanlineAA(int x0, int x1, int y, int alpha)
   {
     //System.err.println("fillScanlineAA: " + x0 + ", " + x1 + ", " + y + ", " + alpha);
@@ -307,20 +305,27 @@
   protected boolean rawDrawImage(Image image, int x, int y, ImageObserver obs)
   {
     boolean ret;
     if (image instanceof XImage)
       {
         XImage xImage = (XImage) image;
         xdrawable.copy_area(xImage.pixmap, xgc, 0, 0, xImage.getWidth(obs),
                             xImage.getHeight(obs), x, y);
         ret = true;
       }
+    else if (image instanceof PixmapVolatileImage)
+      {
+        PixmapVolatileImage pvi = (PixmapVolatileImage) image;
+        xdrawable.copy_area(pvi.getPixmap(), xgc, 0, 0, pvi.getWidth(obs),
+                            pvi.getHeight(obs), x, y);
+        ret = true;
+      }
     else
       {
         ret = super.rawDrawImage(image, x, y, obs);
       }
     return ret;
   }
 
 
 }
 

Reply via email to