Release memory from Batik GVT as early as possible to break some peaks. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1095876 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_1rc1old
@@ -31,6 +31,7 @@ import org.apache.xmlgraphics.image.loader.ImageFlavor; | |||
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; | |||
import org.apache.fop.render.AbstractImageHandlerGraphics2D; | |||
import org.apache.fop.render.ImageHandlerUtil; | |||
import org.apache.fop.render.RenderingContext; | |||
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo; | |||
import org.apache.fop.svg.PDFGraphics2D; | |||
@@ -60,8 +61,8 @@ public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D { | |||
float imw = (float)dim.getWidth() / 1000f; | |||
float imh = (float)dim.getHeight() / 1000f; | |||
float sx = fwidth / (float)imw; | |||
float sy = fheight / (float)imh; | |||
float sx = fwidth / imw; | |||
float sy = fheight / imh; | |||
generator.comment("G2D start"); | |||
boolean accessibilityEnabled = context.getUserAgent().isAccessibilityEnabled(); | |||
@@ -123,8 +124,16 @@ public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D { | |||
/** {@inheritDoc} */ | |||
public boolean isCompatible(RenderingContext targetContext, Image image) { | |||
return (image == null || image instanceof ImageGraphics2D) | |||
boolean supported = (image == null || image instanceof ImageGraphics2D) | |||
&& targetContext instanceof PDFRenderingContext; | |||
if (supported) { | |||
String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE); | |||
if (ImageHandlerUtil.isConversionModeBitmap(mode)) { | |||
//Disabling this image handler automatically causes a bitmap to be generated | |||
return false; | |||
} | |||
} | |||
return supported; | |||
} | |||
} |
@@ -43,6 +43,7 @@ import org.apache.fop.apps.FOUserAgent; | |||
import org.apache.fop.image.loader.batik.BatikImageFlavors; | |||
import org.apache.fop.image.loader.batik.BatikUtil; | |||
import org.apache.fop.render.ImageHandler; | |||
import org.apache.fop.render.ImageHandlerUtil; | |||
import org.apache.fop.render.RenderingContext; | |||
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo; | |||
import org.apache.fop.svg.PDFAElementBridge; | |||
@@ -200,6 +201,7 @@ public class PDFImageHandlerSVG implements ImageHandler { | |||
graphics.setOutputStream(generator.getOutputStream()); | |||
try { | |||
root.paint(graphics); | |||
ctx.dispose(); | |||
generator.add(graphics.getString()); | |||
} catch (Exception e) { | |||
SVGEventProducer eventProducer = SVGEventProducer.Provider.get( | |||
@@ -236,10 +238,18 @@ public class PDFImageHandlerSVG implements ImageHandler { | |||
/** {@inheritDoc} */ | |||
public boolean isCompatible(RenderingContext targetContext, Image image) { | |||
return (image == null | |||
boolean supported = (image == null | |||
|| (image instanceof ImageXMLDOM | |||
&& image.getFlavor().isCompatible(BatikImageFlavors.SVG_DOM))) | |||
&& targetContext instanceof PDFRenderingContext; | |||
if (supported) { | |||
String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE); | |||
if (ImageHandlerUtil.isConversionModeBitmap(mode)) { | |||
//Disabling this image handler automatically causes a bitmap to be generated | |||
return false; | |||
} | |||
} | |||
return supported; | |||
} | |||
} |