lehmi commented on a change in pull request #127:
URL: https://github.com/apache/pdfbox/pull/127#discussion_r685687060



##########
File path: 
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDGraphicsState.java
##########
@@ -601,7 +612,30 @@ public void intersectClippingPath(Area area)
      */
     public Area getCurrentClippingPath()
     {
-        return clippingPath;
+        if (clippingPaths.size() == 1)
+        {
+            // If there is just a single clipping path, no intersections are 
needed.
+            GeneralPath path = clippingPaths.get(0);
+            return clippingCache.computeIfAbsent(path, Area::new);
+        }
+        // If there are multiple clipping paths, combine them to a single area.
+        Area clippingArea = new Area();
+        clippingArea.add(new Area(clippingPaths.get(0)));
+        for (int i = 1; i < clippingPaths.size(); i++)
+        {
+            clippingArea.intersect(new Area(clippingPaths.get(i)));
+        }
+        // Replace the list of individual clipping paths with the 
intersection, and add it to the cache.
+        GeneralPath newPath = new GeneralPath(clippingArea);
+        clippingPaths = new ArrayList<>();
+        clippingPaths.add(newPath);
+        clippingCache.put(newPath, clippingArea);
+        return clippingArea;
+    }
+
+    public List<GeneralPath> getCurrentClippingPaths()
+    {
+        return clippingPaths;

Review comment:
       Maybe it is a good idea to return an unmodifiable version of that list 
so that it can't be modified from outside?
   
   `return Collections.unmodifiableList(clippingPaths)`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to