I have noticed that the setColor(fg) is called in several places just to update Cairo color from fg. This will not work correctly if setColor returns without action in the case when fg is equal to the parameter of the method. This patch fixes these occurences.

2006-05-29  Audrius Meskauskas  <[EMAIL PROTECTED]>

   * gnu/java/awt/peer/gtk/CairoGraphics2D.java
   (clearRect): Do not reuse the fd field, call updateColor.
   (drawRaster): Likewise.
   (setColor): Call updateColor.
   (updateColor): New method.
Index: CairoGraphics2D.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.2
diff -u -r1.2 CairoGraphics2D.java
--- CairoGraphics2D.java	30 May 2006 07:11:58 -0000	1.2
+++ CairoGraphics2D.java	30 May 2006 11:48:57 -0000
@@ -640,10 +640,20 @@
       {
         fg = c;
         paint = c;
-        cairoSetRGBAColor(fg.getRed() / 255.0, fg.getGreen() / 255.0,
-                          fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
+        updateColor();
       }
   }
+  
+  /**
+   * Set the current fg value as the cairo color.
+   */
+  void updateColor()
+  {
+    if (fg == null)
+      fg = Color.BLACK;
+    cairoSetRGBAColor(fg.getRed() / 255.0, fg.getGreen() / 255.0,
+                      fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
+  }
 
   public Color getColor()
   {
@@ -821,7 +831,7 @@
       cairoSetRGBAColor(bg.getRed() / 255.0, bg.getGreen() / 255.0,
 			bg.getBlue() / 255.0, 1.0);
     fillRect(x, y, width, height);
-    setColor(fg);
+    updateColor();
   }
 
   public void draw3DRect(int x, int y, int width, int height, boolean raised)
@@ -1308,8 +1318,8 @@
 
     drawPixels(pixels, r.getWidth(), r.getHeight(), r.getWidth(), i2u);
 
-    // Cairo seems loosing the current color.
-    setColor(fg);
+    // Cairo seems loosing the current color which must be restored.
+    updateColor();
     
     return true;
   }

Reply via email to