Author: jeremias
Date: Thu Jun 30 09:49:55 2011
New Revision: 1141461
URL: http://svn.apache.org/viewvc?rev=1141461&view=rev
Log:
Fixed a multi-threading bug for SVG images included through svg:image inside
SVG document. Similar to the fix required in PDFImageHandlerSVG. The SVG DOM
must be cloned because Batik attaches the CSS parser to the DOM tree and
manipulates the same.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java
xmlgraphics/fop/trunk/status.xml
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java?rev=1141461&r1=1141460&r2=1141461&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java
Thu Jun 30 09:49:55 2011
@@ -23,11 +23,15 @@ import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
+import org.w3c.dom.Element;
+import org.w3c.dom.svg.SVGDocument;
+
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.SVGImageElementBridge;
import org.apache.batik.gvt.AbstractGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.util.ParsedURL;
+
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
@@ -39,8 +43,8 @@ import org.apache.xmlgraphics.image.load
import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-import org.w3c.dom.Element;
-import org.w3c.dom.svg.SVGDocument;
+
+import org.apache.fop.image.loader.batik.BatikUtil;
/**
* Bridge class for the <image> element when jpeg images.
@@ -63,6 +67,7 @@ public abstract class AbstractFOPImageEl
* @param purl the parsed url for the image resource
* @return a new graphics node
*/
+ @Override
protected GraphicsNode createImageGraphicsNode
(BridgeContext ctx, Element imageElement, ParsedURL purl) {
AbstractFOPBridgeContext bridgeCtx = (AbstractFOPBridgeContext)ctx;
@@ -80,8 +85,11 @@ public abstract class AbstractFOPImageEl
if (image instanceof ImageXMLDOM) {
ImageXMLDOM xmlImage = (ImageXMLDOM)image;
if (xmlImage.getDocument() instanceof SVGDocument) {
- return createSVGImageNode(ctx, imageElement,
- (SVGDocument)xmlImage.getDocument());
+ //Clone DOM because the Batik's CSS Parser attaches to the
DOM and is therefore
+ //no thread-safe.
+ SVGDocument clonedDoc =
(SVGDocument)BatikUtil.cloneSVGDocument(
+ xmlImage.getDocument());
+ return createSVGImageNode(ctx, imageElement, clonedDoc);
} else {
//Convert image to Graphics2D
image = manager.convertImage(xmlImage,
Modified: xmlgraphics/fop/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1141461&r1=1141460&r2=1141461&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Thu Jun 30 09:49:55 2011
@@ -60,6 +60,9 @@
documents. Example: the fix of marks layering will be such a case when
it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="JM" type="fix">
+ Fixed a multi-threading bug for SVG images included through svg:image
inside SVG documents.
+ </action>
<action context="Renderers" dev="PH" type="add">
Added an IFDocumentHandler filter for triggering rendering events.
Created an Event that
captures an end page event with the page number.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]