[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: further GdkGraphics2D fixes

Kaffe CVS cvs-commits at kaffe.org
Fri Dec 3 07:04:19 PST 2004


PatchSet 5521 
Date: 2004/12/03 14:59:55
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: further GdkGraphics2D fixes

2004-12-03  Dalibor Topic  <robilad at kaffe.org>

        * libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:
        Resynced with GNU Classpath.

        2004-11-28  Michael Koch  <konqueror at gmx.de>

        * gnu/java/awt/peer/gtk/GdkGraphics2D.java: Fix typo.

        2004-11-27  Sven de Marothy  <sven at physto.se>

        * gnu/java/awt/peer/gtk/GdkGraphics2D.java
        Reformatted.
        (drawRaster): Added FIXME.
        (drawRaster): Changed to work with packed-sample models.

Members: 
	ChangeLog:1.3067->1.3068 
	libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.9->1.10 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3067 kaffe/ChangeLog:1.3068
--- kaffe/ChangeLog:1.3067	Fri Dec  3 14:14:04 2004
+++ kaffe/ChangeLog	Fri Dec  3 14:59:55 2004
@@ -1,5 +1,21 @@
 2004-12-03  Dalibor Topic  <robilad at kaffe.org>
 
+	* libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:
+        Resynced with GNU Classpath.
+
+	2004-11-28  Michael Koch  <konqueror at gmx.de>
+
+	* gnu/java/awt/peer/gtk/GdkGraphics2D.java: Fix typo.
+
+	2004-11-27  Sven de Marothy  <sven at physto.se>
+
+	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
+        Reformatted.
+        (drawRaster): Added FIXME.
+        (drawRaster): Changed to work with packed-sample models.
+
+2004-12-03  Dalibor Topic  <robilad at kaffe.org>
+
 	* libraries/javalib/javax/swing/JList.java,
 	libraries/javalib/javax/swing/JTree.java:
         Resynced with GNU Classpath.
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.9 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.10
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java:1.9	Fri Dec  3 14:00:21 2004
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java	Fri Dec  3 14:59:59 2004
@@ -62,15 +62,15 @@
 import java.awt.Toolkit;
 import java.awt.color.ColorSpace;
 import java.awt.font.FontRenderContext;
-import java.awt.font.GlyphVector;
 import java.awt.font.GlyphJustificationInfo;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
 import java.awt.geom.Arc2D;
 import java.awt.geom.GeneralPath;
 import java.awt.geom.NoninvertibleTransformException;
 import java.awt.geom.PathIterator;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.awt.geom.AffineTransform;
 import java.awt.image.AffineTransformOp;
 import java.awt.image.BufferedImage;
 import java.awt.image.BufferedImageOp;
@@ -82,12 +82,13 @@
 import java.awt.image.ImageConsumer;
 import java.awt.image.ImageObserver;
 import java.awt.image.ImagingOpException;
-import java.awt.image.SampleModel;
+import java.awt.image.MultiPixelPackedSampleModel;
 import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
+import java.awt.image.SampleModel;
 import java.awt.image.WritableRaster;
-import java.awt.image.renderable.RenderableImage;
 import java.awt.image.renderable.RenderContext;
+import java.awt.image.renderable.RenderableImage;
 import java.text.AttributedCharacterIterator;
 import java.util.HashMap;
 import java.util.Map;
@@ -95,24 +96,21 @@
 
 public class GdkGraphics2D extends Graphics2D
 {
-
   //////////////////////////////////////
   ////// State Management Methods //////
   //////////////////////////////////////
+  static
+    {
+      if (Configuration.INIT_LOAD_LIBRARY)
+	System.loadLibrary("gtkpeer");
 
-  static 
-  {
-    if (Configuration.INIT_LOAD_LIBRARY)
-      {
-        System.loadLibrary("gtkpeer");
-      }
+      if (GtkToolkit.useGraphics2D())
+	initStaticState();
+    }
 
-    if (GtkToolkit.useGraphics2D ())
-      initStaticState ();
-  }
-  native static void initStaticState ();
-  private final int native_state = GtkGenericPeer.getUniqueInteger();  
+  static native void initStaticState();
 
+  private final int native_state = GtkGenericPeer.getUniqueInteger();
   private Paint paint;
   private Stroke stroke;
   private Color fg;
@@ -120,246 +118,268 @@
   private Shape clip;
   private AffineTransform transform;
   private GtkComponentPeer component;
-  private Font font;  
+  private Font font;
   private RenderingHints hints;
   private BufferedImage bimage;
-
   private Composite comp;
-
   private Stack stateStack;
-  
-  native private void initState (GtkComponentPeer component);
-  native private void initState (int width, int height);
-  native private void copyState (GdkGraphics2D g);
-  native public void dispose ();
-  native private int[] getImagePixels();
-  native private void cairoSurfaceSetFilter(int filter);
-  native void connectSignals (GtkComponentPeer component);
 
-  public void finalize ()
+  private native void initState(GtkComponentPeer component);
+
+  private native void initState(int width, int height);
+
+  private native void copyState(GdkGraphics2D g);
+
+  public native void dispose();
+
+  private native int[] getImagePixels();
+
+  private native void cairoSurfaceSetFilter(int filter);
+
+  native void connectSignals(GtkComponentPeer component);
+
+  public void finalize()
   {
     dispose();
   }
 
-  public Graphics create ()
+  public Graphics create()
   {
-    return new GdkGraphics2D (this);
+    return new GdkGraphics2D(this);
   }
 
-  public Graphics create (int x, int y, int width, int height)
+  public Graphics create(int x, int y, int width, int height)
   {
-    return new GdkGraphics2D (width, height);
+    return new GdkGraphics2D(width, height);
   }
 
-  GdkGraphics2D (GdkGraphics2D g)
+  GdkGraphics2D(GdkGraphics2D g)
   {
     paint = g.paint;
     stroke = g.stroke;
-    setRenderingHints (g.hints);
+    setRenderingHints(g.hints);
 
     if (g.fg.getAlpha() != -1)
-      fg = new Color (g.fg.getRed (), g.fg.getGreen (), 
-                      g.fg.getBlue (), g.fg.getAlpha ());
-    else 
-      fg = new Color (g.fg.getRGB ());
+      fg = new Color(g.fg.getRed(), g.fg.getGreen(), g.fg.getBlue(),
+                     g.fg.getAlpha());
+    else
+      fg = new Color(g.fg.getRGB());
 
     if (g.bg.getAlpha() != -1)
-      bg = new Color(g.bg.getRed (), g.bg.getGreen (), 
-                     g.bg.getBlue (), g.bg.getAlpha ());
+      bg = new Color(g.bg.getRed(), g.bg.getGreen(), g.bg.getBlue(),
+                     g.bg.getAlpha());
     else
-      bg = new Color (g.bg.getRGB ());
+      bg = new Color(g.bg.getRGB());
 
     if (g.clip == null)
       clip = null;
     else
-      clip = new Rectangle (g.getClipBounds ());
+      clip = new Rectangle(g.getClipBounds());
 
     if (g.transform == null)
-      transform = new AffineTransform ();
+      transform = new AffineTransform();
     else
-      transform = new AffineTransform (g.transform);
+      transform = new AffineTransform(g.transform);
 
     font = g.font;
     component = g.component;
-    copyState (g);
+    copyState(g);
 
-    setColor (fg);
-    setBackground (bg);
-    setPaint (paint);
-    setStroke (stroke);
-    setTransform (transform);
-    setClip (clip);
+    setColor(fg);
+    setBackground(bg);
+    setPaint(paint);
+    setStroke(stroke);
+    setTransform(transform);
+    setClip(clip);
     stateStack = new Stack();
   }
 
-  GdkGraphics2D (int width, int height)
+  GdkGraphics2D(int width, int height)
   {
-    initState (width, height);
+    initState(width, height);
 
     setColor(Color.black);
-    setBackground (Color.black);
-    setPaint (getColor());
-    setFont (new Font("SansSerif", Font.PLAIN, 12));
-    setTransform (new AffineTransform ());
-    setStroke (new BasicStroke ());
-    setRenderingHints (getDefaultHints());
+    setBackground(Color.black);
+    setPaint(getColor());
+    setFont(new Font("SansSerif", Font.PLAIN, 12));
+    setTransform(new AffineTransform());
+    setStroke(new BasicStroke());
+    setRenderingHints(getDefaultHints());
 
     stateStack = new Stack();
   }
 
-  GdkGraphics2D (GtkComponentPeer component)
+  GdkGraphics2D(GtkComponentPeer component)
   {
     this.component = component;
 
-    setFont (new Font("SansSerif", Font.PLAIN, 12));
+    setFont(new Font("SansSerif", Font.PLAIN, 12));
 
-    if (component.isRealized ())
-      initComponentGraphics2D ();
+    if (component.isRealized())
+      initComponentGraphics2D();
     else
-      connectSignals (component);
+      connectSignals(component);
   }
 
-  void initComponentGraphics2D ()
+  void initComponentGraphics2D()
   {
-    initState (component);
+    initState(component);
 
-    setColor (component.awtComponent.getForeground ());
-    setBackground (component.awtComponent.getBackground ());
-    setPaint (getColor());
-    setTransform (new AffineTransform ());
-    setStroke (new BasicStroke ());
-    setRenderingHints (getDefaultHints());
+    setColor(component.awtComponent.getForeground());
+    setBackground(component.awtComponent.getBackground());
+    setPaint(getColor());
+    setTransform(new AffineTransform());
+    setStroke(new BasicStroke());
+    setRenderingHints(getDefaultHints());
 
-    stateStack = new Stack ();
+    stateStack = new Stack();
   }
 
-  GdkGraphics2D (BufferedImage bimage)
+  GdkGraphics2D(BufferedImage bimage)
   {
-    
-    this.bimage = bimage;    
-    initState (bimage.getWidth(), bimage.getHeight());
+    this.bimage = bimage;
+    initState(bimage.getWidth(), bimage.getHeight());
 
     setColor(Color.black);
-    setBackground (Color.black);
-    setPaint (getColor());
-    setFont (new Font("SansSerif", Font.PLAIN, 12));
-    setTransform (new AffineTransform ());
-    setStroke (new BasicStroke ());
-    setRenderingHints (getDefaultHints());
+    setBackground(Color.black);
+    setPaint(getColor());
+    setFont(new Font("SansSerif", Font.PLAIN, 12));
+    setTransform(new AffineTransform());
+    setStroke(new BasicStroke());
+    setRenderingHints(getDefaultHints());
 
     stateStack = new Stack();
-    
+
     // draw current buffered image to the pixmap associated 
     // with it.
-    
-    drawImage (bimage, new AffineTransform (1,0,0,1,0,0), bg, null);
+    drawImage(bimage, new AffineTransform(1, 0, 0, 1, 0, 0), bg, null);
   }
 
-
   ////////////////////////////////////
   ////// Native Drawing Methods //////
   ////////////////////////////////////
-
   // GDK drawing methods
-  private native void gdkDrawDrawable (GdkGraphics2D other, int x, int y);
+  private native void gdkDrawDrawable(GdkGraphics2D other, int x, int y);
 
   // drawing utility methods
-  private native void drawPixels (int pixels[], int w, int h, int stride, double i2u[]);
-  private native void setTexturePixels (int pixels[], int w, int h, int stride);
-  private native void setGradient (double x1, double y1,
-                                   double x2, double y2,
-                                   int r1, int g1, int b1, int a1,
-                                   int r2, int g2, int b2, int a2,
-                                   boolean cyclic);
+  private native void drawPixels(int[] pixels, int w, int h, int stride,
+                                 double[] i2u);
+
+  private native void setTexturePixels(int[] pixels, int w, int h, int stride);
+
+  private native void setGradient(double x1, double y1, double x2, double y2,
+                                  int r1, int g1, int b1, int a1, int r2,
+                                  int g2, int b2, int a2, boolean cyclic);
 
   // simple passthroughs to cairo
-  private native void cairoSave ();
-  private native void cairoRestore ();
-  private native void cairoSetMatrix (double m[]);
-  private native void cairoSetOperator (int cairoOperator);
-  private native void cairoSetRGBColor (double red, double green, double blue);
-  private native void cairoSetAlpha (double alpha);
-  private native void cairoSetFillRule (int cairoFillRule);
-  private native void cairoSetLineWidth (double width);
-  private native void cairoSetLineCap (int cairoLineCap);
-  private native void cairoSetLineJoin (int cairoLineJoin);
-  private native void cairoSetDash (double dashes[], int ndash, double offset);
-  private native void cairoSetMiterLimit (double limit);
-  private native void cairoNewPath ();
-  private native void cairoMoveTo (double x, double y);
-  private native void cairoLineTo (double x, double y);
-  private native void cairoCurveTo (double x1, double y1,
-                                    double x2, double y2,
-                                    double x3, double y3);  
-  private native void cairoRelMoveTo (double dx, double dy);
-  private native void cairoRelLineTo (double dx, double dy);
-  private native void cairoRelCurveTo (double dx1, double dy1,
-                                       double dx2, double dy2,
-                                       double dx3, double dy3);
-  private native void cairoRectangle (double x, double y, 
-                                   double width, double height);
-  private native void cairoClosePath ();
-  private native void cairoStroke ();
-  private native void cairoFill ();
-  private native void cairoClip ();
+  private native void cairoSave();
+
+  private native void cairoRestore();
+
+  private native void cairoSetMatrix(double[] m);
+
+  private native void cairoSetOperator(int cairoOperator);
+
+  private native void cairoSetRGBColor(double red, double green, double blue);
+
+  private native void cairoSetAlpha(double alpha);
+
+  private native void cairoSetFillRule(int cairoFillRule);
+
+  private native void cairoSetLineWidth(double width);
+
+  private native void cairoSetLineCap(int cairoLineCap);
+
+  private native void cairoSetLineJoin(int cairoLineJoin);
+
+  private native void cairoSetDash(double[] dashes, int ndash, double offset);
+
+  private native void cairoSetMiterLimit(double limit);
+
+  private native void cairoNewPath();
+
+  private native void cairoMoveTo(double x, double y);
+
+  private native void cairoLineTo(double x, double y);
+
+  private native void cairoCurveTo(double x1, double y1, double x2, double y2,
+                                   double x3, double y3);
+
+  private native void cairoRelMoveTo(double dx, double dy);
+
+  private native void cairoRelLineTo(double dx, double dy);
+
+  private native void cairoRelCurveTo(double dx1, double dy1, double dx2,
+                                      double dy2, double dx3, double dy3);
 
+  private native void cairoRectangle(double x, double y, double width,
+                                     double height);
+
+  private native void cairoClosePath();
+
+  private native void cairoStroke();
+
+  private native void cairoFill();
+
+  private native void cairoClip();
 
   /////////////////////////////////////////////
   ////// General Drawing Support Methods //////
   /////////////////////////////////////////////
+  private class DrawState
+  {
+    private Paint paint;
+    private Stroke stroke;
+    private Color fg;
+    private Color bg;
+    private Shape clip;
+    private AffineTransform transform;
+    private Font font;
+    private Composite comp;
 
-    private class DrawState
-    {
-	private Paint paint;
-	private Stroke stroke;
-	private Color fg;
-	private Color bg;
-	private Shape clip;
-	private AffineTransform transform;
-	private Font font;  
-	private Composite comp;
-	DrawState (GdkGraphics2D g)
-	{
-	    this.paint = g.paint;
-	    this.stroke = g.stroke;
-	    this.fg = g.fg;
-	    this.bg = g.bg;
-	    this.clip = g.clip;
-	    if (g.transform != null)
-		this.transform = (AffineTransform) g.transform.clone();
-	    this.font = g.font;
-	    this.comp = g.comp;
-	}
-	public void restore(GdkGraphics2D g)
-	{
-	    g.paint = this.paint;
-	    g.stroke = this.stroke;
-	    g.fg = this.fg;
-	    g.bg = this.bg;
-	    g.clip = this.clip;
-	    g.transform = this.transform;
-	    g.font = this.font;
-	    g.comp = this.comp;
-	}
-    }
-    
-    private void stateSave ()
+    DrawState(GdkGraphics2D g)
     {
-	stateStack.push (new DrawState (this));
-	cairoSave ();
+      this.paint = g.paint;
+      this.stroke = g.stroke;
+      this.fg = g.fg;
+      this.bg = g.bg;
+      this.clip = g.clip;
+      if (g.transform != null)
+	this.transform = (AffineTransform) g.transform.clone();
+      this.font = g.font;
+      this.comp = g.comp;
     }
 
-    private void stateRestore ()
+    public void restore(GdkGraphics2D g)
     {
-	((DrawState)(stateStack.pop ())).restore (this);
-	cairoRestore ();
+      g.paint = this.paint;
+      g.stroke = this.stroke;
+      g.fg = this.fg;
+      g.bg = this.bg;
+      g.clip = this.clip;
+      g.transform = this.transform;
+      g.font = this.font;
+      g.comp = this.comp;
     }
+  }
+
+  private void stateSave()
+  {
+    stateStack.push(new DrawState(this));
+    cairoSave();
+  }
+
+  private void stateRestore()
+  {
+    ((DrawState) (stateStack.pop())).restore(this);
+    cairoRestore();
+  }
 
   // Some operations (drawing rather than filling) require that their
   // coords be shifted to land on 0.5-pixel boundaries, in order to land on
   // "middle of pixel" coordinates and light up complete pixels.
-
   private boolean shiftDrawCalls = false;
+
   private final double shifted(double coord, boolean doShift)
   {
     if (doShift)
@@ -372,82 +392,72 @@
   {
     double x = 0;
     double y = 0;
-    double coords[] = new double[6];
+    double[] coords = new double[6];
 
-    cairoSetFillRule (p.getWindingRule ());
-    for ( ; ! p.isDone (); p.next())
+    cairoSetFillRule(p.getWindingRule());
+    for (; ! p.isDone(); p.next())
       {
-        int seg = p.currentSegment (coords);
-        switch(seg)
-          {
-
-          case PathIterator.SEG_MOVETO:
-            x = shifted(coords[0], doShift);
-            y = shifted(coords[1], doShift);
-            cairoMoveTo (x, y);
-            break;
-
-          case PathIterator.SEG_LINETO:
-            x = shifted(coords[0], doShift);
-            y = shifted(coords[1], doShift);
-            cairoLineTo (x, y);
-            break;
-
-          case PathIterator.SEG_QUADTO:
-
-            // splitting a quadratic bezier into a cubic:
-            // see: http://pfaedit.sourceforge.net/bezier.html
-
-            double x1 = x + (2.0/3.0) * (shifted(coords[0], doShift) - x);
-            double y1 = y + (2.0/3.0) * (shifted(coords[1], doShift) - y);
-            
-            double x2 = x1 + (1.0/3.0) * (shifted(coords[2], doShift) - x);
-            double y2 = y1 + (1.0/3.0) * (shifted(coords[3], doShift) - y);
-
-            x = shifted(coords[2], doShift);
-            y = shifted(coords[3], doShift);
-            cairoCurveTo (x1, y1,
-                          x2, y2,
-                          x, y);
-            break;
-
-          case PathIterator.SEG_CUBICTO:
-            x = shifted(coords[4], doShift);
-            y = shifted(coords[5], doShift);
-            cairoCurveTo (shifted(coords[0], doShift), shifted(coords[1], doShift),
-                          shifted(coords[2], doShift), shifted(coords[3], doShift),
-                          x, y);
-            break;
-
-          case PathIterator.SEG_CLOSE:
-            cairoClosePath ();
-            break;
-          }
-      }    
+	int seg = p.currentSegment(coords);
+	switch (seg)
+	  {
+	  case PathIterator.SEG_MOVETO:
+	    x = shifted(coords[0], doShift);
+	    y = shifted(coords[1], doShift);
+	    cairoMoveTo(x, y);
+	    break;
+	  case PathIterator.SEG_LINETO:
+	    x = shifted(coords[0], doShift);
+	    y = shifted(coords[1], doShift);
+	    cairoLineTo(x, y);
+	    break;
+	  case PathIterator.SEG_QUADTO:
+	    // splitting a quadratic bezier into a cubic:
+	    // see: http://pfaedit.sourceforge.net/bezier.html
+	    double x1 = x + (2.0 / 3.0) * (shifted(coords[0], doShift) - x);
+	    double y1 = y + (2.0 / 3.0) * (shifted(coords[1], doShift) - y);
+
+	    double x2 = x1 + (1.0 / 3.0) * (shifted(coords[2], doShift) - x);
+	    double y2 = y1 + (1.0 / 3.0) * (shifted(coords[3], doShift) - y);
+
+	    x = shifted(coords[2], doShift);
+	    y = shifted(coords[3], doShift);
+	    cairoCurveTo(x1, y1, x2, y2, x, y);
+	    break;
+	  case PathIterator.SEG_CUBICTO:
+	    x = shifted(coords[4], doShift);
+	    y = shifted(coords[5], doShift);
+	    cairoCurveTo(shifted(coords[0], doShift),
+	                 shifted(coords[1], doShift),
+	                 shifted(coords[2], doShift),
+	                 shifted(coords[3], doShift), x, y);
+	    break;
+	  case PathIterator.SEG_CLOSE:
+	    cairoClosePath();
+	    break;
+	  }
+      }
   }
 
-
   private final Map getDefaultHints()
   {
-    HashMap defaultHints = new HashMap ();
-    
-    defaultHints.put (RenderingHints.KEY_TEXT_ANTIALIASING, 
-                      RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
-		      
-    defaultHints.put (RenderingHints.KEY_STROKE_CONTROL, 
-                      RenderingHints.VALUE_STROKE_DEFAULT);    
-		      
-    defaultHints.put (RenderingHints.KEY_FRACTIONALMETRICS, 
-                      RenderingHints.VALUE_FRACTIONALMETRICS_OFF);    
-		      
-    defaultHints.put (RenderingHints.KEY_ANTIALIASING, 
-                      RenderingHints.VALUE_ANTIALIAS_OFF);    
-		      
-    defaultHints.put (RenderingHints.KEY_RENDERING,  
-                      RenderingHints.VALUE_RENDER_DEFAULT);
-    
+    HashMap defaultHints = new HashMap();
+
+    defaultHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
+                     RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
+
+    defaultHints.put(RenderingHints.KEY_STROKE_CONTROL,
+                     RenderingHints.VALUE_STROKE_DEFAULT);
+
+    defaultHints.put(RenderingHints.KEY_FRACTIONALMETRICS,
+                     RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
+
+    defaultHints.put(RenderingHints.KEY_ANTIALIASING,
+                     RenderingHints.VALUE_ANTIALIAS_OFF);
+
+    defaultHints.put(RenderingHints.KEY_RENDERING,
+                     RenderingHints.VALUE_RENDER_DEFAULT);
+
     return defaultHints;
-    
   }
 
   private final void updateBufferedImage()
@@ -456,322 +466,288 @@
     updateImagePixels(pixels);
   }
 
-  
-  private final boolean isBufferedImageGraphics ()
+  private final boolean isBufferedImageGraphics()
   {
     return bimage != null;
   }
-    
-  private final void updateImagePixels (int[] pixels)
-  {
 
+  private final void updateImagePixels(int[] pixels)
+  {
     // This function can only be used if 
     // this graphics object is used to draw into 
     // buffered image 
-	
-    if (! isBufferedImageGraphics ()) 
+    if (! isBufferedImageGraphics())
       return;
 
-    WritableRaster raster = bimage.getRaster();		      
-    DataBuffer db = raster.getDataBuffer ();
+    WritableRaster raster = bimage.getRaster();
+    DataBuffer db = raster.getDataBuffer();
 
     // update pixels in the bufferedImage
-
-    if (raster.getSampleModel ().getDataType () == DataBuffer.TYPE_INT 
-        && db instanceof DataBufferInt 
-        && db.getNumBanks () == 1)
+    if (raster.getSampleModel().getDataType() == DataBuffer.TYPE_INT
+        && db instanceof DataBufferInt && db.getNumBanks() == 1)
       {
+	// single bank, ARGB-ints buffer in sRGB space
+	DataBufferInt dbi = (DataBufferInt) raster.getDataBuffer();
 
-        // single bank, ARGB-ints buffer in sRGB space
-        DataBufferInt dbi = (DataBufferInt) raster.getDataBuffer ();
-
-        for (int i=0; i < pixels.length; i++) 
-          dbi.setElem(i, pixels[i]);
-	 			
-      }
-    else 
-      {        
-        bimage.getRaster().setPixels (0, 0, raster.getWidth (),
-                                      raster.getHeight (), pixels);
+	for (int i = 0; i < pixels.length; i++)
+	  dbi.setElem(i, pixels[i]);
       }
+    else
+      bimage.getRaster().setPixels(0, 0, raster.getWidth(),
+                                   raster.getHeight(), pixels);
   }
 
-
-  private final boolean drawImage(Image img, 
-                                  AffineTransform xform,
-                                  Color bgcolor,			    
-                                  ImageObserver obs)
+  private final boolean drawImage(Image img, AffineTransform xform,
+                                  Color bgcolor, ImageObserver obs)
   {
-
     if (img == null)
       return false;
 
-    if (img instanceof GtkOffScreenImage &&
-        img.getGraphics () instanceof GdkGraphics2D &&            
-        (xform == null 
-         || xform.getType () == AffineTransform.TYPE_IDENTITY 
-         || xform.getType () == AffineTransform.TYPE_TRANSLATION)
-        ) 
-      {
-        // we are being asked to flush a double buffer from Gdk
-        GdkGraphics2D g2 = (GdkGraphics2D) img.getGraphics ();
-        gdkDrawDrawable (g2, (int)xform.getTranslateX(), (int)xform.getTranslateY());
-        
-        if (isBufferedImageGraphics ()) 
-          updateBufferedImage();   
-	 
-        return true;
-      }
-    else
-      {      
-
-        // In this case, xform is an AffineTransform that transforms bounding
-        // box of the specified image from image space to user space. However
-        // when we pass this transform to cairo, cairo will use this transform
-        // to map "user coordinates" to "pixel" coordinates, which is the 
-        // other way around. Therefore to get the "user -> pixel" transform 
-        // that cairo wants from "image -> user" transform that we currently
-        // have, we will need to invert the transformation matrix.
-	
-        AffineTransform invertedXform = new AffineTransform();
-
-        try
-          {             
-            invertedXform = xform.createInverse();
-             if (img instanceof BufferedImage)
-               {
-                   // draw an image which has actually been loaded 
-                   // into memory fully
-                   
-                 BufferedImage b = (BufferedImage) img;
-                 return drawRaster (b.getColorModel (), 
-                                    b.getData (), 
-                                    invertedXform,
-                                    bgcolor);
-               }
-             else
-               {
-                 return this.drawImage(GdkPixbufDecoder.createBufferedImage(img.getSource()),
-                                       xform, bgcolor,obs);
-               }	       
-          }
-        catch (NoninvertibleTransformException e)
-          {
-              throw new ImagingOpException("Unable to invert transform " 
-                                           + xform.toString());
-          } 	      
+    if (img instanceof GtkOffScreenImage
+        && img.getGraphics() instanceof GdkGraphics2D
+        && (xform == null || xform.getType() == AffineTransform.TYPE_IDENTITY
+        || xform.getType() == AffineTransform.TYPE_TRANSLATION))
+      {
+	// we are being asked to flush a double buffer from Gdk
+	GdkGraphics2D g2 = (GdkGraphics2D) img.getGraphics();
+	gdkDrawDrawable(g2, (int) xform.getTranslateX(),
+	                (int) xform.getTranslateY());
+
+	if (isBufferedImageGraphics())
+	  updateBufferedImage();
+
+	return true;
       }
-  }
+    else
+      {
+	// In this case, xform is an AffineTransform that transforms bounding
+	// box of the specified image from image space to user space. However
+	// when we pass this transform to cairo, cairo will use this transform
+	// to map "user coordinates" to "pixel" coordinates, which is the 
+	// other way around. Therefore to get the "user -> pixel" transform 
+	// that cairo wants from "image -> user" transform that we currently
+	// have, we will need to invert the transformation matrix.
+	AffineTransform invertedXform = new AffineTransform();
 
+	try
+	  {
+	    invertedXform = xform.createInverse();
+	    if (img instanceof BufferedImage)
+	      {
+		// draw an image which has actually been loaded 
+		// into memory fully
+		BufferedImage b = (BufferedImage) img;
+		return drawRaster(b.getColorModel(), b.getData(),
+		                  invertedXform, bgcolor);
+	      }
+	    else
+	      return this.drawImage(GdkPixbufDecoder.createBufferedImage(img
+	                                                                 .getSource()),
+	                            xform, bgcolor, obs);
+	  }
+	catch (NoninvertibleTransformException e)
+	  {
+	    throw new ImagingOpException("Unable to invert transform "
+	                                 + xform.toString());
+	  }
+      }
+  }
 
   //////////////////////////////////////////////////
   ////// Implementation of Graphics2D Methods //////
   //////////////////////////////////////////////////
-
-  public void draw (Shape s)
+  public void draw(Shape s)
   {
-
-    if (stroke != null &&
-        !(stroke instanceof BasicStroke))
+    if (stroke != null && ! (stroke instanceof BasicStroke))
       {
-        fill (stroke.createStrokedShape (s));
-        return;
+	fill(stroke.createStrokedShape(s));
+	return;
       }
 
-    cairoNewPath ();
-    
+    cairoNewPath();
+
     if (s instanceof Rectangle2D)
       {
-        Rectangle2D r = (Rectangle2D)s;
-        cairoRectangle (shifted(r.getX (), shiftDrawCalls), 
-                        shifted(r.getY (), shiftDrawCalls), 
-                        r.getWidth (), r.getHeight ());
-      }
-    else      
-      walkPath (s.getPathIterator (null), shiftDrawCalls);
-    cairoStroke ();
-    
-    if (isBufferedImageGraphics ()) 
-      updateBufferedImage();   
+	Rectangle2D r = (Rectangle2D) s;
+	cairoRectangle(shifted(r.getX(), shiftDrawCalls),
+	               shifted(r.getY(), shiftDrawCalls), r.getWidth(),
+	               r.getHeight());
+      }
+    else
+      walkPath(s.getPathIterator(null), shiftDrawCalls);
+    cairoStroke();
+
+    if (isBufferedImageGraphics())
+      updateBufferedImage();
   }
 
-  public void fill (Shape s)
+  public void fill(Shape s)
   {
-    cairoNewPath ();
+    cairoNewPath();
     if (s instanceof Rectangle2D)
       {
-        Rectangle2D r = (Rectangle2D)s;
-        cairoRectangle (r.getX (), r.getY (), r.getWidth (), r.getHeight ());
+	Rectangle2D r = (Rectangle2D) s;
+	cairoRectangle(r.getX(), r.getY(), r.getWidth(), r.getHeight());
       }
-    else      
-      walkPath (s.getPathIterator (null), false);
-    cairoFill ();
-    
-   if (isBufferedImageGraphics ()) 
-     updateBufferedImage();   
+    else
+      walkPath(s.getPathIterator(null), false);
+    cairoFill();
 
+    if (isBufferedImageGraphics())
+      updateBufferedImage();
   }
 
-  public void clip (Shape s)
+  public void clip(Shape s)
   {
-      // update it
+    // update it
+    if (clip == null || s == null)
+      clip = s;
+    else if (s instanceof Rectangle2D && clip instanceof Rectangle2D)
+      {
+	Rectangle2D r = (Rectangle2D) s;
+	Rectangle2D curr = (Rectangle2D) clip;
+	clip = curr.createIntersection(r);
+      }
+    else
+      throw new UnsupportedOperationException();
 
-      if (clip == null || s == null)
-	  clip = s;
-      else if (s instanceof Rectangle2D
-	       && clip instanceof Rectangle2D)
+    // draw it
+    if (clip != null)
+      {
+	cairoNewPath();
+	if (clip instanceof Rectangle2D)
 	  {
-	      Rectangle2D r = (Rectangle2D)s;
-	      Rectangle2D curr = (Rectangle2D)clip;
-	      clip = curr.createIntersection (r);
+	    Rectangle2D r = (Rectangle2D) clip;
+	    cairoRectangle(r.getX(), r.getY(), r.getWidth(), r.getHeight());
 	  }
-      else
-	  throw new UnsupportedOperationException ();
+	else
+	  walkPath(clip.getPathIterator(null), false);
 
-      // draw it
-      if (clip != null)
-	  {
-	      cairoNewPath ();
-	      if (clip instanceof Rectangle2D)
-		  {
-		      Rectangle2D r = (Rectangle2D)clip;
-		      cairoRectangle (r.getX (), r.getY (), 
-				      r.getWidth (), r.getHeight ());
-		  }
-	      else
-                walkPath (clip.getPathIterator (null), false);
-	      // cairoClosePath ();
-	      cairoClip ();
-	  }
+	// cairoClosePath ();
+	cairoClip();
+      }
   }
 
-  public Paint getPaint ()
+  public Paint getPaint()
   {
     return paint;
   }

*** Patch too long, truncated ***




More information about the kaffe mailing list