You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2002/01/02 22:21:17 UTC
cvs commit: xml-batik/sources/org/apache/batik/gvt/renderer StaticRenderer.java
deweese 02/01/02 13:21:17
Modified: . build.xml
samples mathMetal.svg
sources/org/apache/batik/ext/awt/image GraphicsUtil.java
sources/org/apache/batik/ext/awt/image/renderable
RedRable.java
sources/org/apache/batik/gvt AbstractGraphicsNode.java
GraphicsNode.java RasterImageNode.java
sources/org/apache/batik/gvt/renderer StaticRenderer.java
Log:
1) Added maxmemory="128m" to javadoc rule otherwise I run out of memory.
2) Improved some of the filters in mathMetal.svg
3) while looking at #2 I found a very serious performance bug when
filtering raster images. This has cut rendering time for
mathMetal and book of kells by about 3x. I have an incling there
are some additional optimizations to be made here...
Revision Changes Path
1.100 +2 -1 xml-batik/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-batik/build.xml,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- build.xml 18 Dec 2001 09:21:22 -0000 1.99
+++ build.xml 2 Jan 2002 21:21:16 -0000 1.100
@@ -47,7 +47,7 @@
[win32] .\build.bat help
- $Id: build.xml,v 1.99 2001/12/18 09:21:22 vhardy Exp $
+ $Id: build.xml,v 1.100 2002/01/02 21:21:16 deweese Exp $
-->
@@ -893,6 +893,7 @@
org.xml.*,
org.w3c.css.*,
org.w3c.dom.*"
+ maxmemory="128m"
sourcepath="${src}"
destdir="${docs}/javadoc"
author="false"
1.2 +49 -50 xml-batik/samples/mathMetal.svg
Index: mathMetal.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/mathMetal.svg,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mathMetal.svg 3 Dec 2001 15:20:38 -0000 1.1
+++ mathMetal.svg 2 Jan 2002 21:21:16 -0000 1.2
@@ -16,7 +16,7 @@
<!-- -->
<!-- @author Christophe.Held@sophia.inria.fr for the MathML formula -->
<!-- @author vincent.hardy@eng.sun.com for the filter effects -->
-<!-- @version $Id: mathMetal.svg,v 1.1 2001/12/03 15:20:38 vhardy Exp $ -->
+<!-- @version $Id: mathMetal.svg,v 1.2 2002/01/02 21:21:16 deweese Exp $ -->
<!-- ========================================================================= -->
<?xml-stylesheet type="text/css" href="tests/resources/style/test.css" ?>
@@ -288,92 +288,97 @@
<circle cx="396" cy="395" r="10" fill="white" /> -->
</g>
- <filter id="emboss">
- <feFlood flood-color="white" />
- <feMerge result="whiteOnBlack">
- <feMergeNode />
- <feMergeNode in="SourceGraphic" />
- </feMerge>
- <feGaussianBlur stdDeviation="1" />
- <feConvolveMatrix order="3" kernelMatrix="-.5 0 0 0 1 0 0 0 .5" result="convolved" />
- <feComposite operator="arithmetic" in="convolved" in2="whiteOnBlack"
- k1="0" k2=".5" k3="-.5" k4=".5" />
- <feComponentTransfer>
- <feFuncA type="linear" slope="0" intercept="1" offset="1"/>
- </feComponentTransfer>
- </filter>
-
<filter id="tint" >
- <feImage xlink:href="#graphics" x="0" y="0" width="450" height="500" result="graphic"/>
+ <feImage xlink:href="#graphics"
+ x="0" y="0" width="450" height="500" result="graphic"/>
<feFlood flood-color="rgb(75,118,197)" result="lightColorFlood" />
<feFlood flood-color="rgb(95,138,197)" result="darkColorFlood" />
- <feComposite operator="in" in="lightColorFlood" in2="graphic" result="lightTint"/>
- <feComposite operator="out" in="darkColorFlood" in2="graphic" result="darkTint"/>
-
- <feMerge result="tint">
+ <feComposite operator="in" in="lightColorFlood" in2="graphic"
+ result="lightTint"/>
+
+ <feMerge result="tint">
+ <feMergeNode in="darkColorFlood" />
<feMergeNode in="lightTint" />
- <feMergeNode in="darkTint" />
- </feMerge>
+ </feMerge>
<feComposite operator="arithmetic" in="tint" in2="SourceGraphic"
k1="1" k2="0" k3=".5" k4="0" />
+ </filter>
+
+
+ <filter id="tint2" >
+ <feComponentTransfer in="SourceGraphic" result="dark">
+ <feFuncR type="linear" slope="0.6144" intercept="0" />
+ <feFuncG type="linear" slope="0.7542" intercept="0" />
+ <feFuncB type="linear" slope="1.0568" intercept="0" />
+ </feComponentTransfer>
+
+ <feComponentTransfer in="SourceGraphic" result="light">
+ <feFuncR type="linear" slope="0.5706" intercept="0" />
+ <feFuncG type="linear" slope="0.6804" intercept="0" />
+ <feFuncB type="linear" slope="1.0568" intercept="0" />
+ </feComponentTransfer>
+ <feImage xlink:href="#graphics"
+ x="0" y="0" width="450" height="500" result="graphic"/>
+ <feComposite operator="in" in="light" in2="graphic"
+ result="lightTint"/>
+
+ <feMerge result="tint">
+ <feMergeNode in="dark" />
+ <feMergeNode in="lightTint" />
+ </feMerge>
</filter>
<filter id="recessed" >
+ <feFlood flood-color="white" flood-opacity="1"
+ result="whiteFlood"/>
+
<feGaussianBlur stdDeviation="2" in="SourceGraphic" />
<feComponentTransfer >
<feFuncA type="linear" slope="-1" intercept="1" />
</feComponentTransfer>
+ <feOffset dx="-3" dy="3" result="shadow"/>
- <feOffset dx="-3" dy="3" />
- <feComposite operator="in" in2="SourceAlpha" result="shadow"/>
- <feFlood flood-color="white" flood-opacity="1" result="whiteFlood"/>
- <feComposite operator="out" in2="SourceAlpha"/>
- <feOffset dx="1" dy="-1" />
- <feComposite operator="in" in2="SourceAlpha" result="whiteTrim"/>
+ <feComposite operator="out" in="whiteFlood" in2="SourceAlpha"/>
+ <feOffset dx="1" dy="-1" result="whiteTrim"/>
<feFlood flood-color="black" flood-opacity=".4"/>
<feComposite operator="out" in2="SourceAlpha"/>
- <feOffset dx="-1" dy="1" />
- <feComposite operator="in" in2="SourceAlpha" result="blackTrim"/>
-
- <feComposite operator="in" in="whiteFlood" in2="SourceAlpha" result="whiteBkg" />
+ <feOffset dx="-1" dy="1" result="blackTrim" />
<feMerge>
- <feMergeNode in="whiteBkg" />
+ <feMergeNode in="whiteFlood" />
<feMergeNode in="shadow" />
<feMergeNode in="whiteTrim"/>
<feMergeNode in="blackTrim"/>
</feMerge>
-
+
+ <feComposite operator="in" in2="SourceAlpha"/>
</filter>
<filter id="shadow">
<feGaussianBlur in="SourceAlpha" stdDeviation="3" />
<feOffset dx="-5" dy="5" />
- <feComponentTransfer>
+ <feComponentTransfer result="shadow">
<feFuncA type="linear" slope=".57" />
</feComponentTransfer>
- <feComposite operator="out" in2="SourceGraphic" result="shadow"/>
-
- <feFlood flood-color="white" result="whiteFlood" />
+ <feFlood flood-color="white"/>
<feComposite operator="in" in2="SourceAlpha"/>
- <feOffset dx="1" dy="-1" />
- <feComposite operator="out" in2="SourceAlpha" result="whiteTrim"/>
+ <feOffset dx="1" dy="-1" result="whiteTrim"/>
<feFlood flood-color="black" flood-opacity=".4"/>
<feComposite operator="in" in2="SourceAlpha"/>
- <feOffset dx="-1" dy="1" />
- <feComposite operator="out" in2="SourceAlpha" result="blackTrim"/>
-
+ <feOffset dx="-1" dy="1" result="blackTrim"/>
<feMerge>
<feMergeNode in="shadow" />
<feMergeNode in="whiteTrim"/>
<feMergeNode in="blackTrim"/>
</feMerge>
+
+ <feComposite operator="out" in2="SourceAlpha"/>
</filter>
<filter id="carved">
@@ -388,12 +393,6 @@
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
-
- <radialGradient id="backgroundGradient" cx="500" cy="-50" r="900" gradientUnits="userSpaceOnUse">
- <stop offset="0" stop-color="white" />
- <stop offset=".5" stop-color="rgb(95,138,197)" />
- <stop offset="1" stop-color="black" />
- </radialGradient>
</defs>
<image width="100%" height="100%" xlink:href="tests/resources/images/brushedMetal.jpg" filter="url(#tint)"/>
1.23 +13 -5 xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java
Index: GraphicsUtil.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- GraphicsUtil.java 14 Dec 2001 01:07:50 -0000 1.22
+++ GraphicsUtil.java 2 Jan 2002 21:21:16 -0000 1.23
@@ -66,7 +66,7 @@
* implementations.
*
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id: GraphicsUtil.java,v 1.22 2001/12/14 01:07:50 deweese Exp $
+ * @version $Id: GraphicsUtil.java,v 1.23 2002/01/02 21:21:16 deweese Exp $
*/
public class GraphicsUtil {
@@ -284,9 +284,18 @@
}
// System.out.println("Starting Draw: " + cr);
- long startTime = System.currentTimeMillis();
+ // long startTime = System.currentTimeMillis();
- if (useMacOSXHacks) {
+ boolean useDrawRenderedImage = useMacOSXHacks;
+
+ SampleModel srcSM = cr.getSampleModel();
+ if ((srcSM.getWidth()*srcSM.getHeight()) >
+ (4*clipR.width*clipR.height))
+ // if srcSM tiles are 4x the clip size then just
+ // draw the renderedImage
+ useDrawRenderedImage = true;
+
+ if (useDrawRenderedImage) {
// We use this code path on MacOSX since the tile
// drawing code below sometimes dies for no real
// reason this seems to behave better.
@@ -298,7 +307,6 @@
} else {
// Use tiles to draw image...
srcCM = cr.getColorModel();
- SampleModel srcSM = cr.getSampleModel();
WritableRaster wr;
wr = Raster.createWritableRaster(srcSM, new Point(0,0));
BufferedImage bi = new BufferedImage
@@ -394,7 +402,7 @@
xloc += xStep; // Get back in bounds.
}
}
- long endTime = System.currentTimeMillis();
+ // long endTime = System.currentTimeMillis();
// System.out.println("Time: " + (endTime-startTime));
1.4 +22 -5 xml-batik/sources/org/apache/batik/ext/awt/image/renderable/RedRable.java
Index: RedRable.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/renderable/RedRable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RedRable.java 3 May 2001 22:10:45 -0000 1.3
+++ RedRable.java 2 Jan 2002 21:21:16 -0000 1.4
@@ -19,6 +19,7 @@
import org.apache.batik.ext.awt.image.PadMode;
import org.apache.batik.ext.awt.image.rendered.CachableRed;
import org.apache.batik.ext.awt.image.rendered.AffineRed;
+import org.apache.batik.ext.awt.image.rendered.TranslateRed;
import org.apache.batik.ext.awt.image.rendered.PadRed;
/**
@@ -26,7 +27,7 @@
* RenderableImage world.
*
* @author <a href="mailto:Thomas.DeWeese@Kodak.com>Thomas DeWeese</a>
- * @version $Id: RedRable.java,v 1.3 2001/05/03 22:10:45 deweese Exp $
+ * @version $Id: RedRable.java,v 1.4 2002/01/02 21:21:16 deweese Exp $
*/
public class RedRable
extends AbstractRable {
@@ -59,6 +60,8 @@
public RenderedImage createRendering(RenderContext rc) {
+ // System.out.println("RedRable Create Rendering: " + this);
+
// Just copy over the rendering hints.
RenderingHints rh = rc.getRenderingHints();
if (rh == null) rh = new RenderingHints(null);
@@ -80,12 +83,26 @@
if (aoiR.intersects(cr.getBounds()) == false)
return null;
- aoiR = aoiR.intersection(cr.getBounds());
- // Get the device bounds, we will crop the affine to those
- // bounds.
- Rectangle devAOI = at.createTransformedShape(aoiR).getBounds();
+ if (at.isIdentity()) {
+ // System.out.println("Using as is");
+ return cr;
+ }
+
+ if ((at.getScaleX() == 1.0) && (at.getScaleY() == 1.0) &&
+ (at.getShearX() == 0.0) && (at.getShearY() == 0.0)) {
+ int xloc = (int)(cr.getMinX()+at.getTranslateX());
+ int yloc = (int)(cr.getMinY()+at.getTranslateY());
+ double dx = xloc - (cr.getMinX()+at.getTranslateX());
+ double dy = yloc - (cr.getMinY()+at.getTranslateY());
+ if (((dx > -0.0001) && (dx < 0.0001)) &&
+ ((dy > -0.0001) && (dy < 0.0001))) {
+ // System.out.println("Using TranslateRed");
+ return new TranslateRed(cr, xloc, yloc);
+ }
+ }
+ // System.out.println("Using Full affine: " + at);
return new AffineRed(cr, at, rh);
}
}
1.30 +2 -2 xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java
Index: AbstractGraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- AbstractGraphicsNode.java 19 Dec 2001 16:17:41 -0000 1.29
+++ AbstractGraphicsNode.java 2 Jan 2002 21:21:16 -0000 1.30
@@ -51,7 +51,7 @@
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @author <a href="mailto:etissandier@ilog.fr">Emmanuel Tissandier</a>
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id: AbstractGraphicsNode.java,v 1.29 2001/12/19 16:17:41 tkormann Exp $
+ * @version $Id: AbstractGraphicsNode.java,v 1.30 2002/01/02 21:21:16 deweese Exp $
*/
public abstract class AbstractGraphicsNode implements GraphicsNode {
@@ -340,7 +340,7 @@
* The GraphicsNodeRable is the Renderable (Filter) before any
* of the filter operations have been applied.
*/
- public GraphicsNodeRable getGraphicsNodeRable() {
+ public Filter getGraphicsNodeRable() {
GraphicsNodeRable ret = null;
if (graphicsNodeRable != null) {
ret = (GraphicsNodeRable)graphicsNodeRable.get();
1.32 +4 -5 xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java
Index: GraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- GraphicsNode.java 19 Dec 2001 16:17:41 -0000 1.31
+++ GraphicsNode.java 2 Jan 2002 21:21:16 -0000 1.32
@@ -25,7 +25,6 @@
import org.apache.batik.gvt.event.GraphicsNodeMouseEvent;
import org.apache.batik.gvt.event.GraphicsNodeMouseListener;
import org.apache.batik.gvt.filter.Mask;
-import org.apache.batik.gvt.filter.GraphicsNodeRable;
/**
* The base class for all graphics nodes. A GraphicsNode encapsulates
@@ -34,7 +33,7 @@
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @author <a href="mailto:etissandier@ilog.fr">Emmanuel Tissandier</a>
- * @version $Id: GraphicsNode.java,v 1.31 2001/12/19 16:17:41 tkormann Exp $
+ * @version $Id: GraphicsNode.java,v 1.32 2002/01/02 21:21:16 deweese Exp $
*/
public interface GraphicsNode {
@@ -230,11 +229,11 @@
Filter getFilter();
/**
- * Returns the GraphicsNodeRable for this node.
- * The GraphicsNodeRable is the Renderable (Filter) before any
+ * Returns the Filter for this node.
+ * The Filter is the Graphics Node before any
* of the filter operations have been applied.
*/
- GraphicsNodeRable getGraphicsNodeRable();
+ Filter getGraphicsNodeRable();
//
// Drawing methods
1.10 +10 -1 xml-batik/sources/org/apache/batik/gvt/RasterImageNode.java
Index: RasterImageNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/RasterImageNode.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- RasterImageNode.java 18 Sep 2001 21:19:00 -0000 1.9
+++ RasterImageNode.java 2 Jan 2002 21:21:16 -0000 1.10
@@ -22,7 +22,7 @@
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @author <a href="mailto:Thomas.DeWeese@Kodak.com>Thomas DeWeese</a>
- * @version $Id: RasterImageNode.java,v 1.9 2001/09/18 21:19:00 deweese Exp $
+ * @version $Id: RasterImageNode.java,v 1.10 2002/01/02 21:21:16 deweese Exp $
*/
public class RasterImageNode extends AbstractGraphicsNode {
@@ -99,6 +99,15 @@
*/
public Rectangle2D getImageBounds() {
return (Rectangle2D) imageBounds.clone();
+ }
+
+ /**
+ * Returns the RenderableImage for this node. The returned
+ * RenderableImage this node before any of the filter operations
+ * have been applied.
+ */
+ public Filter getGraphicsNodeRable() {
+ return image;
}
/**
1.18 +12 -12 xml-batik/sources/org/apache/batik/gvt/renderer/StaticRenderer.java
Index: StaticRenderer.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/StaticRenderer.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- StaticRenderer.java 27 Sep 2001 20:09:11 -0000 1.17
+++ StaticRenderer.java 2 Jan 2002 21:21:17 -0000 1.18
@@ -9,10 +9,10 @@
package org.apache.batik.gvt.renderer;
import org.apache.batik.gvt.GraphicsNode;
-import org.apache.batik.gvt.filter.GraphicsNodeRable;
import org.apache.batik.ext.awt.image.GraphicsUtil;
import org.apache.batik.ext.awt.image.PadMode;
+import org.apache.batik.ext.awt.image.renderable.Filter;
import org.apache.batik.ext.awt.image.rendered.CachableRed;
import org.apache.batik.ext.awt.image.rendered.PadRed;
import org.apache.batik.ext.awt.image.rendered.TranslateRed;
@@ -43,7 +43,7 @@
* rendering in an offscreen buffer image.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com>Vincent Hardy</a>
- * @version $Id: StaticRenderer.java,v 1.17 2001/09/27 20:09:11 deweese Exp $
+ * @version $Id: StaticRenderer.java,v 1.18 2002/01/02 21:21:17 deweese Exp $
*/
public class StaticRenderer implements ImageRenderer {
/**
@@ -58,7 +58,7 @@
* Tree this Renderer paints.
*/
protected GraphicsNode rootGN;
- protected GraphicsNodeRable rootGNR;
+ protected Filter rootFilter;
protected CachableRed rootCR;
protected SoftReference lastCR;
protected SoftReference lastCache;
@@ -121,9 +121,9 @@
* Disposes all resources of this renderer.
*/
public void dispose() {
- rootGN = null;
- rootGNR = null;
- rootCR = null;
+ rootGN = null;
+ rootFilter = null;
+ rootCR = null;
workingOffScreen = null;
workingBaseRaster = null;
@@ -143,8 +143,8 @@
*/
public void setTree(GraphicsNode rootGN){
this.rootGN = rootGN;
- rootGNR = null;
- rootCR = null;
+ rootFilter = null;
+ rootCR = null;
workingOffScreen = null;
workingBaseRaster = null;
@@ -170,7 +170,7 @@
public void setRenderingHints(RenderingHints rh) {
renderingHints = new RenderingHints(rh);
- rootGNR = null;
+ rootFilter = null;
rootCR = null;
workingOffScreen = null;
@@ -423,7 +423,7 @@
RenderContext rc = new RenderContext(rcAT, null, renderingHints);
- RenderedImage ri = rootGNR.createRendering(rc);
+ RenderedImage ri = rootFilter.createRendering(rc);
if (ri == null)
return null;
@@ -445,8 +445,8 @@
* various set methods.
*/
protected void updateWorkingBuffers() {
- if (rootGNR == null) {
- rootGNR = rootGN.getGraphicsNodeRable();
+ if (rootFilter == null) {
+ rootFilter = rootGN.getGraphicsNodeRable();
rootCR = null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org