You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2010/05/30 17:18:58 UTC

svn commit: r949528 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java status.xml

Author: jeremias
Date: Sun May 30 15:18:51 2010
New Revision: 949528

URL: http://svn.apache.org/viewvc?rev=949528&view=rev
Log:
Bugzilla #49338:
Using shorthand procedures for rectangles instead of the generic shape processor.
Submitted by: Submitted by: Julien Aymé <julien.ayme.at.gmail.com>

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
    xmlgraphics/commons/trunk/status.xml

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java?rev=949528&r1=949527&r2=949528&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java Sun May 30 15:18:51 2010
@@ -38,6 +38,7 @@ import java.awt.TexturePaint;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Area;
 import java.awt.geom.PathIterator;
+import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.awt.image.ImageObserver;
 import java.awt.image.RenderedImage;
@@ -367,7 +368,26 @@ public class PSGraphics2D extends Abstra
     }
 
     /**
-     * Processes a path iterator generating the nexessary painting operations.
+     * Processes a Shape generating the necessary painting operations.
+     * @param s Shape to process
+     * @return the winding rule of the path defining the shape
+     * @throws IOException In case of an I/O problem.
+     */
+    public int processShape(Shape s) throws IOException {
+        if (s instanceof Rectangle2D) {
+            // Special optimization in case of Rectangle Shape
+            Rectangle2D r = (Rectangle2D) s;
+            gen.defineRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+            return PathIterator.WIND_NON_ZERO;
+        } else {
+            PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM);
+            processPathIterator(iter);
+            return iter.getWindingRule();
+        }
+    }
+
+    /**
+     * Processes a path iterator generating the necessary painting operations.
      * @param iter PathIterator to process
      * @throws IOException In case of an I/O problem.
      */
@@ -449,8 +469,7 @@ public class PSGraphics2D extends Abstra
             applyStroke(getStroke());
 
             gen.writeln(gen.mapCommand("newpath"));
-            PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM);
-            processPathIterator(iter);
+            processShape(s);
             doDrawing(false, true, false);
             gen.restoreGraphicsState();
         } catch (IOException ioe) {
@@ -486,8 +505,7 @@ public class PSGraphics2D extends Abstra
             preparePainting();
             try {
                 gen.writeln(gen.mapCommand("newpath"));
-                PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM);
-                processPathIterator(iter);
+                processShape(s);
                 // clip area
                 gen.writeln(gen.mapCommand("clip"));
             } catch (IOException ioe) {
@@ -752,10 +770,9 @@ public class PSGraphics2D extends Abstra
             applyPaint(getPaint(), true);
 
             gen.writeln(gen.mapCommand("newpath"));
-            PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM);
-            processPathIterator(iter);
+            int windingRule = processShape(s);
             doDrawing(true, false,
-                      iter.getWindingRule() == PathIterator.WIND_EVEN_ODD);
+                    windingRule == PathIterator.WIND_EVEN_ODD);
             gen.restoreGraphicsState();
         } catch (IOException ioe) {
             handleIOException(ioe);

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=949528&r1=949527&r2=949528&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Sun May 30 15:18:51 2010
@@ -40,6 +40,9 @@
   </contexts>
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="JM" type="update" fixes-bug="49338" due-to="Julien Aymé">
+        Using shorthand procedures for rectangles instead of the generic shape processor.
+      </action>
       <action context="Code" dev="JM" type="update" fixes-bug="49337" due-to="Julien Aymé">
         Moved method disableClipping from AbstractPSDocumentGraphics2D to PSGraphics2D.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org