@@ -1084,7 +1084,8 @@ public void drawImage(PDImage pdImage) throws IOException
10841084 {
10851085 return ;
10861086 }
1087- Matrix ctm = getGraphicsState ().getCurrentTransformationMatrix ();
1087+ PDGraphicsState graphicsState = getGraphicsState ();
1088+ Matrix ctm = graphicsState .getCurrentTransformationMatrix ();
10881089 AffineTransform at = ctm .createAffineTransform ();
10891090
10901091 if (!pdImage .getInterpolate ())
@@ -1113,12 +1114,12 @@ public void drawImage(PDImage pdImage) throws IOException
11131114 }
11141115 }
11151116
1116- graphics .setComposite (getGraphicsState () .getNonStrokingJavaComposite ());
1117+ graphics .setComposite (graphicsState .getNonStrokingJavaComposite ());
11171118 setClip ();
11181119
11191120 if (pdImage .isStencil ())
11201121 {
1121- if (getGraphicsState () .getNonStrokingColor ().getColorSpace () instanceof PDPattern )
1122+ if (graphicsState .getNonStrokingColor ().getColorSpace () instanceof PDPattern )
11221123 {
11231124 // The earlier code for stencils (see "else") doesn't work with patterns because the
11241125 // CTM is not taken into consideration.
@@ -1497,21 +1498,23 @@ public void shadingFill(COSName shadingName) throws IOException
14971498 LOG .error ("shading {} does not exist in resources dictionary" , shadingName );
14981499 return ;
14991500 }
1500- Matrix ctm = getGraphicsState ().getCurrentTransformationMatrix ();
1501+ PDGraphicsState graphicsState = getGraphicsState ();
1502+ Matrix ctm = graphicsState .getCurrentTransformationMatrix ();
15011503
1502- graphics .setComposite (getGraphicsState () .getNonStrokingJavaComposite ());
1504+ graphics .setComposite (graphicsState .getNonStrokingJavaComposite ());
15031505 Shape savedClip = graphics .getClip ();
15041506 graphics .setClip (null );
15051507 lastClips = null ;
15061508
15071509 // get the transformed BBox and intersect with current clipping path
15081510 // need to do it here and not in shading getRaster() because it may have been rotated
15091511 PDRectangle bbox = shading .getBBox ();
1512+ Area currentClippingPath = graphicsState .getCurrentClippingPath ();
15101513 Area area ;
15111514 if (bbox != null )
15121515 {
15131516 area = new Area (bbox .transform (ctm ));
1514- area .intersect (getGraphicsState (). getCurrentClippingPath () );
1517+ area .intersect (currentClippingPath );
15151518 }
15161519 else
15171520 {
@@ -1523,18 +1526,18 @@ public void shadingFill(COSName shadingName) throws IOException
15231526 bounds .add (new Point2D .Double (Math .ceil (bounds .getMaxX () + 1 ),
15241527 Math .ceil (bounds .getMaxY () + 1 )));
15251528 area = new Area (bounds );
1526- area .intersect (getGraphicsState (). getCurrentClippingPath () );
1529+ area .intersect (currentClippingPath );
15271530 }
15281531 else
15291532 {
1530- area = getGraphicsState (). getCurrentClippingPath () ;
1533+ area = currentClippingPath ;
15311534 }
15321535 }
15331536 if (!area .isEmpty ())
15341537 {
15351538 // creating Paint is sometimes a costly operation, so avoid if possible
15361539 Paint paint = shading .toPaint (ctm );
1537- paint = applySoftMaskToPaint (paint , getGraphicsState () .getSoftMask ());
1540+ paint = applySoftMaskToPaint (paint , graphicsState .getSoftMask ());
15381541 graphics .setPaint (paint );
15391542 graphics .fill (area );
15401543 }
0 commit comments