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/05/02 16:30:49 UTC

svn commit: r1889419 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Author: tilman
Date: Sun May  2 16:30:48 2021
New Revision: 1889419

URL: http://svn.apache.org/viewvc?rev=1889419&view=rev
Log:
PDFBOX-4892: optimize, 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=1889419&r1=1889418&r2=1889419&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 Sun May  2 16:30:48 2021
@@ -570,11 +570,14 @@ public class PageDrawer extends PDFGraph
         if (COSName.LUMINOSITY.equals(softMask.getSubType()))
         {
             COSArray backdropColorArray = softMask.getBackdropColor();
-            PDTransparencyGroup form = softMask.getGroup();
-            PDColorSpace colorSpace = form.getGroup().getColorSpace(form.getResources());
-            if (colorSpace != null && backdropColorArray != null)
+            if (backdropColorArray != null)
             {
-                backdropColor = new PDColor(backdropColorArray, colorSpace);
+                PDTransparencyGroup form = softMask.getGroup();
+                PDColorSpace colorSpace = form.getGroup().getColorSpace(form.getResources());
+                if (colorSpace != null)
+                {
+                    backdropColor = new PDColor(backdropColorArray, colorSpace);
+                }
             }
         }
         TransparencyGroup transparencyGroup = new TransparencyGroup(softMask.getGroup(), true, 
@@ -650,17 +653,17 @@ public class PageDrawer extends PDFGraph
     // returns the stroking AWT Paint
     private Paint getStrokingPaint() throws IOException
     {
+        PDGraphicsState graphicsState = getGraphicsState();
         return applySoftMaskToPaint(
-                getPaint(getGraphicsState().getStrokingColor()),
-                getGraphicsState().getSoftMask());
+                getPaint(graphicsState.getStrokingColor()), graphicsState.getSoftMask());
     }
 
     // returns the non-stroking AWT Paint
     private Paint getNonStrokingPaint() throws IOException
     {
+        PDGraphicsState graphicsState = getGraphicsState();
         return applySoftMaskToPaint(
-                getPaint(getGraphicsState().getNonStrokingColor()),
-                getGraphicsState().getSoftMask());
+                getPaint(graphicsState.getNonStrokingColor()), graphicsState.getSoftMask());
     }
 
     // create a new stroke based on the current CTM and the current stroke
@@ -705,19 +708,14 @@ public class PageDrawer extends PDFGraph
     {
         if (dashArray.length > 0)
         {
-            boolean allZero = true;
             for (int i = 0; i < dashArray.length; ++i)
             {
                 if (dashArray[i] != 0)
                 {
-                    allZero = false;
-                    break;
+                    return false;
                 }
             }
-            if (allZero)
-            {
-                return true;
-            }
+            return true;
         }
         return false;
     }