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/03/20 14:37:30 UTC
svn commit: r1887862 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Author: tilman
Date: Sat Mar 20 14:37:30 2021
New Revision: 1887862
URL: http://svn.apache.org/viewvc?rev=1887862&view=rev
Log:
PDFBOX-4892: performance improvements, as suggested by valerybokov
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1887862&r1=1887861&r2=1887862&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Sat Mar 20 14:37:30 2021
@@ -34,6 +34,7 @@ import java.awt.color.ColorSpace;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
+import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
@@ -432,7 +433,7 @@ public class PageDrawer extends PDFGraph
{
// PDFBOX-4150: this is much faster than using textClippingArea.add(new Area(glyph))
// https://stackoverflow.com/questions/21519007/fast-union-of-shapes-in-java
- GeneralPath path = new GeneralPath();
+ GeneralPath path = new GeneralPath(Path2D.WIND_NON_ZERO, textClippings.size());
for (Shape shape : textClippings)
{
path.append(shape, false);
@@ -1356,10 +1357,14 @@ public class PageDrawer extends PDFGraph
{
lastClip = null;
int deviceType = -1;
- if (graphics.getDeviceConfiguration() != null &&
- graphics.getDeviceConfiguration().getDevice() != null)
+ GraphicsConfiguration graphicsConfiguration = graphics.getDeviceConfiguration();
+ if (graphicsConfiguration != null)
{
- deviceType = graphics.getDeviceConfiguration().getDevice().getType();
+ GraphicsDevice graphicsDevice = graphicsConfiguration.getDevice();
+ if (graphicsDevice != null)
+ {
+ deviceType = graphicsDevice.getType();
+ }
}
if (deviceType == GraphicsDevice.TYPE_PRINTER && !annotation.isPrinted())
{