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 16:56:14 UTC

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

Author: jeremias
Date: Sun May 30 14:56:13 2010
New Revision: 949522

URL: http://svn.apache.org/viewvc?rev=949522&view=rev
Log:
Bugzilla #49056:
Small optimization which only generates code for a clipping area if an element is not fully inside the clipping area.
Submitted by: Calixte Denizet <calixte.denizet.at.ac-rennes.fr>

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=949522&r1=949521&r2=949522&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 14:56:13 2010
@@ -36,6 +36,7 @@ import java.awt.Shape;
 import java.awt.Stroke;
 import java.awt.TexturePaint;
 import java.awt.geom.AffineTransform;
+import java.awt.geom.Area;
 import java.awt.geom.PathIterator;
 import java.awt.image.BufferedImage;
 import java.awt.image.ImageObserver;
@@ -430,7 +431,9 @@ public class PSGraphics2D extends Abstra
                 gen.concatMatrix(trans);
             }
             Shape imclip = getClip();
-            writeClip(imclip);
+            if (shouldBeClipped(imclip, s)) {
+                writeClip(imclip);
+            }
             establishColor(getColor());
 
             applyPaint(getPaint(), false);
@@ -447,6 +450,22 @@ public class PSGraphics2D extends Abstra
     }
 
     /**
+     * Determinates if a shape is included into a clipping region
+     * @param clip Shape defining the clipping region
+     * @param s Shape to be drawn
+     * @return a boolean
+     */
+    public boolean shouldBeClipped(Shape clip, Shape s) {
+        if (clip == null || s == null) {
+            return false;
+        }
+        Area as = new Area(s);
+        Area imclip = new Area(clip);
+        imclip.intersect(as);
+        return !imclip.equals(as);
+    }
+
+    /**
      * Establishes a clipping region
      * @param s Shape defining the clipping region
      */
@@ -715,7 +734,9 @@ public class PSGraphics2D extends Abstra
                 gen.concatMatrix(trans);
             }
             Shape imclip = getClip();
-            writeClip(imclip);
+            if (shouldBeClipped(imclip, s)) {
+                writeClip(imclip);
+            }
 
             establishColor(getColor());
 

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=949522&r1=949521&r2=949522&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Sun May 30 14:56:13 2010
@@ -40,6 +40,10 @@
   </contexts>
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="JM" type="add" fixes-bug="49056" due-to="Calixte Denizet">
+        Small optimization which only generates code for a clipping area if an element is not
+        fully inside the clipping area.
+      </action>
       <action context="Code" dev="JM" type="add" fixes-bug="48797">
         Added option to enable/disable the generation of compact vs. verbose PostScript code.
       </action>



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