From: Jeremias Maerki Date: Thu, 30 Jun 2011 09:49:55 +0000 (+0000) Subject: Fixed a multi-threading bug for SVG images included through svg:image inside SVG... X-Git-Tag: fop-1_1rc1old~203 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6c398f41ee39093674c2d62cf62d689c2ac41911;p=xmlgraphics-fop.git 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. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1141461 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java index c4191077f..5d10a7d1b 100644 --- a/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java +++ b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java @@ -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.loader.impl.ImageRawCCITTFax; 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 AbstractFOPImageElementBridge extends SVGImageElementBridg * @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 AbstractFOPImageElementBridge extends SVGImageElementBridg 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, diff --git a/status.xml b/status.xml index ec3f9b6ff..3272607ac 100644 --- a/status.xml +++ b/status.xml @@ -60,6 +60,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Fixed a multi-threading bug for SVG images included through svg:image inside SVG documents. + Added an IFDocumentHandler filter for triggering rendering events. Created an Event that captures an end page event with the page number.