You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/11/10 19:11:52 UTC
svn commit: r1894927 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Author: tilman
Date: Wed Nov 10 19:11:51 2021
New Revision: 1894927
URL: http://svn.apache.org/viewvc?rev=1894927&view=rev
Log:
PDFBOX-5319: avoid creating Paint objects and filling when there is nothing to do
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1894927&r1=1894926&r2=1894927&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Wed Nov 10 19:11:51 2021
@@ -874,7 +874,6 @@ public class PageDrawer extends PDFGraph
public void fillPath(int windingRule) throws IOException
{
graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite());
- graphics.setPaint(getNonStrokingPaint());
setClip();
linePath.setWindingRule(windingRule);
@@ -908,8 +907,10 @@ public class PageDrawer extends PDFGraph
{
shape = linePath;
}
- if (isContentRendered())
+ if (isContentRendered() && !shape.getPathIterator(null).isDone())
{
+ // creating Paint is sometimes a costly operation, so avoid if possible
+ graphics.setPaint(getNonStrokingPaint());
graphics.fill(shape);
}
@@ -1436,11 +1437,8 @@ public class PageDrawer extends PDFGraph
return;
}
Matrix ctm = getGraphicsState().getCurrentTransformationMatrix();
- Paint paint = shading.toPaint(ctm);
- paint = applySoftMaskToPaint(paint, getGraphicsState().getSoftMask());
graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite());
- graphics.setPaint(paint);
Shape savedClip = graphics.getClip();
graphics.setClip(null);
lastClips = null;
@@ -1471,7 +1469,14 @@ public class PageDrawer extends PDFGraph
area = getGraphicsState().getCurrentClippingPath();
}
}
- graphics.fill(area);
+ if (!area.isEmpty())
+ {
+ // creating Paint is sometimes a costly operation, so avoid if possible
+ Paint paint = shading.toPaint(ctm);
+ paint = applySoftMaskToPaint(paint, getGraphicsState().getSoftMask());
+ graphics.setPaint(paint);
+ graphics.fill(area);
+ }
graphics.setClip(savedClip);
}